Example #1
0
    // Get a new command from the player
    public void GetPlayerCommand()
    {
        CommandOutcome outcome             = CommandOutcome.FULL;
        bool           hintOrDeathQuestion = false;

        SuspendCommandProcessing(); // Suspend further command processing until command has been executed

        // Remind the player of two word limit, if they have entered more than a two word command
        if (playerInput.NumberOfWords > 2)
        {
            textDisplayController.AddTextToLog(playerMessageController.GetMessage("53LongCommand"));
        }

        // Count a new turn and deal with any fallout from that
        AddTurn();

        CaveStatus oldCaveStatus = CurrentCaveStatus;

        // Update the clocks and check for closing
        UpdateClocks();

        // Only do lamp stuff if the cave status hasn't just changed
        if (oldCaveStatus == CurrentCaveStatus)
        {
            // Update the lamp and check for dimming/out of power
            UpdateLamp();
        }

        // Only process the command if the cave hasn't just closed
        if (!(oldCaveStatus != CurrentCaveStatus && CurrentCaveStatus == CaveStatus.CLOSED))
        {
            // Process the players's command
            parserState.ResetParserState(playerInput.Words);
            outcome = commandsController.ProcessCommand();
        }

        // If the outcome allows, process a turn following the player command
        if (outcome == CommandOutcome.FULL || outcome == CommandOutcome.DESCRIBE || outcome == CommandOutcome.MESSAGE)
        {
            hintOrDeathQuestion = ProcessTurn(outcome);
        }
        else if (outcome == CommandOutcome.DISTURBED)
        {
            // Player has disturbed the dwarves, so show message before ending game
            textDisplayController.AddTextToLog(playerMessageController.GetMessage("136DwarvesAttack"));
        }

        // If the command has resulted int eh end of game, then end game now
        if (outcome == CommandOutcome.DISTURBED || outcome == CommandOutcome.ENDED)
        {
            EndGame(false);
        }
        // Otherwise, wait for the next player command, unless we're waiting for a question response
        if (outcome != CommandOutcome.QUESTION && !hintOrDeathQuestion)
        {
            ResumeCommandProcessing();
        }
    }
Example #2
0
    // Calculate score for progress
    private void ProgressScore()
    {
        // Add score for number of deaths
        maxScore += gameController.MaxDeaths * 10;
        score    += (gameController.MaxDeaths - gameController.NumDeaths) * 10;

        // Add points for reaching end of game, i.e. not quitting
        maxScore += 4;
        if (ReachedEnd)
        {
            score += 4;
        }

        // Add points for getting deep in cave
        maxScore += 25;
        if (dwarfController.ActivationLevel != 0)
        {
            score += 25;
        }

        CaveStatus caveStatus = gameController.CurrentCaveStatus;

        // Add points for reaching closing
        maxScore += 25;
        if (caveStatus == CaveStatus.CLOSING || caveStatus == CaveStatus.CLOSED)
        {
            score += 25;
        }

        maxScore += 45;
        // Add bonus points if reached closed
        if (caveStatus == CaveStatus.CLOSED)
        {
            score += BonusPoints;
        }

        // Add a point for leaving the magazine at Witt's End
        maxScore++;
        if (itemController.ItemIsAt("16SpelunkerToday", "108WittsEnd"))
        {
            score++;
        }

        // Round off the score
        maxScore += 2;
        score    += 2;
    }
    public GameData(GameController controller, DataType dataType)
    {
        // Add data type
        this.dataType = dataType;

        // Add code
        dataID = "";
        while (dataID.Length < 16)
        {
            dataID += characterSet[UnityEngine.Random.Range(0, characterSet.Length)];
        }

        // Add player
        player = PlayerPrefs.GetInt("CurrentPlayer");

        // Add text display data
        textLog = controller.textDisplayController.TextLog;

        // Add parser state
        ParserState parserState = controller.parserState;

        commandBeingProcessed = parserState.CommandBeingProcessed;
        commandsToProcess     = parserState.CommandsToProcess;
        subjectCarriedOver    = parserState.SubjectCarriedOver;
        verbCarriedOver       = parserState.VerbCarriedOver;

        // Add game controller data
        clock1            = controller.Clock1;
        clock2            = controller.Clock2;
        currentCaveStatus = controller.CurrentCaveStatus;
        currentGameStatus = controller.CurrentGameStatus;
        lampLife          = controller.LampLife;
        lampWarning       = controller.LampWarning;
        numDeaths         = controller.NumDeaths;
        panic             = controller.Panic;
        turns             = controller.Turns;
        wasDark           = controller.WasDark;

        // Add player data
        PlayerController playerController = controller.playerController;

        currentLocation = playerController.CurrentLocation;
        oldLocations    = playerController.OldLocations;

        // Add commands data
        CommandsController commandsController = controller.commandsController;

        magicWordText = commandsController.MagicWordText;
        oldItem       = commandsController.OldItem;
        westCount     = commandsController.WestCount;

        // Add location data
        LocationController locationController = controller.locationController;

        detailMsgCount            = locationController.DetailMsgCount;
        locViews                  = locationController.LocViews;
        timesToAbbreviateLocation = locationController.TimesToAbbreviateLocation;

        // Add items data
        ItemController itemController = controller.itemController;

        itemDict      = itemController.ItemDict;
        treasuresSeen = itemController.TreasuresSeen;

        // Add actions data
        ActionController actionController = controller.actionController;

        foobar  = actionController.Foobar;
        goCount = actionController.GoCount;

        // Add dwarf data
        DwarfController dwarfController = controller.dwarfController;

        activationLevel = dwarfController.ActivationLevel;
        dwarves         = dwarfController.Dwarves;
        dwarvesKilled   = dwarfController.DwarvesKilled;

        // Add score data
        ScoreController scoreController = controller.scoreController;

        bonusPoints       = scoreController.BonusPoints;
        closedHintShown   = scoreController.ClosedHintShown;
        savePenaltyPoints = scoreController.SavePenaltyPoints;
        thresholdIndex    = scoreController.ThresholdIndex;
        turnsPointsLost   = scoreController.TurnsPointsLost;
        isNovice          = scoreController.IsNovice;
        reachedEnd        = scoreController.ReachedEnd;

        // Add hints data
        hintActivations = controller.hintController.HintActivations;

        // Add question data
        currentQuestion = controller.questionController.CurrentQuestion;
    }