Inheritance: Item, IHasQuantity
コード例 #1
0
        private void FinishWorking_Callback(object state)
        {
            if (m_Timer != null)
            {
                m_Timer.Stop();
                m_Timer = null;
            }

            Mobile from = state as Mobile;

            if (from != null && !from.Deleted && !this.Deleted && IsFull)
            {
                SackFlour flour = new SackFlour();

                flour.ItemID = (Utility.RandomBool() ? 4153 : 4165);

                if (from.PlaceInBackpack(flour))
                {
                    m_Flour = 0;
                }
                else
                {
                    flour.Delete();
                    from.SendLocalizedMessage(500998);                       // There is not enough room in your backpack!  You stop grinding.
                }
            }

            UpdateStage();
        }
コード例 #2
0
		private void FinishWorking_Callback( object state )
		{
			if ( m_Timer != null )
			{
				m_Timer.Stop();
				m_Timer = null;
			}

			Mobile from = state as Mobile;

			if ( from != null && !from.Deleted && !this.Deleted && IsFull )
			{
				SackFlour flour = new SackFlour();

				flour.ItemID = ( Utility.RandomBool() ? 4153 : 4165 );

				if ( from.PlaceInBackpack( flour ) )
				{
					m_Flour = 0;
				}
				else
				{
					flour.Delete();
					from.SendLocalizedMessage( 500998 ); // There is not enough room in your backpack!  You stop grinding.
				}
			}

			UpdateStage();
		}
コード例 #3
0
        public bool TryAdd(Item item)
        {
            foreach (Type[] cat in m_AllTypes)
            {
                foreach (Type type in cat)
                {
                    if (item.GetType() == type)
                    {
                        if (m_Resources.ContainsKey(type) && (int)m_Resources[type] + item.Amount >= 100000)
                        {
                            this.PublicOverheadMessage(MessageType.Whisper, 0, false, "I cannot hold more of that resource!");
                            return(false);
                        }
                        if (type == typeof(SackFlour))
                        {
                            SackFlour sack = (SackFlour)item;
                            if (sack.Quantity != 20)
                            {
                                this.PublicOverheadMessage(MessageType.Whisper, 0, false, "The sack has to be full!");
                                return(false);
                            }
                        }

                        AddResource(type, item.Amount);
                        this.PublicOverheadMessage(MessageType.Whisper, 0, false, "Resource Added.");
                        item.Delete();
                        return(true);
                    }
                }
            }
            this.PublicOverheadMessage(MessageType.Whisper, 0, false, "I don't hold that resource!");
            return(false);
        }
コード例 #4
0
        public void Refill()
        {
            int currentcount = this.Items.Count;
            int toAdd        = Utility.RandomMinMax(10, 100);

            while (currentcount < toAdd)
            {
                SackFlour newSack = Activator.CreateInstance(typeof(SackFlour)) as SackFlour;
                DropItem(newSack);
                currentcount++;
            }
        }
コード例 #5
0
ファイル: Beverage.cs プロジェクト: proxeeus/UORebirth
        public virtual void Pour_OnTarget(Mobile from, object targ)
        {
            if (IsEmpty || !Pourable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (!bev.ValidateUse(from, true))
                {
                    return;
                }

                if (bev.IsFull && bev.Content == this.Content)
                {
                    from.SendLocalizedMessage(500848);                       // Couldn't pour it there.  It was already full.
                }
                else if (!bev.IsEmpty)
                {
                    from.SendLocalizedMessage(500846);                       // Can't pour it there.
                }
                else
                {
                    bev.Content  = this.Content;
                    bev.Poison   = this.Poison;
                    bev.Poisoner = this.Poisoner;

                    if (this.Quantity > bev.MaxQuantity)
                    {
                        bev.Quantity   = bev.MaxQuantity;
                        this.Quantity -= bev.MaxQuantity;
                    }
                    else
                    {
                        bev.Quantity += this.Quantity;
                        this.Quantity = 0;
                    }

                    from.PlaySound(0x4E);
                }
            }
            else if (from == targ)
            {
                if (from.Thirst < 20)
                {
                    from.Thirst += 1;
                }

                if (ContainsAlchohol)
                {
                    int heaves = 0;

                    switch (this.Content)
                    {
                    case BeverageType.Ale: heaves = 3; break;

                    case BeverageType.Wine: heaves = 5; break;

                    case BeverageType.Cider: heaves = 5; break;

                    case BeverageType.Liquor: heaves = 10; break;

                    default:                                heaves = 5; break;
                    }

                    from.BAC += heaves;

                    if (from.BAC > 60)
                    {
                        from.BAC = 60;
                    }

                    CheckHeaveTimer(from);
                }

                from.PlaySound(Utility.RandomList(0x30, 0x2D6));

                if (m_Poison != null)
                {
                    from.ApplyPoison(m_Poisoner, m_Poison);
                }

                --Quantity;
            }
            else if (targ is SackFlour)
            {
                SackFlour flour = (SackFlour)targ;
                --Quantity;
                flour.Quantity--;
                if (flour.Deleted)
                {
                    from.SendAsciiMessage("No flour left.");
                }
                from.SendAsciiMessage("You make some dough and put it in your backpack");
                from.AddToBackpack(new Dough());
            }
            else
            {
                from.SendLocalizedMessage(500846);                   // Can't pour it there.
            }
        }