/// <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 } }
/// <summary> /// Public so it can be used by other behaviours if needed (NOTHING ELSE!) /// </summary> public void InitVariables(Ghost pGhost) { CharacterProceduralVariablesModule pVariablesModule = pGhost.m_pProceduralVariablesModule; pVariablesModule.ResetVariable(c_sVariableName_pTileLastFrame); pVariablesModule.ResetVariable(c_sVariableName_pTileWeJustLeft); pVariablesModule.SetVariable(c_sVariableName_bReceivedBehaviourWhileInPrison, pGhost.IsDead()); pVariablesModule.ResetVariable(c_sVariableName_bFleeBehaviourWentOnPrisonDoor); }
private void UpdateSavedTiles(Ghost pGhost, Tile pCurrentTile) { CharacterProceduralVariablesModule pVariablesModule = pGhost.m_pProceduralVariablesModule; Tile pTileLastFrame = (Tile)(pVariablesModule.GetVariable(c_sVariableName_pTileLastFrame)); if (pCurrentTile != pTileLastFrame) { pVariablesModule.SetVariable(c_sVariableName_pTileWeJustLeft, pTileLastFrame); } pVariablesModule.SetVariable(c_sVariableName_pTileLastFrame, pCurrentTile); }
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); }