// Use this for initialization void Start() { p_sprite = player.GetComponentInChildren <SpriteRenderer>(); path = new Stack <MapTile>(); anim = false; pos_x = init_x; pos_y = init_y; metEnemy = false; GlobalControl gc = GameObject.Find("GlobalControl").GetComponent <GlobalControl>();//find the GlobalControl object SceneInfo_dungeon si = (SceneInfo_dungeon)gc.sceneInformation; Debug.Log("Load Scene"); if (si == null)//if there is no scene information (it might means this scene is first loaded) { Debug.Log("no scene information"); enemies = new List <Enemy_map>(); enemies.Add(new Enemy_map(10, 15)); enemies.Add(new Enemy_map(4, 5)); enemies.Add(new Enemy_map(1, 7)); } else//if there is scene information { loadInfo_dungeon(si); Debug.Log("loaded"); } player.transform.Translate(new Vector2(start_x + w * (float)pos_x, start_y + h * (float)pos_y) - new Vector2(player.transform.position.x, player.transform.position.y)); syncCamera(); generateMap(); setEnemies(); }
public void loadEncounter() { string curName = SceneManager.GetActiveScene().name; //saves current scene information GlobalControl gc = GameObject.Find("GlobalControl").GetComponent <GlobalControl>(); SceneInfo_dungeon curscene = new SceneInfo_dungeon(); curscene.pos_x = pos_x; curscene.pos_y = pos_y; curscene.enemies = enemies; gc.scenes.Push(curscene); SceneInfo_encounter nsi = new SceneInfo_encounter(); nsi.monsters = encounter.monsters; gc.sceneInformation = nsi; gc.save(); SceneManager.LoadScene("encounter"); }
public void loadInfo_dungeon(SceneInfo_dungeon info) { pos_x = info.pos_x; pos_y = info.pos_y; enemies = info.enemies; }