コード例 #1
0
    // 주변 노드들 탐지
    public void CheckNearNodes_Hexa()
    {
        Hexa.Dot   dot       = this.gameObject.GetComponent <Hexa.Dot>();
        Hexa.Board hexaBoard = board.GetComponent <Hexa.Board>();

        if (dot != null)
        {
            GameObject nodeObj = hexaBoard.nodes[dot.column][dot.row];

            // 차감 횟수가 0, 즉 다 터졌으면
            if (count <= 0)
            {
                // 보드에서 장애물 갯수를 하나 줄이고
                hexaBoard.obstacles.Dequeue();
                // 나의 매치 상태를 true로 -> 사라질때 처리를 Dot과 한꺼번에
                dot.isMatched = true;
            }

            // 나의 node정보가 있다면, 혹시모를 null 오류 방지
            if (nodeObj != null)
            {
                Hexa.Node node = nodeObj.GetComponent <Hexa.Node>();

                for (int i = 0; i < 6; i++)
                {
                    // 주변 노드가 있다면
                    if (node.nearNodes[i] != null)
                    {
                        // 주변에서 블럭이 터지면
                        if (node.nearNodes[i].GetComponent <Hexa.Node>().dot == null || node.nearNodes[i].GetComponent <Hexa.Node>().dot.GetComponent <Hexa.Dot>().isMatched == true)
                        {
                            // 나의 색깔을 0.6%정도로 변화시키고
                            this.gameObject.GetComponent <SpriteRenderer>().color *= 0.6f;
                            // 차감 횟수를 낮춘 후
                            count--;
                            // 나가, 왜? 주변에서 여러개가 한꺼번에 터져도 횟수는 한번만 차감되기 때문.
                            break;
                        }
                    }
                }
            }
        }
    }