コード例 #1
0
    void Start()
    {
        // clear any input from previous screens
        Input.ResetInputAxes();

        // make sure the progress throbber from the
        // board list is cleared
        State.TaskDone("GetBoardList");

        // cache instance references
        gridManager    = GameObject.FindGameObjectWithTag("GridManager").GetComponentInChildren <ActorGridManager>();
        audioManager   = GameObject.FindGameObjectWithTag("AudioManager").GetComponentInChildren <ActorAudioManager>();
        trinketManager = GameObject.FindGameObjectWithTag("TrinketManager").GetComponentInChildren <ActorTrinketManager>();

        // find the GUI objects
        flowerSelectorObject    = GameObject.Find(flowerSelector).GetComponentInChildren <RectTransform>();
        flowerSelectorImage     = GameObject.Find(flowerSelector).GetComponentInChildren <Image>();
        dialogPanelText         = GameObject.Find(dialogPanel).GetComponentInChildren <Text>();
        blueSelectTransform     = GameObject.Find(blueSelectButton).GetComponentInChildren <RectTransform>();
        redSelectTransform      = GameObject.Find(redSelectButton).GetComponentInChildren <RectTransform>();
        yellowSelectTransform   = GameObject.Find(yellowSelectButton).GetComponentInChildren <RectTransform>();
        boardNameField          = GameObject.Find(boardNameInput).GetComponentInChildren <InputField>();
        saveBoardTextObject     = GameObject.Find(saveBoardText).GetComponentInChildren <Text>();
        ratioTextObject         = GameObject.Find(ratioText).GetComponentInChildren <Text>();
        gemsRemainingTextObject = GameObject.Find(gemsRemaining).GetComponentInChildren <Text>();
        foundTrinketTextObject  = GameObject.Find(foundTrinketText).GetComponentInChildren <Text>();
        trinketImageObject      = GameObject.Find(trinketImage).GetComponentInChildren <Image>();

        // reset the board
        ResetBoard();
    }
コード例 #2
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);
     }
 }
コード例 #3
0
 public void EnterTestMode()
 {
     ActorGameManager.ShowGroup(testModePanelName, true);
     ActorGameManager.ShowGroup(playModeControlsPanelName, false);
     ActorGameManager.ShowGroup(editModePanelName, false);
     ActorGridManager.EnterTestMode();
     ActorGameManager.EnterTestMode();
     ActorGameManager.ShowGroup(helpPanelName, false);
 }
コード例 #4
0
    public static void ShowHint()
    {
        if (State.gameActivity != GameActivity.play)
        {
            return;
        }

        Debug.Log("Show Hint Requested");

        if (seedsPlantedHistory.Count < State.gameBoard.seedsPlantedSolution.Count)
        {
            Identity.AddGems(-1);
            GameStep nextSolution = State.gameBoard.seedsPlantedSolution.ToArray()[seedsPlantedHistory.Count]; // get the solution 1 after the current step
            SetSeedColor(nextSolution.colorID);
            ActorGridManager.GetHexagonActor(nextSolution.hexagonID).PlantSeed();

            UpdateDisplay();
        }
        else
        {
            Debug.LogError("Hint requested past end of solution queue");
        }
    }
コード例 #5
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();
    }
コード例 #6
0
ファイル: Critter.cs プロジェクト: Tulrath/bitterplants
    void Update()
    {
        if (deathTime != 0 && Time.realtimeSinceStartup > deathTime)
        {
            Destroy(gameObject);
        }

        if (!moving && Time.realtimeSinceStartup > nextStartMoveTime)
        {
            moving           = true;
            nextStopMoveTime = Time.realtimeSinceStartup + moveSeconds;
            GameObject go = null;
            switch (moveType)
            {
            case MoveType.random:
                go = ActorGridManager.GetRandomHexagon();
                if (go)
                {
                    targetTransform = go.GetComponent <RectTransform>();
                }
                break;

            case MoveType.stationary:
                targetTransform    = null;
                moveSpeedPerSecond = Vector2.zero;
                break;
            }
        }

        if (moving && Time.realtimeSinceStartup > nextStopMoveTime)
        {
            moving            = false;
            nextStartMoveTime = Time.realtimeSinceStartup + pauseSeconds;
        }

        if (moving)
        {
            if (targetTransform != null)
            {
                Vector2 tgt = targetTransform.anchoredPosition;
                Vector2 pos = myTransform.anchoredPosition;
                desiredMove = new Vector2(tgt.x < pos.x ? -moveSpeedPerSecond.x : moveSpeedPerSecond.x, tgt.y < pos.y ? -moveSpeedPerSecond.y : moveSpeedPerSecond.y) * Time.deltaTime;
            }
            else
            {
                desiredMove = moveSpeedPerSecond * Time.deltaTime;
            }
        }

        if (desiredMove != Vector2.zero)
        {
            Vector2 newPosition = myTransform.anchoredPosition + desiredMove;
            newPosition.x = newPosition.x < -32f ? (State.referenceScreenSize.x + 32f) : newPosition.x;
            newPosition.x = newPosition.x > (State.referenceScreenSize.x + 64f) ? -32f : newPosition.x;
            newPosition.y = newPosition.y < 32f ? (State.referenceScreenSize.y + 32f) : newPosition.y;
            newPosition.y = newPosition.y > (State.referenceScreenSize.y + 64f) ? 32f : newPosition.y;

            myTransform.anchoredPosition = newPosition;
        }

        if (moveType == MoveType.sway && swayDistance.x != 0)
        {
            swayMax = new Vector2(swayMax.x, myTransform.anchoredPosition.y);
            swayMin = new Vector2(swayMin.x, myTransform.anchoredPosition.y);
            //myTransform.anchoredPosition = Vector2.SmoothDamp(myTransform.anchoredPosition, swayingRight? swayMax :swayMin, ref swayVelocity, smoothTime);
            myTransform.anchoredPosition = Vector2.SmoothDamp(myTransform.anchoredPosition, (swayingRight ? swayMax : swayMin), ref swayVelocity, smoothTime, 10f, Time.deltaTime);

            if (Time.time > nextSwayChange)
            {
                nextSwayChange = Time.time + swayInterval;
                swayingRight   = !swayingRight;
            }
        }

        if (spinDegreesPerSecond != 0)
        {
            myTransform.Rotate(Vector3.forward, Time.deltaTime * spinDegreesPerSecond, Space.World);
        }

        if (flipDegreesPerSecond != 0)
        {
            myTransform.Rotate(Vector3.right, Time.deltaTime * flipDegreesPerSecond, Space.World);
        }

        if (fadeSeconds != 0)
        {
            currentOpacity = Mathf.PingPong(((Time.time + fadeOffset) / fadeSeconds), 1f);
            myImage.color  = new Color(1f, 1f, 1f, currentOpacity);
        }
    }