public void DistractedTo(GameObject obj) { ChickenState = ChickenState.Lured; TimeToUpdateNavmeshDestination = NavmeshUpdateRate; _corn = obj.GetComponent <Corn>(); NavMeshAgent.stoppingDistance = .5f; }
public void Chop(Mobile from) { if (from.InRange(this.GetWorldLocation(), 1)) { if (from == m_sower) { from.Direction = from.GetDirectionTo(this); double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100; if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue)) { Corn fruit = new Corn(Utility.Random(m_yield + 2)); from.AddToBackpack(fruit); int cnt = Utility.Random(4) + 1; Log logs = new Log(cnt); from.AddToBackpack(logs); } this.Delete(); from.SendMessage("You chop the plant up"); } else { from.SendMessage("You do not own this plant !!!"); } } else { from.SendLocalizedMessage(500446); } }
public static void ResetToDefaults_Static() { OakTree.ResetToDefaults_Static_OakTree(); Corn.ResetToDefaults_Static_Corn(); Hospital.ResetToDefaults_Static_Hospital(); Dock.ResetToDefaults_Static_Dock(); RecruitingCenter.ResetToDefaults_Static_RecruitingCenter(); QuantumTransmitter.ResetToDefaults_Static_QuantumTransmitter(); Hangar.ResetToDefaults_Static_Hangar(); }
public void TestMethod1() { IncrementingResource corn = new Corn(); corn.Value = 10; corn.Delta = 5; // Proc a tick corn.Tick(); Assert.AreEqual(corn.Value, 15); Assert.AreEqual(corn.Delta, 5); }
public static void PlantUpdate() // можно выделить в потоки { if (existingPlantsMask != 0) { if ((existingPlantsMask & (1 << CROP_CORN_ID)) != 0) { Corn.UpdatePlants(); } if ((existingPlantsMask & (1 << TREE_OAK_ID)) != 0) { OakTree.UpdatePlants(); } } }
public static void Bake() { Pizza pizza = new LargePizza(); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); pizza = new Ham(pizza); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); pizza = new Cheese(pizza); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); pizza = new Corn(pizza); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); pizza = new Cheese(pizza); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); }
public static void UpdatePlants() { float t = GameMaster.LIFEPOWER_TICK; if (corns.Count > 0) { int i = 0; while (i < corns.Count) { Corn c = corns[i]; if (c == null) { corns.RemoveAt(i); continue; } else { float theoreticalGrowth = c.lifepower / c.lifepowerToGrow; if (c.growth < theoreticalGrowth) { c.growth = Mathf.MoveTowards(c.growth, theoreticalGrowth, growSpeed * t); } else { c.lifepower -= decaySpeed * t; if (c.lifepower <= 0) { c.Dry(); } } if (c.growth >= 1 & c.stage < MAX_STAGE) { c.SetStage((byte)(c.stage + 1)); } i++; } } } else { if (((existingPlantsMask >> CROP_CORN_ID) & 1) != 0) { int val = 1; val = val << CROP_CORN_ID; existingPlantsMask -= val; } } }
public override void Parse() { ConInfo = new SimpleCornInfo(); string[] cmds = Corn.Replace("[", "").Replace("]", "").Split(','); if (cmds.Length == 5) { ConInfo.RepeatInterval = ParseCmd <int?>("RepeatInterval", cmds[1]); ConInfo.RepeatCount = ParseCmd <int?>("RepeatCount", cmds[2]); ConInfo.StartTime = ParseCmd <DateTime?>("StartTime", cmds[3]); ConInfo.EndTime = ParseCmd <DateTime?>("EndTime", cmds[4]); } else { throw new Exception("Corn表达式解析失败,corn:" + Corn); } }
static void Main(string[] args) { Sandwich mySandwich = new VeggieSandwich(); Console.WriteLine(mySandwich.GetPrize()); Console.WriteLine(mySandwich.GetDescription()); mySandwich = new Cheese(mySandwich); Console.WriteLine(mySandwich.GetPrize()); Console.WriteLine(mySandwich.GetDescription()); mySandwich = new Corn(mySandwich); Console.WriteLine(mySandwich.GetPrize()); Console.WriteLine(mySandwich.GetDescription()); mySandwich = new Olives(mySandwich); Console.WriteLine(mySandwich.GetPrize()); Console.WriteLine(mySandwich.GetDescription()); }
IEnumerator CrtEatCorn() { while (_corn.Health > 0 || _corn != null) { _corn.Health -= EatSubstraction; yield return(new WaitForSecondsRealtime(EatingSpeed)); } _corn = null; IsEatingCorn = false; IsPecking = false; NavMeshAgent.GoToShortestWaypointLocation(Waypoints, ref CurrentWaypointIndex); ChickenState = ChickenState.Moving; Animator.SetFloat("speed", 1); Animator.SetBool("pecking", false); NavMeshAgent.stoppingDistance = 0; //avmeshUpdateRate = .1f; }
public void WellnessDiscountOrganicOnly() { //Arrange Ingredient organic = new Garlic(null, DEFAULT_UNIT_SIZE); Ingredient inOrganic = new Corn(null, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(organic.IsOrganic == true); Assert.IsFalse(inOrganic.IsOrganic == true); //Act double organicDiscount = organic.getWellnessDiscount(); double inOrganicDiscount = inOrganic.getWellnessDiscount(); //Assert Assert.IsTrue(organicDiscount != 0); Assert.IsTrue(inOrganicDiscount == 0); }
public Item Harvest() { Item harvest = null; if (CropType == "turnip") { if (Maturity == "b") { harvest = new Turnip(Content, new Vector2(X, Y)); } } else if (CropType == "potato") { if (Maturity == "b") { harvest = new Potato(Content, new Vector2(X, Y)); } } else if (CropType == "tomato") { if (Maturity == "d") { harvest = new Tomato(Content, new Vector2(X, Y)); } } else if (CropType == "corn") { if (Maturity == "d") { harvest = new Corn(Content, new Vector2(X, Y)); } } else if (CropType == "grass") { harvest = null; } if (harvest != null) { harvest.Update(HarvestMoon.Instance.GameTime); } return(harvest); }
public void SubtractServingCannotMakeSizeNegative() { //Arrange Ingredient aboveZero = new Lemon(null, DEFAULT_UNIT_SIZE); Ingredient atZero = new Garlic(null, DEFAULT_UNIT_SIZE); Ingredient belowZero = new Corn(null, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(aboveZero.Units == DEFAULT_UNIT_SIZE); Assert.IsTrue(atZero.Units == DEFAULT_UNIT_SIZE); Assert.IsTrue(belowZero.Units == DEFAULT_UNIT_SIZE); //Act aboveZero.subtractServing(DEFAULT_UNIT_SIZE - 0.1); atZero.subtractServing(DEFAULT_UNIT_SIZE); belowZero.subtractServing(DEFAULT_UNIT_SIZE + 0.1); //Assert Assert.IsTrue(aboveZero.Units > 0.0); Assert.IsTrue(atZero.Units == 0.0); Assert.IsTrue(belowZero.Units >= 0.0); }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from != m_sower) { from.SendMessage("You do not own this plant !!!"); return; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage("You cannot harvest a crop while mounted."); return; } if (DateTime.UtcNow > lastpicked.AddSeconds(3)) { lastpicked = DateTime.UtcNow; int cookValue = (int)from.Skills[SkillName.Cooking].Value / 20; if (cookValue == 0) { from.SendMessage("You have no idea how to harvest this crop."); return; } if (from.InRange(this.GetWorldLocation(), 1)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); } else { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0); m_lastvisit = DateTime.UtcNow; if (cookValue > m_yield) { cookValue = m_yield + 1; } int pick = Utility.RandomMinMax(cookValue - 4, cookValue); if (pick < 0) { pick = 0; } if (pick == 0) { from.SendMessage("You do not manage to harvest any crops."); return; } m_yield -= pick; from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s")); if (m_yield < 1) { ((Item)this).ItemID = pickedGraphic; } Corn crop = new Corn(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to harvest anything."); } } }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage("You cannot harvest a crop while mounted."); return; } if (DateTime.Now > lastpicked.AddSeconds(3)) // 3 seconds between picking { lastpicked = DateTime.Now; int cookValue = (int)from.Skills[SkillName.Cooking].Value / 20; if (cookValue == 0) { from.SendMessage("You have no idea how to harvest this crop."); return; } if (from.InRange(this.GetWorldLocation(), 1)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); if (PlayerCanDestroy && !(m_sower.AccessLevel > AccessLevel.Counselor)) { UpRootGump g = new UpRootGump(from, this); from.SendGump(g); } } else //check skill and sower { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0); if (from == m_sower) { cookValue *= 2; m_lastvisit = DateTime.Now; } if (cookValue > m_yield) { cookValue = m_yield + 1; } int pick = Utility.Random(cookValue); if (pick == 0) { from.SendMessage("You do not manage to harvest any crops."); return; } // *** Limit to one yield until we have Corn item *** if (pick > 1) { pick = 1; } m_yield -= pick; from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s")); //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); ((Item)this).ItemID = pickedGraphic; Corn crop = new Corn(pick); from.AddToBackpack(crop); if (SowerPickTime != TimeSpan.Zero && m_lastvisit + SowerPickTime < DateTime.Now && !(m_sower.AccessLevel > AccessLevel.Counselor)) { this.UpRoot(from); return; } if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to harvest anything."); } } }
public void TestTeardown() { corn = null; }
public void TestSetup() { corn = new Corn(0); }
public PlayerResources() { Corn = new Corn(); Wheat = new Wheat(); }
public void Tick() { Corn.Tick(); Wheat.Tick(); }