/// <summary> /// Mows the lawn. This action will take some time. /// </summary> /// <param name="beeWorldManager"></param> /// <param name="lawnMower"></param> /// <param name="callback"></param> public void MowLawn(BeeWorldManager beeWorldManager, LawnMower lawnMower, Action callback) { System.Diagnostics.Debug.Assert(!this.IsMowingLawn); this.mBeeWorldManager.RealTimePerTick = TimeSpan.FromMilliseconds(300); this.mBeeWorldManager.BeeMinutesPerTick *= 2; this.mLawnMower = lawnMower; this.mLawnMowingCompleteCallback = callback; this.IsMowingLawn = true; }
public void UpdateTick(BeeWorldManager worldManager) { if (this.mBeeYard.IsUnlocked) { var lElapsedMinutes = worldManager.ElapsedTime.TotalMinutes; if (this.IsMowingLawn) { this.mBeeYard.GrassGrowth = Math.Max(sMinGrassGrowth, this.mBeeYard.GrassGrowth - (lElapsedMinutes * this.mLawnMower.SpeedFactor)); if (this.mBeeYard.GrassGrowth == sMinGrassGrowth) { this.IsMowingLawn = false; this.mLawnMower = null; this.mLawnMowingCompleteCallback(); this.mLawnMowingCompleteCallback = null; this.mBeeWorldManager.ResetTimeRates(); } } else { this.mBeeYard.GrassGrowth = Math.Min(sMaxGrassGrowth, this.mBeeYard.GrassGrowth + (lElapsedMinutes * this.mBeeYard.RegrowthFactor)); } } foreach (var lUpdatable in this.mUpdatables) { lUpdatable.UpdateTick(worldManager); } }