void UpdateWave() { if (waveValues == null) { waveValues = FindObjectOfType <WaveValues>(); } uiWave.text = "Wave " + waveValues.waveNumber.ToString(); // Fade the wave part of the UI beetween waves if (!waveValues.isWaveActive) { if (uiWave.canvasRenderer.GetAlpha() <= minOpacity) { uiWave.CrossFadeAlpha(1, fadeDuration, true); } else if (uiWave.canvasRenderer.GetAlpha() >= 1) { uiWave.CrossFadeAlpha(minOpacity, fadeDuration, true); } } else if (waveValues.isWaveActive && uiWave.canvasRenderer.GetAlpha() < 1) { uiWave.CrossFadeAlpha(1, fadeDuration, true); } }
// Use this for initialization void Start() { waveValues = FindObjectOfType <WaveValues>(); spawnManager = FindObjectOfType <SpawnManager>(); scoreManager = FindObjectOfType <ScoreManager>(); navigationAgent = GetComponent <NavMeshAgent>(); // Prepare the initial position NavMeshHit closestHit; // Get the height of the agent Vector3 mobHeight = new Vector3(0, navigationAgent.height, 0); // Get the nearest valid position on the NavMesh if (NavMesh.SamplePosition(transform.position, out closestHit, 20, NavMesh.AllAreas)) { // Define the initial position transform.position = closestHit.position + mobHeight; } // Enabled the navigation agent navigationAgent.enabled = true; // Define the base target if (isServer) { SetDestination(); } }
// Use this for initialization void Start() { playerGun = GetComponent <Gun>(); playerAction = GetComponent <PlayerAction>(); playerHealth = GetComponent <HealthValues>(); waveValues = FindObjectOfType <WaveValues>(); scoreValues = FindObjectOfType <ScoreValues>(); }
// Use this for initialization void Start() { if (!isServer) { Destroy(this); } Debug.Log("Wave manager initialized..."); spawnManager = FindObjectOfType <SpawnManager>(); waveValues = FindObjectOfType <WaveValues>(); }
// Use this for initialization void Start() { if (!isServer) { Destroy(this); } waveManager = FindObjectOfType <WaveManager>(); waveValues = FindObjectOfType <WaveValues>(); // Get all the enemies spawn on the map foreach (Spawners spawn in FindObjectsOfType <Spawners>()) { spawners.Add(spawn); } }
private void OnDestroy() { Debug.Log("On destroy..."); WaveValues waveValues = FindObjectOfType <WaveValues>(); NetworkIdentity networkIdentity = GetComponent <NetworkIdentity>(); // Remove the information of the player if (waveValues != null && networkIdentity != null) { waveValues.RemovePlayer(networkIdentity); if (GetComponent <HealthValues>().isAlive) { waveValues.playerAlive--; } } }
// Update is called once per frame void Update() { if (waveValues != null) { // Check if the game is over if (waveValues.gameStatus != -1) { // Define on which camera the canvas have to be rendered endCanvas.worldCamera = Camera.current; // Fade in of the panel and its children if (endPanel.alpha < 1) { endPanel.alpha += fadeSpeed; } // Set the message to show switch (waveValues.gameStatus) { case 1: endMessage.text = winMessage; break; case 0: endMessage.text = loseMessage; break; } waittingTime += Time.deltaTime; // Check if the time passed on this screen has reached his end if (waittingTime >= waitBeforeLeaving) { // Leave the game FindObjectOfType <CustomNetworkManager>().LeaveGame(); Destroy(this); } } } else { waveValues = FindObjectOfType <WaveValues>(); } }
void AddPlayer() { WaveValues waveValues = FindObjectOfType <WaveValues>(); // Prepare the addition of the player WaveValues.PlayerInfo thisPlayer = new WaveValues.PlayerInfo(); // Add the NetID to the information of the player thisPlayer.playerNetID = GetComponent <NetworkIdentity>(); if (waveValues != null) { // Add the player to the global list of the players waveValues.AddPlayer(thisPlayer); } else { // Retry to add the player AddPlayer(); } }
// Use this for initialization void Start() { Debug.Log("Player initialized..."); // Get the default camera defaultCamera = Camera.main.gameObject; EnablePlayer(); waveValues = FindObjectOfType <WaveValues>(); if (!isServer) { return; } // Add the player to the global player list AddPlayer(); // Add a player to the player alive count waveValues.playerAlive++; }
// Use this for initialization void Start() { waveValues = FindObjectOfType <WaveValues>(); endCanvas = GetComponent <Canvas>(); }