public void ClearLevel()
 {
     Grid.ClearTiles();
     Grid.worldsize.x = wordsiz_temp.x;
     Grid.worldsize.y = wordsiz_temp.y;
     Grid.Initialize(z_depth);
 }
Exemple #2
0
    void LoadLevel()
    {
        Player.worldpos = new Vector3Int(
            last_player_pos.x * Grid.GetNodeLength,
            last_player_pos.y * Grid.GetNodeLength,
            last_player_pos.z * Grid.GetNodeLength);
        data_level dat = levels[currentLevNum];

        Grid.ClearTiles();
        Grid.worldsize = new Vector3Int(dat.size_x, dat.size_y, 45);
        Grid.Initialize();

        for (int x = 0; x < Grid.worldsize.x - 1; x++)
        {
            for (int y = 0; y < Grid.worldsize.y - 1; y++)
            {
                for (int z = 0; z < Grid.worldsize.z - 1; z++)
                {
                    data_level.data_block blok = dat.blocks.Find(bl => bl.x == x && bl.y == y && bl.z == z);
                    data_level.data_door  dr   = dat.doors.Find(bl => bl.x == x && bl.y == y && bl.z == z);
                    data_level.data_item  it   = dat.items.Find(bl => bl.x == x && bl.y == y && bl.z == z);

                    if (blok != null)
                    {
                        o_block block = Grid.SpawnObject(blok.name, new Vector3Int(x, y, z));
                    }

                    if (dr != null)
                    {
                        o_block block = Grid.SpawnObject(dr.name, new Vector3Int(x, y, z));

                        o_door door = block.GetComponent <o_door>();
                        door.location             = dr.lev;
                        door.teleport_position    = new Vector3Int(dr.tele_x, dr.tele_y, dr.tele_z);
                        door.locked               = dr.locked;
                        door.required_waterstones = dr.require;
                        door.DOOR_STATE           = (o_door.DOOR_MODE)dr.doortype;
                    }
                    if (it != null)
                    {
                        o_block block = Grid.SpawnObject(it.name, new Vector3Int(x, y, z));
                        o_item  item  = block.GetComponent <o_item>();
                        item.item = it.item;
                    }
                }
            }
        }
    }