Example #1
0
    private void Update()
    {
        //if in communcation, check for response, call handler on response if there
        if (aiCommState == AICommunicationState.InCommunication)
        {
            if (currentCommChannel != null && currentCommChannel.IsResponseReceived())
            {
                playerResponse = currentCommChannel.GetResponse();

                //end communcation and reset state
                currentCommChannel.EndCommuncation();
                currentCommChannel = null;

                aiCommState = AICommunicationState.NotInCommuncation;

                //handle whatever the response was
                HandleResponse(playerResponse);
            }
        }
        else if (!openingDone)
        {
            Debug.LogError("about to close doors in cell opening");
            maze.CloseDoorsInCell(playerCurrentCoords);
            SendMessageToPlayer(GameLinesTextGetter.OpeningMonologue(), oneWayCommChannel);
        }
        else if (playerCurrentCoords != player.MazeCellCoords &&
                 DistanceBetweenPlayerAndRoom(player.MazeCellCoords) < 0.4)
        {
            //neutral ending. ends on reaching the ladder
            if (player.MazeCellCoords == maze.exitCoords && !aiAlignmentState.ToString().StartsWith("Very"))
            {
                FlyoverMonologueEnding();
            }
            //very friendly ending. end condition on the last room
            else if (aiAlignmentState == AIAlignmentState.VeryFriendly &&
                     player.MazeCellCoords.z == (maze.size.z - 1))
            {
                maze.TurnAllLightsRed();

                Debug.LogError("about to close doors in cell friendlyending");
                maze.CloseDoorsInCell(player.MazeCellCoords);
                gameOver = true;
            }
            //the standard case. do a reaction or request
            else
            {
                //for the single hallway ending. close doors behind you.
                if (aiAlignmentState == AIAlignmentState.VeryFriendly)
                {
                    Debug.LogError("about to close doors in cell friendlyending close behind");
                    maze.CloseDoorsInCell(playerCurrentCoords);
                }

                playerCurrentCoords = player.MazeCellCoords;
                if (!firstInterchangeDone)
                {
                    Neutral_Request_AskPlayerToTouchCorners();
                    firstInterchangeDone = true;
                }
                else
                {
                    if (reactToPlayer)
                    {
                        ExecuteRandomAction(perStateReactionList[aiAlignmentState]);

                        //react to player next time only if VeryHostile, VeryFriendly and there are reactions left
                        reactToPlayer = (aiAlignmentState.ToString().StartsWith("Very")) &&
                                        perStateReactionList[aiAlignmentState].Count > 0;
                    }
                    else
                    {
                        if (!roomsRequestedIn.ContainsKey(playerCurrentCoords))
                        {
                            ExecuteRandomAction(perStateRequestActionList[aiAlignmentState]);
                            roomsRequestedIn[playerCurrentCoords] = true;
                        }

                        //on occasion, prompt a reaction from the AI on the next room
                        reactToPlayer = (UnityEngine.Random.Range(0, 1f) < 0.75f);
                    }
                }
            }
        }
    }
 public static string GetEndingMonologue(AIAlignmentState state) {
     return GetAllTextByPath("ending/" + state.ToString() + "/ending_monologue_standard");
 }
Example #3
0
 public static string GetEndingMonologue(AIAlignmentState state)
 {
     return(GetAllTextByPath("ending/" + state.ToString() + "/ending_monologue_standard"));
 }