コード例 #1
0
    void Start()
    {
        GameBoard   = GameObject.FindGameObjectWithTag("GameBoard").GetComponent <HexGrid>();
        bubbleIndex = GameBoard.GetRandomBubbleIndex();
        Color bubbleColor = GameBoard.GetBubbleColor(bubbleIndex);

        Paddle = GameObject.FindGameObjectWithTag("Player").GetComponent <PaddleController>();
        Paddle.SetLineRendererColor(bubbleColor);
    }
コード例 #2
0
    public void AddBubbleToGameBoard(Bubble bubble)
    {
        Vector3        position    = GameBoard.transform.InverseTransformPoint(bubble.transform.position);
        HexCoordinates coordinates = HexCoordinates.FromPosition(position);

        if (GameBoard.HasCellBubble(coordinates.X, coordinates.Y) == false)
        {
            GameBoard.AddBubbleToCoordinates(coordinates.X, coordinates.Y, bubble);
            var clusterBubbles = GameBoard.GetClusterFromCoordinates(coordinates.X, coordinates.Y);

            if (clusterBubbles != null &&
                clusterBubbles.Count >= MinBubblesToRemove)
            {
                foreach (var bubbleCoordinates in clusterBubbles)
                {
                    GameBoard.RemoveBubbleFromCoordinates(bubbleCoordinates.X, bubbleCoordinates.Y);
                }

                var floatingClusters = GameBoard.GetFloatingClusters();

                foreach (var bubbleCoordinates in floatingClusters)
                {
                    GameBoard.RemoveBubbleFromCoordinates(bubbleCoordinates.X, bubbleCoordinates.Y);
                }

                UpdateScore(clusterBubbles.Count + floatingClusters.Count);
            }

            GameBoard.SetTurnOver();
            if (GameBoard.IsTurnEventCountReached() == true)
            {
                GameBoard.AddNewBubblesRow();
            }
        }

        IsGameOver = CheckIsGameOver();
        if (IsGameOver)
        {
            StartCoroutine(GotoGameOver());
        }

        bubbleIndex = GameBoard.GetRandomBubbleIndex();
        Color bubbleColor = GameBoard.GetBubbleColor(bubbleIndex);

        Paddle.SetLineRendererColor(bubbleColor);
        bubbleToLaunch = null;
    }