コード例 #1
0
        /// <summary>
        /// Checks if there are currently any available SafeHouse tiles.
        /// </summary>
        /// <returns>True if there are 1 or more tiles available.</returns>
        private Boolean CheckForValidSafeHouseTiles()
        {
            // Grab a list of all the SafeHouse objects, so that we can pick one at
            // random to walk to.
            List <GameObject> safeHouses = GameObjectManager.pInstance.GetGameObjectsOfClassification(GameObjectDefinition.Classifications.SAFE_HOUSE);

            // We want to avoid standing on a tile that is already occupied by another Stranded.
            // To do that, we just loop through the list of safeHouses and remove any that are
            // already occupied.
            for (Int32 i = safeHouses.Count - 1; i >= 0; i--)
            {
                // Get the tile at the position of this SafeHouse.
                mGetTileAtObjectMsg.Reset();
                mGetTileAtObjectMsg.mObject_In = safeHouses[i];
                WorldManager.pInstance.pCurrentLevel.OnMessage(mGetTileAtObjectMsg);

                // If there is no Tile, there we should not be trying to go here at all.
                if (null == mGetTileAtObjectMsg.mTile_Out)
                {
                    continue;
                }

                // If the tile is occupied we should not try to go there.
                if (!mGetTileAtObjectMsg.mTile_Out.HasAttribute(Level.Tile.Attribute.Occupied))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Called once when the state starts.
        /// </summary>
        public override void OnBegin()
        {
            // Start the StatBoostResearch since we are now researching.
            pParentGOH.SetBehaviourEnabled <StatBoostResearch>(true);

            // The stat boost needs to be given to the player.
            mSetTargetMsg.mTarget_In = GameObjectManager.pInstance.pPlayer;
            pParentGOH.OnMessage(mSetTargetMsg);

            // Grab the tile at that location and update its Attributes to now be
            // Occupied.
            mGetTileAtObjectMsg.Reset();
            mGetTileAtObjectMsg.mObject_In = pParentGOH;
            WorldManager.pInstance.pCurrentLevel.OnMessage(mGetTileAtObjectMsg);

            if (null != mGetTileAtObjectMsg.mTile_Out)
            {
                mGetTileAtObjectMsg.mTile_Out.SetAttribute(Level.Tile.Attribute.Occupied);
            }
        }
コード例 #3
0
        /// <summary>
        /// Called once when the state starts.
        /// </summary>
        public override void OnBegin()
        {
            mSetActiveAnimationMsg.mAnimationSetName_In = "Idle";
            pParentGOH.OnMessage(mSetActiveAnimationMsg);

            // Grab the tile at that location and update its Attributes to now be
            // Occupied.
            mGetTileAtObjectMsg.Reset();
            mGetTileAtObjectMsg.mObject_In = pParentGOH;
            WorldManager.pInstance.pCurrentLevel.OnMessage(mGetTileAtObjectMsg);

            if (null != mGetTileAtObjectMsg.mTile_Out)
            {
                mGetTileAtObjectMsg.mTile_Out.SetAttribute(Level.Tile.Attribute.Occupied);
            }

            mButtonHint = null;
            mPopup      = null;

            pParentGOH.SetBehaviourEnabled <HealNearby>(true);
        }
コード例 #4
0
        /// <summary>
        /// Called once when the state starts.
        /// </summary>
        public override void OnBegin()
        {
            // Grab a list of all the SafeHouse objects, so that we can pick one at
            // random to walk to.
            List <GameObject> safeHouses = GameObjectManager.pInstance.GetGameObjectsOfClassification(GameObjectDefinition.Classifications.SAFE_HOUSE);

            mValidSafeHouses.Clear();

            // We want to avoid standing on a tile that is already occupied by another Stranded.
            // To do that, we just loop through the list of safeHouses and remove any that are
            // already occupied.
            for (Int32 i = safeHouses.Count - 1; i >= 0; i--)
            {
                // Get the tile at the position of this SafeHouse.
                mGetTileAtObjectMsg.Reset();
                mGetTileAtObjectMsg.mObject_In = safeHouses[i];
                WorldManager.pInstance.pCurrentLevel.OnMessage(mGetTileAtObjectMsg);

                // If there is no Tile, there we should not be trying to go here at all.
                if (null == mGetTileAtObjectMsg.mTile_Out)
                {
                    continue;
                }

                // If the tile is occupied we should not try to go there.
                if (mGetTileAtObjectMsg.mTile_Out.HasAttribute(Level.Tile.Attribute.Occupied))
                {
                    continue;
                }

                mValidSafeHouses.Add(safeHouses[i]);
            }

            // There is a chance that all safeHouse tiles are occupied.
            if (mValidSafeHouses.Count <= 0)
            {
                /// <todo>
                /// Go to a new state; maybe one where the dude just wanders a bit.
                /// </todo>
                ///

                // There are no spaces left in the SafeHouse so don't try to find a spot.
                mSetStateMsg.mNextState_In = "Follow";
                pParentGOH.OnMessage(mSetStateMsg);

                // This is used OnEnd()
                mGetTileAtObjectMsg.Reset();

                // The score will have been incremented before entering this state, but it
                // should not have because in reality there is no space left. Reverse that
                // change.
                pParentGOH.OnMessage(mGetSafeHouseScoreMessage);
                mIncrementScoreMsg.mAmount_In = -mGetSafeHouseScoreMessage.mSafeHouseScore_Out;
                pParentGOH.OnMessage(mIncrementScoreMsg);

                return;
            }

            // Show the player walking towards his destination.
            mSetActiveAnimationMsg.mAnimationSetName_In = "Run";
            pParentGOH.OnMessage(mSetActiveAnimationMsg);

            // Use the collision center point since the position root is at the
            // bottom of the image and can result in off by 1 errors when finding
            // which tile this guy is standing in.
            mSetSourceMsg.mSource_In = pParentGOH.pCollisionRect.pCenterPoint;
            pParentGOH.OnMessage(mSetSourceMsg);

            // Pick a random safeHouse location to move to.
            Int32 index = RandomManager.pInstance.RandomNumber() % mValidSafeHouses.Count;

            mSetDestinationMsg.mDestination_In = mValidSafeHouses[index].pPosition;
            pParentGOH.OnMessage(mSetDestinationMsg);

            // Grab the tile at that location and update its Attributes to now be
            // Occupied.
            mGetTileAtObjectMsg.Reset();
            mGetTileAtObjectMsg.mObject_In = mValidSafeHouses[index];
            WorldManager.pInstance.pCurrentLevel.OnMessage(mGetTileAtObjectMsg);

            if (null != mGetTileAtObjectMsg.mTile_Out)
            {
                mGetTileAtObjectMsg.mTile_Out.SetAttribute(Level.Tile.Attribute.Occupied);
            }

            // The PathFollow style should not dynamically update the destination.
            mSetTargetObjectMsg.mTarget_In = null;
            pParentGOH.OnMessage(mSetTargetObjectMsg);

            // With the destination and source set on the PathFind Behaviour, turning on the PathFollow
            // Behaviour will cause him to walk to the destination.
            pParentGOH.SetBehaviourEnabled <PathFollow>(true);
        }