IEnumerator RespawnCoroutine(float spawnTime) { yield return(new WaitForSeconds(spawnTime)); messageWindow.SetActive(true); int playerIndex = Random.Range(0, playerModel.Length); int spawnIndex = Random.Range(0, spawnPoints.Length); player = PhotonNetwork.Instantiate(playerModel[playerIndex].name, spawnPoints[spawnIndex].position, spawnPoints[spawnIndex].rotation, 0); // sceneCamera.enabled = false; if (spawnTime == 0) { AddMessage("Player " + PhotonNetwork.LocalPlayer.NickName + " Joined the Ride again."); SPPlayer.SetActive(false); Destroy(SPPlayer); pairScreen.SetActive(true); // if (PhotonNetwork.IsMasterClient) // { // serverWindow.SetActive(true); // knockOutButton.SetActive(true); // } // knockOutManager.GetComponent<KnockoutModeManager>().AddRiders(); // Debug.Log("Knockout Adder12"); } else { AddMessage("Player " + PhotonNetwork.LocalPlayer.NickName + " Joined the Ride"); Destroy(SPPlayer); pairScreen.SetActive(true); RPS_Position posScript = (RPS_Position)player.GetComponent <RPS_Position>() as RPS_Position; Debug.Log("RPS AdderMM"); yield return(new WaitForSeconds(2.0f)); // test = player.GetComponent<PlayerTicket>(); // knockManagerList.players.Add(test); // Debug.Log("test"); /* knockOutManager.GetComponent<KnockoutModeManager>().AddRiders(); * Debug.Log("Knockout Adder"); * knockOutManager.GetComponent<KnockoutModeManager>().AddOthers(); * Debug.Log("Knockout Other"); */ // add the position to the storageScript if (!storageScript.positionScript.Contains(posScript)) { storageScript.positionScript.Add(posScript); } if (PhotonNetwork.IsMasterClient) { serverWindow.SetActive(true); // knockOutButton.SetActive(true); } } }
IEnumerator wait() { // adds delays between instantiating new AI players //if (!GetComponent<PhotonView>().IsMine) // { yield return(new WaitForSeconds(2)); RPS_Position posScript = (RPS_Position)otherplayer.GetComponent <RPS_Position>() as RPS_Position; Debug.Log("RPS Adder3"); // add the position to the storageScript if (!storageScript.positionScript.Contains(posScript)) { storageScript.positionScript.Add(posScript); } //} }
// Start is called before the first frame update void Start() { // RPS_Storage storageScript = GameObject.Find("RPS_Storage").GetComponent<RPS_Storage>(); storageScript = GameObject.Find("RPS_Storage").GetComponent <RPS_Storage>(); knockOutManager = GameObject.Find("KnockOutManager"); knockManagerList = GameObject.Find("KnockOutManager").GetComponent <KnockoutModeManager>(); if (!GetComponent <PhotonView>().IsMine) { Destroy(GetComponent <SplineFollower>()); Destroy(GetComponent <BicyclePowerSim>()); Destroy(GetComponent <BicycleSplineController>()); Destroy(GetComponent <WaypointProgressTracker>()); Destroy(GetComponent <EVP.VehicleCameraController>()); Destroy(GetComponent <BikeFrontLight>()); Destroy(GetComponent <AzureAudioDayNightController>()); // Destroy(GetComponent<RPS_Inspector>()); // Destroy(GetComponent<RPS_Position>()); // Destroy(GetComponent<RPS_Lap>()); // Destroy(GetComponent<RPS_LapUI>()); // Destroy(GetComponent<EndOfRace>()); Destroy(GetComponent <RPS_ScreenUI>()); tag = "OtherPlayer"; for (int i = 0; i < localScripts.Length; i++) { localScripts[i].enabled = false; } for (int i = 0; i < localObject.Length; i++) { localObject[i].SetActive(false); } smoothSync = GetComponent <SmoothSyncPUN2>(); if (smoothSync) { // Set up a validation method to check incoming States to see if cheating may be happening. smoothSync.validateStateMethod = validateStateOfPlayer; } // otherplayer = GameObject.FindGameObjectWithTag("OtherPlayer"); wait(); Debug.Log("Ok Wait 2 seconds!"); RPS_Position posScript = (RPS_Position)otherplayer.GetComponent <RPS_Position>() as RPS_Position; Debug.Log("RPS Adder2"); //Add the other Players to the List for Knockout test = GameObject.FindGameObjectWithTag("OtherPlayer").GetComponent <PlayerTicket>(); knockManagerList.players.Add(test); // knockManagerList.AddPlayerCount(); // Debug.Log("AddPlayerCount +1"); /* wait(); * for (int i = 0; i < knockManagerList.players.Count; i++) * { * if (knockManagerList.players[i] != null) * knockManagerList.playerCount += 1; * } */ //remove duplicates // knockManagerList.players = knockManagerList.players.Distinct().ToList(); Debug.Log("testOtherPlayerForKnockOutMode"); // knockOutManager.GetComponent<KnockoutModeManager>().AddOthers(); // Debug.Log("AddOtherNetWorkScript"); // add the position to the storageScript if (!storageScript.positionScript.Contains(posScript)) { storageScript.positionScript.Add(posScript); } } }