void Update() { //initialize bord if data had recevied if (!bordInitialized) { foreach (Vector3 vec in walles) { Instantiate(wall, vec, initializingRotation); } foreach (Vector3 vec in stones) { Instantiate(stone, vec, initializingRotation); } foreach (Vector3 vec in waters) { Instantiate(water, vec, initializingRotation); } bordInitialized = true; } while (coinsToDraw.Count > 0) { CoinObject c = coinsToDraw[0]; coinsToDraw.RemoveAt(0); GameObject game = Instantiate(coin, c.getPosition(), initializingRotation) as GameObject; //Send data to coin. So that it can work independently later game.SendMessage("setValues", new int[] { c.getTimeLeft(), c.getCoinValue() }); UnityEngine.Debug.logger.Log("Coin " + c.getX() + "," + c.getY() + " " + c.getCoinValue() + " time" + c.getTimeLeft()); } while (healthToDraw.Count > 0) { HealthObject c = healthToDraw[0]; healthToDraw.RemoveAt(0); GameObject game = Instantiate(health, c.getPosition(), initializingRotation) as GameObject; //Send data to coin. So that it can work independently later game.SendMessage("setValues", c.getTimeLeft()); UnityEngine.Debug.logger.Log("Health " + c.getX() + "," + c.getY() + " time" + c.getTimeLeft()); } }
void Update() { if (!bordcreated) { foreach (Vector3 vec in wallList) { Instantiate(wall, vec, initializingRotation); } foreach (Vector3 vec in stoneList) { Instantiate(stone, vec, initializingRotation); } foreach (Vector3 vec in waterList) { Instantiate(water, vec, initializingRotation); } bordcreated = true; } while (coinsToDraw.Count > 0) { CoinObject c = coinsToDraw[0]; coinsToDraw.RemoveAt(0); GameObject game = Instantiate(coin, c.getPosition(), initializingRotation) as GameObject; game.SendMessage("setValues", new int[] { c.getTimeLeft(), c.getCoinValue() }); UnityEngine.Debug.logger.Log("Coin " + c.getX() + "," + c.getY() + " " + c.getCoinValue() + " time" + c.getTimeLeft()); } while (healthToDraw.Count > 0) { HealthObject c = healthToDraw[0]; healthToDraw.RemoveAt(0); GameObject game = Instantiate(health, c.getPosition(), initializingRotation) as GameObject; game.SendMessage("setValues", c.getTimeLeft()); UnityEngine.Debug.logger.Log("Health " + c.getX() + "," + c.getY() + " time" + c.getTimeLeft()); } while (toInstanciate.Count > 0) { //toInstanciate.RemoveAt(0); List <string> list = toInstanciate.Dequeue() as List <string>; String[] cod = list[1].ToString().Split(','); Vector3 pPosition = new Vector3(Int32.Parse(cod[0]), -Int32.Parse(cod[1])); Quaternion rotation = Quaternion.Euler(0, 0, 0); int pDirection = Int32.Parse(list[2].ToString()); if (pDirection == 0) { rotation = Quaternion.Euler(0, 0, 0); } if (pDirection == 1) { rotation = Quaternion.Euler(0, 0, -90); } if (pDirection == 2) { rotation = Quaternion.Euler(0, 0, 180); } if (pDirection == 3) { rotation = Quaternion.Euler(0, 0, 90); } /*if (list[0].ToString()=="P0") * { * if (!isInstanciate) * { * GameObject clone = (GameObject)Instantiate(player, pPosition, rotation); * //Destroy(clone, 1.25f); * isInstanciate = true; * } * }*/ if (list[0].ToString() == "P0") { GameObject clone = (GameObject)Instantiate(tank, pPosition, rotation); Destroy(clone, 1.25f); } if (list[0].ToString() == "P1") { GameObject clone = (GameObject)Instantiate(tank, pPosition, rotation); Destroy(clone, 1.25f); } if (list[0].ToString() == "P2") { GameObject clone = (GameObject)Instantiate(tank, pPosition, rotation); Destroy(clone, 1.25f); } if (list[0].ToString() == "P3") { GameObject clone = (GameObject)Instantiate(tank, pPosition, rotation); Destroy(clone, 1.25f); } if (list[0].ToString() == "P4") { GameObject clone = (GameObject)Instantiate(tank, pPosition, rotation); Destroy(clone, 1.25f); } if (list[0].ToString() == "P5") { GameObject clone = (GameObject)Instantiate(tank, pPosition, rotation); Destroy(clone, 1.25f); } } }