Example #1
0
    // subPanelの同じ色のdropを取得する
    private int GetSubNodeColorCount(PuzzleDrop.DROP_TYPE type, Vector2 arrayPos)
    {
        foreach (Vector2 vec2 in checkTriggerPos)
        {
            if (vec2 == arrayPos)
            {
                return(0);
            }
        }
        checkTriggerPos.Add(arrayPos);
        if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x] == null)
        {
            return(0);
        }
        int count = 0;
        // 自身の色が目的の色と同じならカウントを増加させる
        PuzzleDrop drop = subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x];

        if (drop.dropType == type)
        {
            destroyTargetArrayPos.Add(arrayPos);
            count++;
        }
        else
        {
            return(0);
        }

        // 下方向をチェック
        if (!((int)arrayPos.y + 1 >= subPanelHeight))
        {
            if (subPanel[((int)arrayPos.y + 1) * subPanelWidth + (int)arrayPos.x] != null)
            {
                if (subPanel[((int)arrayPos.y + 1) * subPanelWidth + (int)arrayPos.x].dropType == type)
                {
                    count += GetSubNodeColorCount(type, new Vector2(arrayPos.x, arrayPos.y + 1));
                }
            }
        }

        // 上方向をチェック
        if (!((int)arrayPos.y - 1 <= -1))
        {
            if (subPanel[((int)arrayPos.y - 1) * subPanelWidth + (int)arrayPos.x] != null)
            {
                if (subPanel[((int)arrayPos.y - 1) * subPanelWidth + (int)arrayPos.x].dropType == type)
                {
                    count += GetSubNodeColorCount(type, new Vector2(arrayPos.x, arrayPos.y - 1));
                }
            }
        }

        // 左方向をチェック
        if (!((int)arrayPos.x - 1 <= -1))
        {
            if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x - 1] != null)
            {
                if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x - 1].dropType == type)
                {
                    count += GetSubNodeColorCount(type, new Vector2(arrayPos.x - 1, arrayPos.y));
                }
            }
        }

        // 右方向をチェック
        if (!((int)arrayPos.x + 1 >= subPanelWidth))
        {
            if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x + 1] != null)
            {
                if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x + 1].dropType == type)
                {
                    count += GetSubNodeColorCount(type, new Vector2(arrayPos.x + 1, arrayPos.y));
                }
            }
        }

        return(count);
    }
Example #2
0
 void Awake()
 {
     gameManager = GetComponent <GameManager> ();
     puzzleDrop  = FindObjectOfType <PuzzleDrop> ();
 }