public void SetTarget(GameObject target_) { CapitalShipScript CShip = transform.root.GetComponent <CapitalShipScript>(); if (target != null) { CShip.UnclaimTarget(target); } if (target_ != null) { CShip.ClaimTarget(target_); } target = target_; }
void Update() { if (volumeHolder != PlayerPrefs.GetFloat("MusicVolume")) { volumeHolder = PlayerPrefs.GetFloat("MusicVolume"); this.audio.volume = volumeHolder; } if (m_lossTimerBegin) { //Wait 5 seconds after sending loss state. If we haven't heard back from any clients by then, resend the loss state lossTimer += Time.deltaTime; if (lossTimer > 5.0f) { ResendLossState(); } } if (!m_gameStopped) { if (Network.isServer) { if (m_capitalDamageTimer < 5.0f) { m_capitalDamageTimer += Time.deltaTime; } //Purely related to enemy spawning if (m_shouldCheckForFinished && GameObject.FindGameObjectsWithTag("Enemy").Length == 0) { //No enemies left! AlertArenaIsClear(); } if (m_waveTimer < 45.0f) { m_waveTimer += Time.deltaTime; if (m_waveTimer >= 45.0f) { //Spawn next wave PlayerRequestsRoundStart(); } } } //Debug.Log ("[GSC]: Checking which dead players need to be updated"); //foreach(DeadPlayer deadP in m_deadPlayers) for (int i = 0; i < m_deadPlayers.Count; i++) { m_deadPlayers[i].m_deadTimer = Mathf.Max(0f, m_deadPlayers[i].m_deadTimer - Time.deltaTime); if (Network.isServer) { if (m_deadPlayers[i].m_deadTimer <= 0) { //Try to respawn the player CapitalShipScript cshipSc = m_ingameCapitalShip.GetComponent <CapitalShipScript>(); if (cshipSc.CShipCanAfford(500)) { //Debug.Log ("[GSC]: Player: " + m_deadPlayers[i].m_playerObject.m_name + " is respawning..."); //Spend the respawn cost cshipSc.SpendBankedCash(500); //Tell the NetworkPlayer to spawn a new ship for themselves //If the server is the dead one, then use the local version if (m_deadPlayers[i].m_playerObject.m_netPlayer == Network.player) { Debug.Log("Host respawned themselves."); SpawnAShip(Network.player); ChangeToInGame(); } else { Debug.Log("Telling remote player to respawn themselves."); networkView.RPC("SpawnAShip", m_deadPlayers[i].m_playerObject.m_netPlayer, m_deadPlayers[i].m_playerObject.m_netPlayer); networkView.RPC("ChangeToInGame", m_deadPlayers[i].m_playerObject.m_netPlayer); } //Remove them from the deadList networkView.RPC("PropagateNonDeadPlayer", RPCMode.Others, m_deadPlayers[i].m_playerObject.m_netPlayer); m_deadPlayers.RemoveAt(i--); } else { if (m_deadPlayers[i].m_needsChecking) { //Alert the GUI that there are insufficient funds to respawn, then stop checking if we can afford m_GUIManager.GetComponent <GUIManager>().AlertGUINoMoneyToRespawn(m_deadPlayers[i].m_playerObject.m_netPlayer); m_deadPlayers[i].m_needsChecking = false; } } } } } } }