コード例 #1
0
 protected override void OnTarget(Mobile from, object targ)
 {
     if (targ is BaseBeverage)
     {
         BaseBeverage bev = (BaseBeverage)targ;
         if (bev.Content == BeverageType.Milk || bev.Quantity < 1)
         {
             bev.Content = BeverageType.Milk;
             if (t_mk.Quantity > bev.Quantity)
             {
                 t_mk.Quantity -= (bev.MaxQuantity - bev.Quantity);
                 bev.Quantity   = bev.MaxQuantity;
             }
             else
             {
                 bev.Quantity += t_mk.Quantity;
                 t_mk.Quantity = 0;
             }
             t_mk.InvalidateProperties();
             t_mk.UpdateName();
             from.PlaySound(0x4E);
         }
         else
         {
             from.SendMessage("You shouldn't mix beverages.");
         }
     }
     else if (targ is MilkingBucket)
     {
         MilkingBucket bev = (MilkingBucket)targ;
         if (bev.Quantity < 10)
         {
             if (bev.MilkType == t_mk.MilkType || bev.Quantity < 1)
             {
                 bev.MilkType = t_mk.MilkType;
                 if (bev.Quantity < 1)
                 {
                     bev.Age = t_mk.Age;
                 }
                 if (bev.Age > t_mk.Age)
                 {
                     bev.Age = t_mk.Age;
                 }
                 if (t_mk.Quantity > (10 - bev.Quantity))
                 {
                     t_mk.Quantity -= (10 - bev.Quantity);
                     bev.Quantity   = 10;
                 }
                 else
                 {
                     bev.Quantity += t_mk.Quantity;
                     t_mk.Quantity = 0;
                 }
                 t_mk.InvalidateProperties();
                 t_mk.UpdateName();
                 bev.InvalidateProperties();
                 bev.UpdateName();
                 from.PlaySound(0x4E);
                 from.SendMessage("You pour the milk into the keg.");
             }
             else
             {
                 bev.MilkType = TypeOfMilk.Mixed;
                 if (bev.Quantity < 1)
                 {
                     bev.Age = t_mk.Age;
                 }
                 if (bev.Age > t_mk.Age)
                 {
                     bev.Age = t_mk.Age;
                 }
                 if (t_mk.Quantity > (100 - bev.Quantity))
                 {
                     t_mk.Quantity -= (100 - bev.Quantity);
                     bev.Quantity   = 100;
                 }
                 else
                 {
                     bev.Quantity += t_mk.Quantity;
                     t_mk.Quantity = 0;
                 }
                 t_mk.InvalidateProperties();
                 t_mk.UpdateName();
                 bev.InvalidateProperties();
                 bev.UpdateName();
                 from.PlaySound(0x4E);
                 from.SendMessage("You pour the milk into the keg.");
             }
         }
         else
         {
             from.SendMessage("That is full!");
         }
     }
     else if (targ is MilkKeg)
     {
         MilkKeg bev = (MilkKeg)targ;
         if (bev.Quantity < 100)
         {
             if (bev.MilkType == t_mk.MilkType || bev.Quantity < 1)
             {
                 bev.MilkType = t_mk.MilkType;
                 if (bev.Quantity < 1)
                 {
                     bev.Age = t_mk.Age;
                 }
                 if (bev.Age > t_mk.Age)
                 {
                     bev.Age = t_mk.Age;
                 }
                 if (t_mk.Quantity > (100 - bev.Quantity))
                 {
                     t_mk.Quantity -= (100 - bev.Quantity);
                     bev.Quantity   = 100;
                 }
                 else
                 {
                     bev.Quantity += t_mk.Quantity;
                     t_mk.Quantity = 0;
                 }
                 t_mk.InvalidateProperties();
                 t_mk.UpdateName();
                 bev.InvalidateProperties();
                 bev.UpdateName();
                 from.PlaySound(0x4E);
                 from.SendMessage("You pour the milk into the keg.");
             }
             else
             {
                 bev.MilkType = TypeOfMilk.Mixed;
                 if (bev.Quantity < 1)
                 {
                     bev.Age = t_mk.Age;
                 }
                 if (bev.Age > t_mk.Age)
                 {
                     bev.Age = t_mk.Age;
                 }
                 if (t_mk.Quantity > (100 - bev.Quantity))
                 {
                     t_mk.Quantity -= (100 - bev.Quantity);
                     bev.Quantity   = 100;
                 }
                 else
                 {
                     bev.Quantity += t_mk.Quantity;
                     t_mk.Quantity = 0;
                 }
                 t_mk.InvalidateProperties();
                 t_mk.UpdateName();
                 bev.InvalidateProperties();
                 bev.UpdateName();
                 from.PlaySound(0x4E);
                 from.SendMessage("You pour the milk into the keg.");
             }
         }
         else
         {
             from.SendMessage("That is full!");
         }
     }
     else if (targ is MeasuringCup)
     {
         if (t_mk.Quantity > 0)
         {
             from.AddToBackpack(new Milk());
             from.PlaySound(0x240);
             from.SendMessage("You measure out one cup of milk.");
             t_mk.Quantity -= 1;
             t_mk.InvalidateProperties();
             t_mk.UpdateName();
         }
         else
         {
             from.SendMessage("The keg is empty!");
         }
     }
     else
     {
         from.SendMessage("You can't do that.");
     }
 }
コード例 #2
0
 public MilkingTarget(MilkingBucket mb) : base(1, false, TargetFlags.None)
 {
     t_mb = mb;
 }