コード例 #1
0
    /*private void Create_Bonus(s_Tiles hitTileCache)
     * {
     *  GameObject Bonus = Instantiate(GetBonusType(hitTileCache.Type), BottomRight
     + new Vector2(hitTileCache.column * TileSize.x,
     +          hitTileCache.row * TileSize.y), Quaternion.identity) as GameObject;
     +
     +  tiles[hitTileCache.row, hitTileCache.column] = Bonus;
     +  var BonusShape = Bonus.GetComponent<s_Tiles>();
     +
     +  BonusShape.Assign_Card(hitTileCache.Type, hitTileCache.row, hitTileCache.column);
     +
     +  BonusShape.Card |= s_CardType.RemoveWholeRowColumn;
     + }*/

    private s_MovedTileInfo Create_New_Tile_In_Specific_Columns(IEnumerable <int> columnsWithMissingTiles)
    {
        s_MovedTileInfo newTileInfo = new s_MovedTileInfo();


        foreach (int column in columnsWithMissingTiles)
        {
            var emptyItems = tiles.Get_Empty_Items_On_Column(column);
            foreach (var item in emptyItems)
            {
                var        go      = Get_Random_Tile();
                GameObject newTile = Instantiate(go, SpawnPositions[column], Quaternion.identity)
                                     as GameObject;

                newTile.GetComponent <s_Tiles>().Assign_Card(go.GetComponent <s_Tiles>().Type, item.Row, item.Column);

                if (s_Constants.rows - item.Row > newTileInfo.maxMoveDistance)
                {
                    newTileInfo.maxMoveDistance = s_Constants.rows - item.Row;
                }

                tiles[item.Row, item.Column] = newTile;
                newTileInfo.Add_Tile(newTile);
            }
        }
        return(newTileInfo);
    }
コード例 #2
0
    public s_MovedTileInfo Collapse(IEnumerable <int> columns)
    {
        s_MovedTileInfo collapseInfo = new s_MovedTileInfo();

        foreach (var column in columns)
        {
            for (int row = 0; row < s_Constants.rows - 1; row++)
            {
                if (tilesA[row, column] == null)
                {
                    for (int row2 = row + 1; row2 < s_Constants.rows; row2++)
                    {
                        if (tilesA[row2, column] != null)
                        {
                            tilesA[row, column]  = tilesA[row2, column];
                            tilesA[row2, column] = null;

                            if (row2 - row > collapseInfo.maxMoveDistance)
                            {
                                collapseInfo.maxMoveDistance = row2 - row;
                            }

                            tilesA[row, column].GetComponent <s_Tiles>().row    = row;
                            tilesA[row, column].GetComponent <s_Tiles>().column = column;

                            collapseInfo.Add_Tile(tilesA[row, column]);
                            break;
                        }
                    }
                }
            }
        }
        return(collapseInfo);
    }