コード例 #1
0
    internal static void Clicked(S_Gem _gem)
    {
        _ClickedGems.Add(_gem);
        if (_ClickedGems.Count == 2)
        {
            Vector2Int _Result = _ClickedGems[0].M_Sector - _ClickedGems[1].M_Sector;

            if (_Result.x == -1)
            {
                _ClickedGems[0].SetSector(true, 1);                         // right
            }
            else if (_Result.x == 1)
            {
                _ClickedGems[0].SetSector(true, -1);                        // left
            }
            else if (_Result.y == -1)
            {
                _ClickedGems[0].SetSector(false, 1);                        // up
            }
            else if (_Result.y == 1)
            {
                _ClickedGems[0].SetSector(false, -1);                       // down
            }
            _ClickedGems.Clear();
        }
    }
コード例 #2
0
ファイル: S_Gem.cs プロジェクト: AntonSalazar/Emission-MTCH3-
    private void FindMatches()
    {
        name = "Gem (" + M_Sector.x + " : " + M_Sector.y + ")";
        if (M_Sector.x > 0 && M_Sector.x < S_Board.M_sBoard.x - 1)
        {
            S_Gem _Left  = S_Board.M_GemsGrid[M_Sector.x - 1, M_Sector.y];
            S_Gem _Right = S_Board.M_GemsGrid[M_Sector.x + 1, M_Sector.y];

            if (M_GemColor == _Left.M_GemColor && M_GemColor == _Right.M_GemColor)
            {
                M_isMatched        = true;
                _Left.M_isMatched  = true;
                _Right.M_isMatched = true;
            }
        }

        if (M_Sector.y > 0 && M_Sector.y < S_Board.M_sBoard.y - 1)
        {
            S_Gem _Down = S_Board.M_GemsGrid[M_Sector.x, M_Sector.y - 1];
            S_Gem _Up   = S_Board.M_GemsGrid[M_Sector.x, M_Sector.y + 1];

            if (M_GemColor == _Down.M_GemColor && M_GemColor == _Up.M_GemColor)
            {
                M_isMatched       = true;
                _Down.M_isMatched = true;
                _Up.M_isMatched   = true;
            }
        }
    }
コード例 #3
0
    private void GenerateGrid()
    {
        M_GemsGrid = new S_Gem[M_sBoard.x, M_sBoard.y];

        for (int i = 0; i < M_sBoard.x; i++)
        {
            for (int j = 0; j < M_sBoard.y; j++)
            {
                S_Gem _newGem = S_PoolManager.m_PoolManager.GetPoolObject(_GemObject, new Vector3(i - (M_sBoard.x / 2), j - (M_sBoard.y / 2), transform.position.z), Quaternion.identity);
                _newGem.name = "Gem (" + i + " : " + j + ")";
                _newGem.m_Transform.SetParent(transform);
                _newGem.M_Sector   = new Vector2Int(i, j);
                _newGem.M_GemColor = (S_Gem.GemColor)Random.Range(0, _Dificult);
                M_GemsGrid[i, j]   = _newGem;
            }
        }
    }