예제 #1
0
    /// <summary>
    /// Public so it can be used by other behaviours if needed (NOTHING ELSE!)
    /// </summary>
    public void UpdateFleeMovement(Ghost pGhost)
    {
        CharacterProceduralVariablesModule pVariablesModule = pGhost.m_pProceduralVariablesModule;

        if (pVariablesModule.GetVariableAsBool(c_sVariableName_bReceivedBehaviourWhileInPrison))
        {
            GetOutOfPrison(pGhost);
            return;
        }

        Tile pCurrentTile = MapManager.Instance.GetTileFromPosition(pGhost.transform.position);

        UpdateSavedTiles(pGhost, pCurrentTile);

        Tile pTileWeJustLeft = (Tile)(pVariablesModule.GetVariable(c_sVariableName_pTileWeJustLeft));

        Tile pTileFurtherFromPlayer = MapManager.Instance.GetAdjacentTileFurtherFromPosition(PlayerCharacter.Instance.transform.position, pCurrentTile, pTileWeJustLeft);

        if (pTileFurtherFromPlayer != null)
        {
            pGhost.m_pNavMeshAgent.SetDestination(pTileFurtherFromPlayer.transform.position);
        }


        if (pTileFurtherFromPlayer == null || pTileWeJustLeft == null)
        {
            pVariablesModule.SetVariable(c_sVariableName_pTileWeJustLeft, pCurrentTile);                // If no further tile, should allow backtrack if needed, and if no tile just left, prevent backtracking by putting the current one just in case
        }
    }
예제 #2
0
    private void GetOutOfPrison(Ghost pGhost)
    {
        CharacterProceduralVariablesModule pVariablesModule = pGhost.m_pProceduralVariablesModule;

        bool bWentOnPrisonDoor       = pVariablesModule.GetVariableAsBool(c_sVariableName_bFleeBehaviourWentOnPrisonDoor);
        bool bCurrentTileIsGhostDoor = MapManager.Instance.GetTileFromPosition(pGhost.transform.position).TileType == ETileType.GHOST_DOOR;

        if (!bWentOnPrisonDoor)
        {
            pVariablesModule.SetVariable(c_sVariableName_bFleeBehaviourWentOnPrisonDoor, bCurrentTileIsGhostDoor);
        }
        else if (!bCurrentTileIsGhostDoor)
        {
            pVariablesModule.SetVariable(c_sVariableName_bReceivedBehaviourWhileInPrison, false);
        }

        pGhost.m_pNavMeshAgent.SetDestination(PlayerCharacter.Instance.transform.position);
    }