Пример #1
0
    /**
     * Generates single-tile background objects
     * Mushrooms have a 10% chance of spawning. Everything else is 90%
     * @param x - coordinate for row in grid
     * @param y - coordinate for column in grid
     */
    private void genSingle(int x, int y)
    {
        if (chanceSpawn(5))
        {
            int index;

            if (chanceSpawn(10))
            {
                index = (int)SingleCell.mushroom;
            }
            else
            {
                index = (int)Random.Range((float)SingleCell.bgGrass1, (float)SingleCell.bgGrass2 + 1);
            }
            Sprite  spriteToPlace = room.getSpriteAtIndex(index);
            Cell    cellToPlace   = room.getCellAtCoord(x, y + 1);
            Vector3 position      = roomPosition + room.GetWorldPosition(x, y + 1) + new Vector3(room.getCellSize(), room.getCellSize());

            cellToPlace.placeBGTile(position, spriteToPlace);
        }
    }