public override void Execute(Wife pWife) { int iWorkType = pWife.rand.Next(7); string sWorkType = "the work was not set"; switch (iWorkType) { case 0: sWorkType = "Расстилаю свежее постельное белье"; break; case 1: sWorkType = "Мою пол в гостинной"; break; case 2: sWorkType = "Поливаю цветы"; break; case 3: sWorkType = "Мою пол в коридоре"; break; case 4: sWorkType = "Мою окна"; break; case 5: sWorkType = "Готовлю вкусный обед"; break; case 6: sWorkType = "Стираю вещи"; break; } Console.WriteLine(String.Format("\n{0}: " + sWorkType, EntityManager.Instance().GetNameOfEntity(pWife.ID))); if (pWife.rand.Next(10) == 0) { pWife.ChangeState(GoBath.Instance()); } else { //go to shop for food if (pWife.HasMoney() && pWife.rand.Next(20) == 0) { pWife.ChangeState(VisitFoodShop.Instance()); } //or for cloth, if rich else if (pWife.IsRich() && pWife.rand.Next(30) == 0) { pWife.ChangeState(VisitClothShop.Instance()); } } }
public static State <Wife> Instance() { if (instance == null) { instance = new VisitClothShop(); } return(instance); }