Beispiel #1
0
    // Begin a new turn
    public bool ProcessTurn(CommandOutcome turnType)
    {
        bool hintOrDeathQuestion = false;
        bool forced = true;

        // This loop is repeated while the player is alive until the player reaches a location where movement isn't forced
        while (playerController.IsAlive && forced)
        {
            forced = false; // Ensure we break out of the loop, unless the current location is forced

            if (turnType == CommandOutcome.FULL)
            {
                // If the player has left the cave during closing ...
                if (playerController.IsOutside && CurrentCaveStatus == CaveStatus.CLOSING)
                {
                    // ... force them back inside and give them warning about cave closing
                    playerController.RevokeMovement();
                    textDisplayController.AddTextToLog(playerMessageController.GetMessage("130ClosedAnnounce"));

                    // Start the panic clock, if it hasn't already started
                    StartPanic();
                }

                // CHeck if player's path is blocked by a dwarf before moving player to new location
                if (dwarfController.Blocked())
                {
                    // Passage was blocked, so tell player
                    textDisplayController.AddTextToLog(playerMessageController.GetMessage("2DwarfBlock"));
                    playerController.RevokeMovement();
                }
                else
                {
                    playerController.CommitMovement();
                }

                // Now process the dwarves
                if (dwarfController.DoDwarfActions())
                {
                    // The dwarves killed the player avatar
                    playerController.KillPlayer();
                }
            }

            // If player is still alive after any dwarf encounters...
            if (playerController.IsAlive)
            {
                // If the location is to be shown or reshown, show it now
                if (turnType != CommandOutcome.MESSAGE)
                {
                    // Now show the current location
                    DisplayLocation();
                }

                // Show useful info in the debug panel (only visible if debug mode is on)
                debugPanelScript.UpdateDebugPanel();

                // Check to see if movement from this location is forced and move if so
                forced = playerController.CheckForcedMove();

                // Forced locations can't have items left there and don't have hints, so if movement was forced, we can skip this section
                if (!forced)
                {
                    // Don't show item descriptions again if the command outcome was just a message
                    if (turnType != CommandOutcome.MESSAGE)
                    {
                        // If at Y2 before closing, there's a 25% chance the player hears someone say "PLUGH"
                        if (playerController.CurrentLocation == "33Y2" && CurrentCaveStatus != CaveStatus.CLOSING && Random.value < .25)
                        {
                            textDisplayController.AddTextToLog(playerMessageController.GetMessage("7Plugh"));
                        }

                        DisplayItems();
                    }

                    // If cave is closed, adjust state of any carried items so they will be described again after they are put down
                    if (CurrentCaveStatus == CaveStatus.CLOSED)
                    {
                        AdjustCarriedItemsAfterClosing();
                    }

                    // Get rid of the knife if it exists
                    itemController.CleanUpKnife();
                }
                else
                {
                    // Ensure we process a full turn for any forced movement
                    turnType = CommandOutcome.FULL;
                }
            }
        }

        // If the player has died
        if (!playerController.IsAlive)
        {
            PlayerDeath();
            hintOrDeathQuestion = true;
        }
        else
        {
            // Show any hints for the current location
            hintOrDeathQuestion = hintController.CheckForHints(playerController.CurrentLocation);
        }

        // Check to see if a continuation save is due
        persistenceController.CheckContinuationSave();

        return(hintOrDeathQuestion);
    }