コード例 #1
0
    public bool Calculate(int cellView1Index, int cellView2Index)
    {
        int minIndex = Mathf.Min(cellView1Index, cellView2Index);
        int maxIndex = Mathf.Max(cellView1Index, cellView2Index);

        CellModel first  = Grid[minIndex];
        CellModel second = Grid[maxIndex];

        if (CheckHorizontalCellsCanBeDestroyed(minIndex, maxIndex))
        {
            Enable(first, second);
            return(true);
        }
        else if (CheckVerticalCellsCanBeDestroyed(minIndex, maxIndex))
        {
            Enable(first, second);
            return(true);
        }
        else if (CheckFirstAndLastCanBeDestroyed(minIndex, maxIndex))
        {
            Enable(first, second);
            return(true);
        }
        else
        {
            Vibration.Medium();
        }

        return(false);
    }