void Awake() { m_Pelagia = new Pelagia(); m_Pelagia.Init("./3drpg2.json"); InitMsg im = new InitMsg(); im.cmd = "init"; im.global_x = columns; im.global_y = rows; string json = JsonUtility.ToJson(im); m_Pelagia.Call("manager", json); name_obj = new Dictionary <string, GameObject>(); }
void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); GameObject go = GameObject.FindGameObjectWithTag("Player"); player = go.GetComponent <Player>(); m_Pelagia = new Pelagia(); m_Pelagia.Init("./rpg.json"); InitMsg im = new InitMsg(); im.global_x = columns; im.global_y = rows; im.view_x = viewColumns; im.view_y = viewRows; im.npc_count = enemyCount; im.wall_count = wallCount; im.food_count = foodCount; string json = JsonUtility.ToJson(im); m_Pelagia.Call("init", json); //Call the InitGame function to initialize the first level InitGame(); }