public Text[] playerScoreHUDList, playerNamesHUDList; // these are the text-fields for each player's kills and name in the HUD panel. This is set from the editor void Start() { SpawnPoint[] allSpawners = FindObjectsOfType(typeof(SpawnPoint)) as SpawnPoint[]; //gets all the spawner scripts int playerCount = GameSparksManager.Instance().GetSessionInfo().GetPlayerList().Count; //gets the number of players #region Setup Players playerList = new Player_Master[playerCount];//create a list to store the player scripts Debug.Log("GC| Found " + playerList.Length + " Players..."); for (int i = 0; i < playerCount; i++) { Debug.Log("Player Counter " + i); for (int j = 0; j < allSpawners.Length; j++) { Debug.Log("Spawn Counter" + j); //if the spawner id and player id are the same, place the player here if (allSpawners[j].playerPeerId == GameSparksManager.Instance().GetSessionInfo().GetPlayerList()[i].peerID) { allSpawners[j].StartCountdown();//countdown to reset the spawner int tempPeerID = GameSparksManager.Instance().GetSessionInfo().GetPlayerList()[i].peerID; // if the current iteration is the player, set it up as the player. if (GameSparksManager.Instance().GetSessionInfo().GetPlayerList()[i].peerID == GameSparksManager.Instance().GetRTSession().PeerId) { //Creates the player GameObject newPlayer = Instantiate(playerPrefab, allSpawners[j].gameObject.transform.position, allSpawners[j].gameObject.transform.rotation) as GameObject; //Calls function to setup the player newPlayer.GetComponent <Player_Master>().Setup(allSpawners[j].gameObject.transform, true, tempPeerID); //Ensures Cameras are active newPlayer.transform.GetChild(0).gameObject.SetActive(true); //Set the players name newPlayer.name = GameSparksManager.Instance().GetSessionInfo().GetPlayerList()[i].peerID.ToString(); //Set the players parent newPlayer.transform.SetParent(this.transform); // add the new tank object to the corresponding reference in the list playerList[i] = newPlayer.GetComponent <Player_Master>(); } else { //Creates the enemy player GameObject enemyPlayer = Instantiate(enemyPrefabs[i], allSpawners[j].gameObject.transform.position, allSpawners[j].gameObject.transform.rotation) as GameObject; //Calls function to setup the enemy player enemyPlayer.GetComponent <Player_Master>().Setup(allSpawners[j].gameObject.transform, false, tempPeerID); //Set the enemy's name enemyPlayer.name = GameSparksManager.Instance().GetSessionInfo().GetPlayerList()[i].peerID.ToString(); //Set the enemy's parent enemyPlayer.transform.SetParent(this.transform); // add the new tank object to the corresponding reference in the list playerList[i] = enemyPlayer.GetComponent <Player_Master>(); } break; } } } #endregion }
//Sends a death notice to the player who died to tell them they died in on instance public void SendDeath() { using (RTData data = RTData.Get()) { GameSparksManager.Instance().GetRTSession().SendData(4, GameSparks.RT.GameSparksRT.DeliveryIntent.UNRELIABLE_SEQUENCED, data);// send the data } }