// Use this for initialization void Start() { this.serialConn = new SerialConn(); this.networkConn = (NetworkConn)GameObject.Find("NetworkConnection").GetComponent <NetworkConn> (); this.clientNum = networkConn.getCleintNum(); serialConn.broadcastData(clientNum, "shipColor"); }
// Use this for initialization void Start() { /* * Testing playerpref */ PlayerPrefs.SetInt("clientNum", 3); PlayerPrefs.SetString("C1", "G"); PlayerPrefs.SetString("C2", "B"); PlayerPrefs.SetString("C3", "R"); print("GAME RULES: I = if T = then B = blue R = Red G = green Y = yellow"); this.serialConn = new SerialConn(); this.networkConn = (NetworkConn)GameObject.Find("NetworkConnection").GetComponent <NetworkConn> (); this.characters = new Dictionary <string, character> (); characterNum = PlayerPrefs.GetInt("clientNum"); for (int i = 0; i < characterNum; i++) { string charName = "C" + (i + 1); string shipColor = PlayerPrefs.GetString(charName); print(shipColor); GameObject shipPrefab = null; //Object shipPrefab = AssetDatabase.LoadAssetAtPath (prefabAddr, typeof(GameObject)); if (shipColor == "R") { shipPrefab = Rship; } else if (shipColor == "G") { shipPrefab = Gship; } else if (shipColor == "B") { shipPrefab = Bship; } else if (shipColor == "Y") { shipPrefab = Yship; } GameObject shipObject = (GameObject)Instantiate(shipPrefab, new Vector3(start.transform.position.x, start.transform.position.y, -1.7f), Quaternion.identity); character ship = shipObject.GetComponent <character>(); ship.start = start; ship.firstObstacle = firstPlanet; ship.finishObstacle = finishPlanet; ship.goal = goal; ship.name = charName; this.characters.Add(charName, ship); } foreach (character c in characters.Values) { c.setSerialConnection(this.serialConn); } serialConn.broadcastData(characterNum, "StartInput"); this.camera = GetComponent <Camera> (); }