public void BootstrapPlayer() { myPlayerData = new PlayerDescriptor(); myPlayerData.GenerateNewGuid(); TTManager.instance.myPlayers.Add(this); Debug.Log("New player with name: " + myPlayerData.playerName); //TODO: make this better //transform.FindChild("Canvas/Name").GetComponent<Text>().text = "name: " + myPlayerData.playerName; //TODO: might replace ttdockzone with throwzone for consistency myDockZone = GetComponent <TTDockZone> (); myDockZone.myPlayer = this; myDockZone.UpdateDock(); foreach (TargetZone tz in myTargetZones) { tz.SetOwner(this); //tz.BroadcastToHH (); //broadcasting happens during tether phase } //GameManager.instance.SendPlayerDockStatus (myPlayerData); UpdateHHPlayerDesc(); }
// DELEAGTES //========== void OnSeatRequestMesage(JSONObject message) { Debug.Log("OnSeatRequestMessage: " + message.ToString()); bool seatWasGranted = message.GetField("granted").b; PlayerDescriptor playerInfo = new PlayerDescriptor(message.GetField("data")); // if seat granted if (seatWasGranted) { Debug.Log("setting player"); // TODO INSTANTIATE PLAYER & DOCK //GameObject newPlayer = Instantiate(); //myPlayer = newPlayer.GetComponent<HHPlayer>(); //myPlayer.BootstrapPlayer(playerInfo); playerSeated = true; // update name in player settings GameViewManager.instance.playerInfoView.SendMessage("OnSeatGranted", playerInfo); // update name in footer bar GameViewManager.instance.footerPanel.SendMessage("UpdatePlayerInfo", playerInfo); } }
// SEATING PROCESS //================ public void RequestSeatForPlayer(PlayerDescriptor selectedPlayer) { Debug.Log("selecting this player" + selectedPlayer); Debug.Log("complete information around this player: " + new JSONObject(JsonUtility.ToJson(selectedPlayer)).ToString()); NetworkingManager.instance.RequestSeat(selectedPlayer); }
//anytime the TTPlayer receives info from HH about itself, it updates itself void PlayerDescriptorFunction(JSONObject data) { PlayerDescriptor playerData = new PlayerDescriptor(data); if (playerData.playerGuid == myPlayerData.playerGuid) { //Debug.Log ("this is data meant for us!"); myPlayerData = playerData; //sets our new name or victory points or whatever myDockZone.UpdateDock(); } }
//called when player selects their seat public void BootstrapPlayer(PlayerDescriptor thisPlayersData) { myPlayerData = thisPlayersData; foreach (TargetZone tz in myTargetZones) { tz.SetOwner(this); } //SendPlayerDescriptor (); SendTargetZoneDescriptors(); }