public override void Execute(Miner pMiner) { //digging gold until miner is carrying MaxNuggets number of nuggets //although if he gets thirsty during his digging, he stops work and //changes states to go to saloon for a whiskey pMiner.AddToGoldCarried(1); //diggin' is hard work pMiner.IncreaseFatigue(); pMiner.IncreaseHunger(); Console.WriteLine(String.Format("\n{0}: Заработал монетку", EntityManager.Instance().GetNameOfEntity(pMiner.ID))); //if enough gold mined, go and put it in the bank if (pMiner.PocketsFull()) { pMiner.ChangeState(VisitBankAndDepositeGold.Instance()); } //if thirsty go and get whiskey else if (pMiner.Thirsty()) { pMiner.ChangeState(QuenchThirst.Instance()); } //if hungry go and eat in Mac else if (pMiner.Hungry()) { pMiner.ChangeState(Mac_MakeOrder.Instance()); } }
public static State <Miner> Instance() { if (instance == null) { instance = new VisitBankAndDepositeGold(); } return(instance); }