Beispiel #1
0
    private bool isMoveEligible(VOTile tileToMove, int rowSpeed, int columnSpeed)
    {
        bool ret = (tileToMove.row + rowSpeed < NumRows) &&
                   (tileToMove.row + rowSpeed >= 0) &&
                   (tileToMove.column + columnSpeed < NumColumns) &&
                   (tileToMove.column + columnSpeed >= 0);

        return(ret);
    }
Beispiel #2
0
    private bool tilesCanMerge(VOTile tile1, VOTile tile2)
    {
        if ((tile1.value == tile2.value && (tile2.value >= 3 && tile1.value >= 3)) ||
            (tile1.value != tile2.value && (tile2.value < 3 && tile1.value < 3)) ||
            (tile1.value < 0) || (tile2.value < 0))
        {
            return(true);
        }

        return(false);
    }
Beispiel #3
0
    //spawns a specific number of tiles (and returns them to the board behaviour script)
    public List <VOTile> SpawnTiles(int numTilesToAdd)
    {
        List <VOTile> ret = new List <VOTile> ();

        int i;
        int randomRow;
        int randomColumn;
        int randomTilePoolIndex;

        for (i = 0; i < numTilesToAdd && tiles.Count < NumRows * NumColumns; i++)
        {
            do
            {
                randomRow    = Mathf.FloorToInt(UnityEngine.Random.Range(0, NumRows));
                randomColumn = Mathf.FloorToInt(UnityEngine.Random.Range(0, NumColumns));
            }while(getTileAt(randomRow, randomColumn) != null);

            randomTilePoolIndex = 1;

            if (UnityEngine.Random.value < ChanceToSpawnTwo)
            {
                randomTilePoolIndex = 2;
            }

            if (UnityEngine.Random.value < ChanceToSpawnThree)
            {
                randomTilePoolIndex = 3;
            }

            var newTile = new VOTile(randomRow, randomColumn, randomTilePoolIndex);

            //chance to get a joker
            if (UnityEngine.Random.value < ChanceToSpawnJoker)
            {
                newTile.value = -1;
            }

            tiles.Add(newTile);
            ret.Add(newTile);
        }

        return(ret);
    }