public void popupPanelFood(FarmCow cow) { panelFood.SetActive(true); panelFood.transform.localScale = Vector3.one; iTween.ScaleFrom(panelFood, iTween.Hash("scale", new Vector3(0.5f, 0.1f, 1.0f), "time", 0.3f, "easetype", iTween.EaseType.easeOutBack)); int count = panelFood.transform.childCount; for (int i = 0; i < count; i++) { Transform tr = panelFood.transform.GetChild(i); if (tr.name.IndexOf("food") != -1) { UILabel countLb = tr.Find("count").GetComponent <UILabel>(); if (invetoryDc.ContainsKey(tr.name)) { countLb.text = invetoryDc[tr.name] + ""; tr.GetComponent <BoxCollider>().enabled = true; } else { countLb.text = "0"; tr.GetComponent <BoxCollider>().enabled = false; } } } selectedCow = cow; }
protected override void OnTarget(Mobile from, object targ) { if (targ is FarmCow) { FarmCow c = (FarmCow)targ; if (c.Owner == from || c.Owner == null) { bool CanUse = from.CheckSkill(SkillName.AnimalLore, 20, 50); if (CanUse) { if (c.Milk > 0) { if (t_mb.Quantity < 10) { c.PlaySound(c.GetIdleSound()); from.SendMessage("You milk the cow."); if (t_mb.Quantity < 1) { t_mb.Age = DateTime.UtcNow; } int tofill = 10 - t_mb.Quantity; if (c.Milk > tofill) { t_mb.Quantity = 10; c.Milk -= tofill; if (t_mb.MilkType != TypeOfMilk.Cow && t_mb.MilkType != TypeOfMilk.None) { t_mb.MilkType = TypeOfMilk.Mixed; } else { t_mb.MilkType = TypeOfMilk.Cow; } } else { t_mb.Quantity += c.Milk; c.Milk = 0; if (t_mb.MilkType != TypeOfMilk.Cow && t_mb.MilkType != TypeOfMilk.None) { t_mb.MilkType = TypeOfMilk.Mixed; } else { t_mb.MilkType = TypeOfMilk.Cow; } } t_mb.InvalidateProperties(); t_mb.UpdateName(); } else { from.SendMessage("Your milk bucket is full!"); } } else { from.SendMessage("That animal is out of milk."); } } else { c.PlaySound(c.GetIdleSound()); from.SendMessage("You fail to milk the cow!"); } } else { from.SendMessage("You don't own that animal."); } } else if (targ is FarmSheep) { FarmSheep c = (FarmSheep)targ; if (c.Owner == from || c.Owner == null) { bool CanUse = from.CheckSkill(SkillName.AnimalLore, 20, 50); if (CanUse) { if (c.Milk > 0) { if (t_mb.Quantity < 10) { c.PlaySound(c.GetIdleSound()); from.SendMessage("You milk the sheep."); if (t_mb.Quantity < 1) { t_mb.Age = DateTime.UtcNow; } int tofill = 10 - t_mb.Quantity; if (c.Milk > tofill) { t_mb.Quantity = 10; c.Milk -= tofill; if (t_mb.MilkType != TypeOfMilk.Sheep && t_mb.MilkType != TypeOfMilk.None) { t_mb.MilkType = TypeOfMilk.Mixed; } else { t_mb.MilkType = TypeOfMilk.Sheep; } } else { t_mb.Quantity += c.Milk; c.Milk = 0; if (t_mb.MilkType != TypeOfMilk.Sheep && t_mb.MilkType != TypeOfMilk.None) { t_mb.MilkType = TypeOfMilk.Mixed; } else { t_mb.MilkType = TypeOfMilk.Sheep; } } t_mb.InvalidateProperties(); t_mb.UpdateName(); } else { from.SendMessage("Your milk bucket is full!"); } } else { from.SendMessage("That animal is out of milk."); } } else { c.PlaySound(c.GetIdleSound()); from.SendMessage("You fail to milk the sheep!"); } } else { from.SendMessage("You don't own that animal."); } } else if (targ is FarmGoat) { FarmGoat c = (FarmGoat)targ; if (c.Owner == from || c.Owner == null) { bool CanUse = from.CheckSkill(SkillName.AnimalLore, 20, 50); if (CanUse) { if (c.Milk > 0) { if (t_mb.Quantity < 10) { c.PlaySound(c.GetIdleSound()); from.SendMessage("You milk the goat."); if (t_mb.Quantity < 1) { t_mb.Age = DateTime.UtcNow; } int tofill = 10 - t_mb.Quantity; if (c.Milk > tofill) { t_mb.Quantity = 10; c.Milk -= tofill; if (t_mb.MilkType != TypeOfMilk.Goat && t_mb.MilkType != TypeOfMilk.None) { t_mb.MilkType = TypeOfMilk.Mixed; } else { t_mb.MilkType = TypeOfMilk.Goat; } } else { t_mb.Quantity += c.Milk; c.Milk = 0; if (t_mb.MilkType != TypeOfMilk.Goat && t_mb.MilkType != TypeOfMilk.None) { t_mb.MilkType = TypeOfMilk.Mixed; } else { t_mb.MilkType = TypeOfMilk.Goat; } } t_mb.InvalidateProperties(); t_mb.UpdateName(); } else { from.SendMessage("Your milk bucket is full!"); } } else { from.SendMessage("That animal is out of milk."); } } else { c.PlaySound(c.GetIdleSound()); from.SendMessage("You fail to milk the goat!"); } } else { from.SendMessage("You don't own that animal."); } } else if (targ is Pitcher) { Pitcher bev = (Pitcher)targ; if (bev.Content == BeverageType.Milk || bev.Quantity < 1) { bev.Content = BeverageType.Milk; if (t_mb.Quantity > (bev.MaxQuantity - bev.Quantity)) { t_mb.Quantity -= (bev.MaxQuantity - bev.Quantity); bev.Quantity = bev.MaxQuantity; } else { bev.Quantity += t_mb.Quantity; t_mb.Quantity = 0; } t_mb.InvalidateProperties(); t_mb.UpdateName(); from.PlaySound(0x4E); } else { from.SendMessage("You shouldn't mix beverages."); } } else if (targ is MilkKeg) { MilkKeg bev = (MilkKeg)targ; if (bev.Quantity < 100) { if (bev.MilkType == t_mb.MilkType || bev.Quantity < 1) { bev.MilkType = t_mb.MilkType; if (bev.Quantity < 1) { bev.Age = t_mb.Age; } if (bev.Age > t_mb.Age) { bev.Age = t_mb.Age; } if (t_mb.Quantity > (100 - bev.Quantity)) { t_mb.Quantity -= (100 - bev.Quantity); bev.Quantity = 100; } else { bev.Quantity += t_mb.Quantity; t_mb.Quantity = 0; } t_mb.InvalidateProperties(); t_mb.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_mb.Age; } if (bev.Age > t_mb.Age) { bev.Age = t_mb.Age; } if (t_mb.Quantity > (100 - bev.Quantity)) { t_mb.Quantity -= (100 - bev.Quantity); bev.Quantity = 100; } else { bev.Quantity += t_mb.Quantity; t_mb.Quantity = 0; } t_mb.InvalidateProperties(); t_mb.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_mb.Quantity > 0) { from.AddToBackpack(new Milk()); from.PlaySound(0x240); from.SendMessage("You measure out one cup of milk."); t_mb.Quantity -= 1; t_mb.InvalidateProperties(); t_mb.UpdateName(); } else { from.SendMessage("The bucket is empty!"); } } else { from.SendMessage("You can't do that."); } }