当前位置: 首页>>代码示例>>C#>>正文


C# Bag.AddItem方法代码示例

本文整理汇总了C#中Server.Items.Bag.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# Bag.AddItem方法的具体用法?C# Bag.AddItem怎么用?C# Bag.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server.Items.Bag的用法示例。


在下文中一共展示了Bag.AddItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadyPlayer


//.........这里部分代码省略.........
                                items.Add(armor);
                            else if (armor.ProtectionLevel != ArmorProtectionLevel.Regular)
                                items.Add(armor);
                        }
                    }
                }

                if (m.Backpack != null)
                {
                    foreach (Item item in m.Backpack.Items)
                    {
                        if (item != null)
                        {
                            if (item is BaseWeapon && !MagicWeapons)
                            {
                                BaseWeapon weapon = (BaseWeapon) item;

                                if (weapon.AccuracyLevel != WeaponAccuracyLevel.Regular)
                                    items.Add(weapon);
                                else if (weapon.DamageLevel != WeaponDamageLevel.Regular)
                                    items.Add(weapon);
                                else if (weapon.DurabilityLevel != WeaponDurabilityLevel.Regular)
                                    items.Add(weapon);
                            }
                            else if (item is BaseArmor && !MagicArmor)
                            {
                                BaseArmor armor = (BaseArmor) item;

                                if (armor.Durability != ArmorDurabilityLevel.Regular)
                                    items.Add(armor);
                                else if (armor.ProtectionLevel != ArmorProtectionLevel.Regular)
                                    items.Add(armor);
                            }
                            else if (item is BasePotion && !Potions)
                                items.Add(item);
                            else if (item is EtherealMount && !Mounts)
                                items.Add(item);
                            else if (item is Bandage && !Bandages)
                                items.Add(item);
                        }
                    }
                }

                if (!Mounts)
                {
                    if (m.Mount != null)
                    {
                        IMount mount = m.Mount;
                        mount.Rider = null;
                        if (mount is BaseMount)
                        {
                            if (mount is BaseCreature)
                            {
                                BaseCreature bc = (BaseCreature)mount;
                                bc.ControlTarget = null;
                                bc.ControlOrder = OrderType.Stay;
                                bc.Internalize();

                                bc.SetControlMaster(null);
                                bc.SummonMaster = null;

                                bc.IsStabled = true;
                                m.Stabled.Add(bc);
                                MountCollection.Add(m.Serial, bc);
                                m.SendMessage(38, "Your mount has been moved to the your stables");
                            }
                        }
                    }
                }

                if (items.Count > 0)
                    m.SendMessage(38, "You had items that did not meet the requirements for the deathmatch and were thus moved to your bank.");

                foreach (Item item in items)
                    bag.AddItem(item);

                if (bag.Items.Count > 0)
                    bank.DropItem(bag);
                else
                    bag.Delete();

                #endregion
            }
            
            if (m_EventSupplier != null)
                m_EventSupplier.OnMoveOver(m);

            Contestants.Add(m);

            SpawnMobile(m);

            if ( m_GiveHorses )
                DMHorse.TryGiveHorse(m);

            if (m.NetState != null)
            {
                m.SendMessage(38, "You have joined a deathmatch");
                m.SendMessage(38, "You can check the score with \".DMScore\"");
            }
        }
开发者ID:FreeReign,项目名称:imaginenation,代码行数:101,代码来源:DMStone.cs

示例2: GivePrizes

		public void GivePrizes( Mobile pm )
		{
			bool Won = false;
			int team;
			if( pm.FindItemOnLayer( Layer.Cloak ) != null )
			{
				team = pm.FindItemOnLayer( Layer.Cloak ).Hue;
			}
			else
			{
				pm.SendMessage( "You have no team cloak.  Please ask the GM about this!" );
				return;
			}
			
			if( ( m_Team1 > 0 && m_Team2 == 0 && m_Team3 == 0 && m_Team4 == 0 ) && team == m_Team1Hue )
		{
			Won = true;
			pm.MoveToWorld( Exit1Dest, MapDest );
		}
			if(  (m_Team2 > 0 && m_Team1 == 0 && m_Team3 == 0 && m_Team4 == 0)  && team == m_Team2Hue )
		{
			Won = true;
			pm.MoveToWorld( Exit2Dest, MapDest );
		}
		
			if(  ( m_Team3 > 0 && m_Team2 == 0 && m_Team1 == 0 && m_Team4 == 0) && team == m_Team3Hue )
		{
			Won = true;
			pm.MoveToWorld( Exit3Dest, MapDest );
		}
			if( ( m_Team4 > 0 && m_Team2 == 0 && m_Team3 == 0 && m_Team1 == 0) && team == m_Team4Hue )
		{
			Won = true;	
			pm.MoveToWorld( Exit4Dest, MapDest );
		}
				
			

			if( Won )
			{
				pm.SendMessage( "Your team won!  Here is your prize." );
				if( m_WinnersPrizes == null || m_WinnersPrizes.Count == 0 )
				{
					pm.SendMessage( "The GM did not set an automatic prize.  Please ask them if they are planning on giving one out!" );
					return;
				}
				Bag winnersBag = new Bag();
				Item toGive;
				for( int i = 0; i < m_WinnersPrizes.Count; i++ )
				{
					if( m_WinnersPrizes[i] is BankCheck )
					{
						int bcWorth = ((BankCheck)m_WinnersPrizes[i]).Worth;
						toGive = new BankCheck( bcWorth );
					}
					else
					{
						toGive = (Item)Activator.CreateInstance( m_WinnersPrizes[i].GetType() );
						toGive.Amount = ((Item)m_WinnersPrizes[i]).Amount;
					}
					winnersBag.AddItem( toGive );
				}
				pm.AddToBackpack( winnersBag );
			}
			else
				pm.SendMessage( "Your team did not win this game.  Try again next time!" );
		}
开发者ID:FreeReign,项目名称:imaginenation,代码行数:67,代码来源:PBGameItem.cs


注:本文中的Server.Items.Bag.AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。