void onStart(SocketIOEvent e) { statusGame = STARTING; Debug.Log("Starting Game"); Debug.Log(e.data.ToString()); JSONObject[] itemList = e.data.GetField("data").GetField("items").list.ToArray(); Debug.Log(itemList); MapGenerator mapGen = map.GetComponent <MapGenerator> (); mapGen.GenerateMap(); Debug.Log("Generate Randomizer"); PositionRandomizer randomizer = map.GetComponent <PositionRandomizer> (); ItemsGenerator itemsGen = items.GetComponent <ItemsGenerator> (); itemsGen.GenerateItems(randomizer, itemList); EnvironmentGenerator enviGen = environment.GetComponent <EnvironmentGenerator> (); enviGen.GenerateEnvironment(randomizer); player.transform.position = randomizer.RandomPosition(PositionRandomizer.PLAYER); EnemyManager enemyManager = enemies.GetComponent <EnemyManager> (); enemyManager.CreateEnemyManager(randomizer); socket.Emit("GAME_STATUS_READY"); }
public void GenerateItems(PositionRandomizer randomizer, JSONObject[] items) { for (int i = 0; i < items.Length; i++) { string temp = items [i].ToString(); Debug.Log("temp: " + temp); string item = temp.Substring(1, temp.Length - 2); Debug.Log("item: " + item); if (item.Equals("KEY")) { Debug.Log("add key"); Instantiate(key, randomizer.RandomPosition(PositionRandomizer.ITEM), Quaternion.identity); } else if (item.Equals("DOOR")) { Debug.Log("add door"); Instantiate(door, randomizer.RandomPosition(PositionRandomizer.ITEM), Quaternion.identity); } } }
void Create(GameObject obj) { var rotation = Quaternion.Euler(0, Random.Range(0, 360), 0); Instantiate(obj, randomizer.RandomPosition(PositionRandomizer.MONSTER), rotation); }