/// <summary> /// Constructor. /// </summary> public FSMStateWaitAtStandingPosition(String popupScript) { mPopupScript = popupScript; mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage(); mGetTileAtObjectMsg = new Level.GetTileAtObjectMessage(); mGetAttachmentPointMsg = new SpriteRender.GetAttachmentPointMessage(); mOnPopupCloseMsg = new StrandedPopup.OnPopupClosedMessage(); mSetStateMsg = new FiniteStateMachine.SetStateMessage(); }
/// <summary> /// The main interface for communicating between behaviours. Using polymorphism, we /// define a bunch of different messages deriving from BehaviourMessage. Each behaviour /// can then check for particular upcasted messahe types, and either grab some data /// from it (set message) or store some data in it (get message). /// </summary> /// <param name="msg">The message being communicated to the behaviour.</param> public override void OnMessage(ref BehaviourMessage msg) { base.OnMessage(ref msg); if (msg is StrandedPopup.OnPopupClosedMessage) { // This message is broadcast to all GameObjects, so make sure it is actually a popup we // opened before reacting to it. if (msg.pSender == mPopup) { StrandedPopup.OnPopupClosedMessage temp = (StrandedPopup.OnPopupClosedMessage)msg; if (temp.mSelection_In == StrandedPopupDefinition.ButtonTypes.GunUp) { mSetStateMsg.mNextState_In = "ResearchStatBoost"; pParentGOH.OnMessage(mSetStateMsg); } else if (temp.mSelection_In == StrandedPopupDefinition.ButtonTypes.HpUp) { mSetStateMsg.mNextState_In = "ResearchStatBoost"; pParentGOH.OnMessage(mSetStateMsg); } else if (temp.mSelection_In == StrandedPopupDefinition.ButtonTypes.MilitantPatrol) { DebugMessageDisplay.pInstance.AddConstantMessage("Patrol"); mSetStateMsg.mNextState_In = "Patrol"; pParentGOH.OnMessage(mSetStateMsg); } else if (temp.mSelection_In == StrandedPopupDefinition.ButtonTypes.MilitantFollow) { DebugMessageDisplay.pInstance.AddConstantMessage("Follow"); mSetStateMsg.mNextState_In = "Follow"; pParentGOH.OnMessage(mSetStateMsg); } else if (temp.mSelection_In == StrandedPopupDefinition.ButtonTypes.MakeScout) { // Spawn some smoke to be more ninja like. GameObject go = GameObjectFactory.pInstance.GetTemplate("GameObjects\\Effects\\Dust\\Dust"); // Grab that attachment point and position the new object there. mGetAttachmentPointMsg.mName_In = "Smoke"; pParentGOH.OnMessage(mGetAttachmentPointMsg); // Put the smoke at the right position relative to the Civilian. go.pPosition = mGetAttachmentPointMsg.mPoisitionInWorld_Out; // The Smoke gets pushed onto the GameObjectManager and will delete itself when // it finishes the animation. GameObjectManager.pInstance.Add(go); // Spawn the Scout to replace this Civilian. go = GameObjectFactory.pInstance.GetTemplate("GameObjects\\Characters\\Scout\\Scout"); go.pPosition = pParentGOH.pPosition; GameObjectManager.pInstance.Add(go); GameObjectManager.pInstance.Remove(pParentGOH); } else if (temp.mSelection_In == StrandedPopupDefinition.ButtonTypes.ScoutSearch) { mSetStateMsg.mNextState_In = "BeginSearch"; pParentGOH.OnMessage(mSetStateMsg); } else if (temp.mSelection_In == StrandedPopupDefinition.ButtonTypes.EngineerRepair) { DebugMessageDisplay.pInstance.AddConstantMessage("Repair"); mSetStateMsg.mNextState_In = "Repair"; pParentGOH.OnMessage(mSetStateMsg); } // Popups get recycled so if ours closes, we need to make sure to clear our local // reference, else the next object to use it might send messages that we react to. mPopup = null; } } }