Exemplo n.º 1
0
Arquivo: Map.cs Projeto: Porkka/CDIO4
    void BuildMap()
    {
        // Setup Map
        this.mapWidth = ((this.maxRoomPosition + 1) * 32);
        this.mapHeight = ((this.maxRoomPosition + 1) * 32);

        // Get map's rooms, corridors, walls etc
        Map.data = this.GetMapData();

        // Use map's layout to render right prefabs
        Map.renderer = new MapRenderer(Map.data, this.mapWidth, this.mapHeight);
        //  TODO: Dynamic theme
        MapRenderer.MapTheme theme = MapRenderer.MapTheme.PIRATE;

        switch(gameLevel)
        {
            case 1:
            theme = MapRenderer.MapTheme.PIRATE;
                break;
            case 2:
                theme = MapRenderer.MapTheme.JUNGLE;
                break;
            case 3:
                theme = MapRenderer.MapTheme.DUNGEON;
                break;
        }

        Map.renderer.SetMapTheme(theme);
        // Instantiate prefabs
        Map.renderer.Render(this.transform);
        this.StartingTile = this._Rooms[Random.Range(0, this._Rooms.Count - 1)].CenterTile;
        // Setup Player
        this._setupPlayer();

        // Setup game assets like items, monsters / other npcs to a pool from which to draw from while spawning them to the map . Logic is n/y ?

        // Setup gameobjects - items
        // this._items = this.SetupItems();

        //this.SpawnPotions();
        //testiansa();

        // Setup gameobject - npcs
        // this._monsters = this.SetupMonsters();
        List<Object> tmp = new List<Object> ();

        string path = Map.renderer.ThemePath();
        tmp.Add(Resources.Load(path + "Enemy"));
        tmp.Add(Resources.Load(path + "obstacle"));
        //tmp.Add (Resources.Load("Dungeon/lvlpirate/Parrot"));
        //tmp.Add (Resources.Load("Enemy"));

        for (int i = 1; i < this._Rooms.Count ; i++) {
            Spawn s = new Spawn (this._Rooms [i], tmp);

            // HMMMH min and max must be associated with room sizes
            // HMMMH room can't be used as spawn point more than once
            s.MinSpawns = 1;
            s.MaxSpawns = 3;
            s.Release ();
        }

        tmp.Clear ();
        tmp.Add(Resources.Load(path + "Boss"));

        Spawn boss = new Spawn (this._Rooms [0], tmp);
        boss.MinSpawns = 0;
        boss.MaxSpawns = 0;
        boss.Release ();

        // Setup Boss

        // ============================================================

        // Spawn above items with some logic

        // Spawn.SpawnItems(this._monsters, rnd collection of rooms);
        // or
        // Spawn.SpawnItems(this._monsters, rnd collection of rooms);
        // Spawn.SpawnConsealedItems(this._monsters, rnd collection of rooms); // barrels, chests

        // Spawn enemies with some logic

        //Spawn.SpawnEnemies(this._monsters, rnd collection of rooms);
        // Enemies.StartRoaming();

        //Spawn.SpawnBoss(this.Boss, Room.BiggestRoom(this._Rooms))
    }