コード例 #1
0
ファイル: BoardController.cs プロジェクト: Tetro48/prjChlg
    /// <summary>
    /// Clears all tiles from a specified line
    /// </summary>
    /// <param name="lineToClear">Index of the line to be cleared</param>
    void ClearLine(int lineToClear)
    {
        int linesFrozen = GameEngine.instance.lineFreezingMechanic ? GameEngine.instance.linesFrozen[GameEngine.instance.curSect] : 0;

        if (lineToClear < linesFrozen || lineToClear > gridSizeY)
        {
            Debug.LogError("Error: Cannot Clear Line: " + lineToClear);
            return;
        }
        for (int x = 0; x < gridSizeX; x++)
        {
            PieceController curPC = fullGrid[x, lineToClear].tileOnGridUnit.GetComponent <TileController>().pieceController;
            curPC.tiles[fullGrid[x, lineToClear].tileOnGridUnit.GetComponent <TileController>().tileIndex] = null;
            int tileTexture = 0;
            for (int i = 0; i < 28; i++)
            {
                if (fullGrid[x, lineToClear].tileOnGridUnit.GetComponent <SpriteRenderer>().sprite == curPC.tileSprites[i])
                {
                    tileTexture = i;
                }
            }
            BoardParticleSystem.instance.SummonParticles(new Vector2Int(x, lineToClear), tileTexture);
            Destroy(fullGrid[x, lineToClear].tileOnGridUnit);
            if (!curPC.AnyTilesLeft())
            {
                Destroy(curPC.gameObject);
            }
            fullGrid[x, lineToClear].tileOnGridUnit = null;
            fullGrid[x, lineToClear].isOccupied     = false;
        }
    }
コード例 #2
0
 /// <summary>
 /// 一行のタイルをクリアする
 /// </summary>
 /// <param name="lineToClear">行のインデクス</param>
 private void ClearLine(int lineToClear)
 {
     if (lineToClear < 0 || lineToClear > gridSizeY)
     {
         Debug.LogError("Error: Cannot Clear Line" + lineToClear);
         return;
     }
     for (int x = 0; x < gridSizeX; x++)
     {
         PieceController curPC = gameBoardUnits[x, lineToClear].tileOnThisGrid.GetComponent <TileController>().pieceController;
         curPC.tiles[gameBoardUnits[x, lineToClear].tileOnThisGrid.GetComponent <TileController>().tileIndex] = null;
         Destroy(gameBoardUnits[x, lineToClear].tileOnThisGrid);
         if (!curPC.AnyTilesLeft())
         {
             Destroy(curPC.gameObject);
         }
         gameBoardUnits[x, lineToClear].tileOnThisGrid = null;
         gameBoardUnits[x, lineToClear].isOccupied     = false;
     }
 }
コード例 #3
0
 /// <summary>
 /// Clears all tiles from a specified line
 /// </summary>
 /// <param name="lineToClear">Index of the line to be cleared</param>
 void ClearLine(int lineToClear)
 {
     if (lineToClear < 0 || lineToClear > gridSizeY)
     {
         Debug.LogError("Error: Cannot Clear Line: " + lineToClear);
         return;
     }
     for (int x = 0; x < gridSizeX; x++)
     {
         PieceController curPC = fullGrid[x, lineToClear].tileOnGridUnit.GetComponent <TileController>().pieceController;
         curPC.tiles[fullGrid[x, lineToClear].tileOnGridUnit.GetComponent <TileController>().tileIndex] = null;
         Destroy(fullGrid[x, lineToClear].tileOnGridUnit);
         if (!curPC.AnyTilesLeft())
         {
             Destroy(curPC.gameObject);
         }
         fullGrid[x, lineToClear].tileOnGridUnit = null;
         fullGrid[x, lineToClear].isOccupied     = false;
     }
 }
コード例 #4
0
ファイル: BoardController.cs プロジェクト: Tetro48/prjChlg
    public void DestroyLine(int line)
    {
        for (int i = 0; i < gridSizeX; i++)
        {
            // if (line < 0)
            // {
            //     Debug.LogError("Out of bounds!");
            //     break;
            // }
            if (fullGrid[i, line].isOccupied)
            {
                PieceController curPC = fullGrid[i, line].tileOnGridUnit.GetComponent <TileController>().pieceController;
                curPC.tiles[fullGrid[i, line].tileOnGridUnit.GetComponent <TileController>().tileIndex] = null;
                Destroy(fullGrid[i, line].tileOnGridUnit);

                if (!curPC.AnyTilesLeft())
                {
                    Destroy(curPC.gameObject);
                }
            }
            fullGrid[i, line].tileOnGridUnit = null;
            fullGrid[i, line].isOccupied     = false;
        }
    }