コード例 #1
0
        public override bool OnMessage(BaseGameEntity pEntity, Telegram pTelegram)
        {
            MinersWife wife = (MinersWife)pEntity;

            switch (pTelegram.Msg)
            {
            case (int)message_type.Msg_StewReady:
            {
                DebugMessages.Instance.WriteLine(String.Format("Message received by {0} at time {1}", MainSM.GetEntityName(pEntity.ID()), MessageDispatcher.Instance.GetRunningTime()));
                DebugMessages.Instance.WriteLine(String.Format("{0}: StewReady! Lets eat", MainSM.GetEntityName(pEntity.ID())));

                //let hubby know the stew is ready
                MessageDispatcher.Instance.DispatchMessage((int)MessageDispatcher.SEND_MSG_IMMEDIATELY,
                                                           wife.ID(),
                                                           (int)EntityName.ent_Miner_Bob,
                                                           (int)message_type.Msg_StewReady,
                                                           (int)MessageDispatcher.NO_ADDITIONAL_INFO);

                wife.Cooking = false;
                wife.GetFSM().ChangeState(new DoHouseWork());

                return(true);
            }
            }//end switch

            return(false);
        }
コード例 #2
0
        public override void Enter(BaseGameEntity pEntity)
        {
            MinersWife wife = (MinersWife)pEntity;

            //if not already cooking put the stew in the oven
            if (!wife.Cooking)
            {
                DebugMessages.Instance.WriteLine(String.Format("{0}: Putting the stew in the oven", MainSM.GetEntityName(pEntity.ID())));

                //send a delayed message myself so that I know when to take the stew
                //out of the oven
                MessageDispatcher.Instance.DispatchMessage(1.5,                               //time delay
                                                           wife.ID(),                         //sender ID
                                                           wife.ID(),                         //receiver ID
                                                           (int)message_type.Msg_StewReady,   //msg
                                                           (int)MessageDispatcher.NO_ADDITIONAL_INFO);

                wife.Cooking = true;
            }
        }
コード例 #3
0
        public override bool OnMessage(BaseGameEntity pEntity, Telegram pTelegram)
        {
            MinersWife wife = (MinersWife)pEntity;

            switch (pTelegram.Msg)
            {
            case (int)message_type.Msg_HiHoneyImHome:
            {
                double CurrentTime = MessageDispatcher.Instance.GetRunningTime();

                DebugMessages.Instance.WriteLine(String.Format("Message handled by {0} at time: {1}", MainSM.GetEntityName(wife.ID()), CurrentTime));

                DebugMessages.Instance.WriteLine(String.Format("{0}: Hi honey. Let me make you some of mah fine country stew", MainSM.GetEntityName(wife.ID())));

                wife.GetFSM().ChangeState(new CookStew());

                return(true);
            }
            }

            return(false);
        }