private void Gathering() { if (_foundedBerries == null) { List <IHumanFood> potentialFood = LocateTarget <IHumanFood>(); _foundedBerries = potentialFood.OfType <Berries>().FirstOrDefault(); } else if (!_gotFood) { MoveTo(_foundedBerries.X, _foundedBerries.Y); if (_foundedBerries.X != X || _foundedBerries.X != Y) { return; } _gotFood = true; GlobalMap.Field[X, Y].Entity.Remove(_foundedBerries); GlobalMap.deadEntityList.Add(_foundedBerries); } else { MoveTo(MyHouse.X, MyHouse.Y); if (MyHouse.X != X || MyHouse.Y != Y) { return; } if (!MyHouse.FillStorage()) { EatFromStorage(); MyHouse.FillStorage(); } _foundedBerries = null; _gotFood = false; } }
public override void Live() { if (Satiety <= 0 || Dead) { Dead = true; } else if (GlobalMap.CheckTime()) { CurrentBirthCooldown--; Sleep(); } else if (Satiety <= SatTreshold) { CurrentBirthCooldown--; if (MyHouse != null) { if (MyHouse.CheckStorage()) { EatFromStorage(); } else { FindFood(); Eat(); } } } else if (Gender == GameObjectType.Female && MyHouse != null) { if (!MyHouse.CheckStorage()) { Gathering(); } } else if (FoundPartner == null) { RandomMove(); CurrentBirthCooldown--; if (CurrentBirthCooldown < BirthCooldown) { FindPartner(); } } else if (FoundPartner != null && CurrentBirthCooldown < BirthCooldown) { if (MyHouse == null) { if (Gender == GameObjectType.Male) { LocateBuilding(); } MoveTo(DateX, DateY); } else { MoveTo(MyHouse.X, MyHouse.Y); } CreateFamily(); } else { StayHome(); } }
private void EatFromStorage() { MyHouse.TakeFromStorage(); Satiety++; }