Esempio n. 1
0
        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());
                }
            }
        }
Esempio n. 2
0
        public static State <Wife> Instance()
        {
            if (instance == null)
            {
                instance = new GoBath();
            }

            return(instance);
        }
Esempio n. 3
0
        public Wife(int id, string name, Random Rand, Miner miner) : base(id, name)
        {
            rand      = Rand;
            w_husband = miner;

            w_iRich        = 4 + rand.Next(6);
            w_Location     = wife_location_type.bath;
            w_StateMachine = new StateMachine <Wife>(this);
            w_StateMachine.SetCurrentState(GoBath.Instance());
            w_StateMachine.SetGlobalState(WifesGlobalState.Instance());
        }