void OnEnemy(SocketIOEvent socketIOEvent) { print("An enemy"); string data = socketIOEvent.data.ToString(); print("your Enemy JSON data was recieved"); EnemyJSON currentEnemyJSON = EnemyJSON.CreateFromJSON(data); print("your JSON was created : " + data); Vector3 position = new Vector3(currentEnemyJSON.enemyPosition[0], currentEnemyJSON.enemyPosition[1], currentEnemyJSON.enemyPosition[2]); print("your name isssssssssssssssss "); Quaternion rotation = Quaternion.Euler(currentEnemyJSON.enemyRotation[0], currentEnemyJSON.enemyRotation[1], currentEnemyJSON.enemyRotation[2]); print("your name isssssssssssssssss "); GameObject p = Instantiate(enemyCube, position, rotation) as GameObject; EnemyCubeController pc = p.GetComponent <EnemyCubeController>(); Transform t = p.transform.Find("Healthbar Canvas"); Transform t1 = t.transform.Find("Player Name"); Text enemyName = t1.GetComponent <Text>(); enemyName.text = currentEnemyJSON.name; pc.isLocalEnemy = true; p.name = currentEnemyJSON.name; print("your enemy name is " + currentEnemyJSON.name); }
void OnEnemies(SocketIOEvent socketIOEvent) { EnemyJSON enemiesJSON = EnemyJSON.CreateFromJSON(socketIOEvent.data.ToString()); EnemySpawner es = GetComponent <EnemySpawner>(); es.SpawnEnemies(enemiesJSON); }
void OnOthersEnemy(SocketIOEvent socketIOEvent) { Debug.Log("Others Enemy is under ganarating....."); string data = socketIOEvent.data.ToString(); EnemyJSON enemyJSON = EnemyJSON.CreateFromJSON(data); Vector3 position = new Vector3(enemyJSON.enemyPosition[0], enemyJSON.enemyPosition[1], enemyJSON.enemyPosition[2]); Quaternion rotation = Quaternion.Euler(enemyJSON.enemyRotation[0], enemyJSON.enemyRotation[1], enemyJSON.enemyRotation[2]); GameObject o = GameObject.Find(enemyJSON.name) as GameObject; Debug.Log("enemyJSON : " + data + enemyJSON); if (o != null) { return; } GameObject oe = Instantiate(enemyCube, position, rotation) as GameObject; oe.name = enemyJSON.name; EnemyCubeController ecc = oe.GetComponent <EnemyCubeController>(); Health eh = oe.GetComponent <Health>(); eh.currentHealth = enemyJSON.health; ecc.isLocalEnemy = false; }