private void CreatePlayer(string charName) { GameObject obj; obj = (GameObject)PhotonNetwork.Instantiate(charName, getPosChar(charName), Quaternion.identity, 0); obj.name = charName; SceneManager.MoveGameObjectToScene(obj, SceneManager.GetSceneByName("GameScene")); PhotonView view = obj.GetPhotonView(); view.RPC("DontDestroy", RpcTarget.AllBuffered); PhotonHashtable h = new PhotonHashtable(); h.Add("Type", charName); h.Add("Hours", 0); h.Add("DayIsEnded", false); h.Add("sp", 1); h.Add("wp", 7); h.Add("farmer", 0); h.Add("gold", 0); h.Add("deposit", 0); h.Add("wineskin", 0); h.Add("shield", 0); h.Add("falcon", 0); h.Add("bow", 0); h.Add("telescope", 0); h.Add("helm", 0); h.Add("brew", 0); h.Add("herb", false); h.Add("yellowStone", 0); h.Add("blueStone", 0); h.Add("greenStone", 0); PhotonNetwork.SetPlayerCustomProperties(h); PhotonNetwork.SetPlayerCustomProperties(h); this.addPlayerToList(charName); Hero myHero = obj.GetComponent <Hero>(); GameBoardRegion.setHero(myHero); GameObject o2 = (GameObject)PhotonNetwork.Instantiate(charName + "TimeTracker", new Vector3(-1.3f, 12.55f, 15), Quaternion.identity, 0); o2.name = charName + "TimeTracker"; SceneManager.MoveGameObjectToScene(o2, SceneManager.GetSceneByName("GameScene")); PhotonView v2 = o2.GetPhotonView(); v2.RPC("DontDestroy", RpcTarget.AllBuffered); myHero.timeTrackToken = o2.GetComponent <SpriteRenderer>(); }
private void CreatePlayer(string charName) { string str = ""; foreach (string s in data) { if (s.StartsWith(charName)) { str = s; break; } } char[] separator = { '\t' }; string[] arr = str.Split(separator); GameObject obj; Vector3 coords = GameBoardRegion.regionCoords[int.Parse(arr[1])]; obj = (GameObject)PhotonNetwork.Instantiate(charName, coords, Quaternion.identity, 0); obj.name = charName; SceneManager.MoveGameObjectToScene(obj, SceneManager.GetSceneByName("GameScene")); PhotonView view = obj.GetPhotonView(); view.RPC("DontDestroy", RpcTarget.AllBuffered); PhotonHashtable h = new PhotonHashtable(); h.Add("Type", charName); h.Add("pos", int.Parse(arr[1])); h.Add("Hours", int.Parse(arr[2])); h.Add("DayIsEnded", false); h.Add("sp", int.Parse(arr[4])); h.Add("wp", int.Parse(arr[3])); h.Add("farmer", int.Parse(arr[5])); h.Add("gold", int.Parse(arr[6])); h.Add("deposit", 0); h.Add("wineskin", int.Parse(arr[8])); h.Add("shield", int.Parse(arr[9])); h.Add("falcon", int.Parse(arr[10])); h.Add("bow", int.Parse(arr[12])); h.Add("telescope", int.Parse(arr[11])); h.Add("helm", int.Parse(arr[13])); h.Add("brew", int.Parse(arr[14])); h.Add("herb", bool.Parse(arr[7])); h.Add("yellowStone", int.Parse(arr[15])); h.Add("blueStone", int.Parse(arr[16])); h.Add("greenStone", int.Parse(arr[17])); PhotonNetwork.SetPlayerCustomProperties(h); this.addPlayerToList(charName); Hero myHero = obj.GetComponent <Hero>(); GameBoardRegion.setHero(myHero); float shift = 0; int hours = int.Parse(arr[2]); if (hours > 7) //account for uneven space between hour 7 and 8 { shift += 0.55f; } shift += 1.75f * hours; GameObject o2 = (GameObject)PhotonNetwork.Instantiate(charName + "TimeTracker", new Vector3(-1.3f + shift, 12.55f, 15), Quaternion.identity, 0); o2.name = charName + "TimeTracker"; SceneManager.MoveGameObjectToScene(o2, SceneManager.GetSceneByName("GameScene")); PhotonView v2 = o2.GetPhotonView(); v2.RPC("DontDestroy", RpcTarget.AllBuffered); myHero.timeTrackToken = o2.GetComponent <SpriteRenderer>(); int hrs = (int)PhotonNetwork.LocalPlayer.CustomProperties["Hours"]; Debug.Log("newHours: " + hrs); }