Beispiel #1
0
 public static void SetBoardColorGoal(int hexagonID, ColorID seedColorID)
 {
     if (!State.gameBoard.presetBoard.ContainsKey(hexagonID))
     {
         State.gameBoard.presetBoard.Add(hexagonID, (int)seedColorID);
         ActorGridManager.SetHexagonGoalColor(hexagonID, seedColorID);
     }
 }
Beispiel #2
0
    public static void SetBoardToTurn(int TurnID)
    {
        // reset the grid state
        // this resets colors and goals for all hexagons
        ActorGridManager.ResetGrid();

        // clear the scoreboard
        int originalSeedsPlantedGoal = State.gameBoard.gameGoals.ContainsKey(seedsPlanted) ? State.gameBoard.gameGoals[seedsPlanted] : TurnID;

        ClearScores();

        // if this is a NEW board, then copy the history
        // to the solution to simulate a game save
        if (State.BoardIsNew())
        {
            State.gameBoard.seedsPlantedSolution = new Queue <GameStep>(seedsPlantedHistory);
        }

        Debug.LogWarning("Setting board " + State.gameBoardName + " state to turn " + TurnID);

        // if we are in play mode, simply repeat the steps from seedsPlanted History up to the turnID
        if (State.gameActivity == GameActivity.play && seedsPlantedHistory.Count >= TurnID && TurnID > 0)
        {
            Queue <GameStep> replay = new Queue <GameStep>(seedsPlantedHistory);
            ClearHistory();
            SetScoreGoal(seedsPlanted, originalSeedsPlantedGoal);

            for (int i = 0; i < TurnID; i++)
            {
                GameStep playStep = replay.Dequeue();
                SetSeedColor(playStep.colorID);
                ActorGridManager.GetHexagonActor(playStep.hexagonID).PlantSeed();
            }
        }

        // if we are in the edit or test activity, and we own this board, then
        // reset the local history
        // this doesn't effect the board's solution
        // and gets rebuild by PlantSeed() function
        // then replay the solution up to the turnID
        // while also rebuilding the solution queue
        // also set the currently-selected seed color to match the last turn
        if ((State.gameActivity == GameActivity.edit || State.gameActivity == GameActivity.test) && State.gameBoardMine)
        {
            ClearHistory();

            // set the goal to the turn count
            SetScoreGoal(seedsPlanted, TurnID);


            for (int i = 0; i < TurnID; i++)
            {
                GameStep playStep = State.gameBoard.seedsPlantedSolution.Dequeue();
                SetSeedColor(playStep.colorID);
                ActorGridManager.GetHexagonActor(playStep.hexagonID).PlantSeed();
            }


            // clear the solution and copy the current history to the solution making sure to use deep copy
            State.gameBoard.seedsPlantedSolution.Clear();
            State.gameBoard.seedsPlantedSolution = new Queue <GameStep>(seedsPlantedHistory);
        }


        // if we are in artist mode, or if we do not own this board
        // then set the hexagon goals
        if (State.gameMode == GameMode.artist || !State.gameBoardMine)
        {
            Debug.Log("Setting " + State.gameBoard.presetBoard.Count + " preset hexagon goals for board " + State.gameBoardName);
            foreach (KeyValuePair <int, int> preset in State.gameBoard.presetBoard)
            {
                ActorGridManager.SetHexagonGoalColor(preset.Key, (ColorID)preset.Value);
            }

            // set the goal back to what it was originally
            SetScoreGoal(seedsPlanted, originalSeedsPlantedGoal);
        }

        // automatically advance to PLAY state
        State.gameState = GameState.play;

        UpdateDisplay();
    }