Example #1
0
    Tile GenerateTileAt(int x, int y)
    {
        // Get the terrain type.
        TerrainType t = GenerateTerrainTypeAt(x, y);

        // Create the tile.
        Tile tile = new Tile(x, y, t);

        // Set the tile.
        tileMap.SetAt(x, y, tile);

        // Should a creature spawn here?
        if (GC.Chance(P_CREATURE_ON_TILE))
        {
            // Yes. Get which one from the tile type.
            CreatureType ct = t.GetRandomCreatureType();

            tile.entity = new Creature(ct, tile);
        }

        // Should an item spawn here?
        if (GC.Chance(P_ITEM_ON_TILE))
        {
            // Yes. Get which one from the tile type.
            ItemType it = t.GetRandomItemType();

            tile.storedItem = it;
        }

        // Return the tile.
        return(tile);
    }