Пример #1
0
        public override void Execute(Miner pMiner)
        {
            pMiner.IncreaseFatigue();
            pMiner.IncreaseHunger();

            if (pMiner.GoldInPockets > 0)
            {
                pMiner.DepositIntoTheBank(pMiner.GoldInPockets);
                Console.WriteLine(String.Format("\n{0}: Я положил {1} золота в банк. Теперь у меня всего в банке {2} золота",
                                                EntityManager.Instance().GetNameOfEntity(pMiner.ID), pMiner.GoldInPockets,
                                                pMiner.GoldInBank));
                pMiner.EmptyPockets();

                if (pMiner.Wealthy())
                {
                    pMiner.ChangeState(GoHomeAndSleepTilRested.Instance());
                    //pMiner.GetFSM().SetGlobalState(GoHomeAndSleepTilRested.Instance());
                }
                else
                {
                    pMiner.ChangeState(EnterMineAndDigForNugget.Instance());
                }
            }
            else
            {
                Console.WriteLine(String.Format("\n{0}: У меня нет золота с собой. Зачем я пришел в банк?",
                                                EntityManager.Instance().GetNameOfEntity(pMiner.ID)));
                pMiner.ChangeState(EnterMineAndDigForNugget.Instance());
            }
        }
Пример #2
0
        public static State <Miner> Instance()
        {
            if (instance == null)
            {
                instance = new GoHomeAndSleepTilRested();
            }

            return(instance);
        }
Пример #3
0
        private void SetBaseValues()
        {
            if (rand == null)
            {
                rand = new Random();
            }

            m_iGoldCarried = 0;
            m_iMoneyInBank = 0;
            m_iThirst      = 0;
            m_iHunger      = 0;
            m_iFatigue     = 0;
            m_Location     = location_type.home;

            m_iGoldCarriedMax = 2 + rand.Next(4);
            m_iGoldMax        = 4 + rand.Next(10);
            m_iThirstMax      = 7 + rand.Next(5);
            m_iHungerMax      = 9 + rand.Next(4);

            //setting up state machine
            m_pStateMachine = new StateMachine <Miner>(this);

            m_pStateMachine.SetCurrentState(GoHomeAndSleepTilRested.Instance());
        }
Пример #4
0
        public bool HusbandIsNotSleeping()
        {
            bool answ = (w_husband.CurrentState.GetType() != GoHomeAndSleepTilRested.Instance().GetType());

            return(answ);
        }