void Start() { FPSPlayerComponent = Camera.main.GetComponent <CameraControl>().playerObj.GetComponent <FPSPlayer>(); asource = gameObject.AddComponent <AudioSource>(); asource.spatialBlend = 0.0f; WaveText = FPSPlayerComponent.waveUiObj.GetComponent <WaveText>(); WaveTextShadow = FPSPlayerComponent.waveUiObjShadow.GetComponent <WaveText>(); //initialize health amounts on GUIText objects WaveText.waveGui = waveNumber; WaveTextShadow.waveGui = waveNumber; WaveText.waveGui2 = NpcsToSpawn - killedNpcs; WaveTextShadow.waveGui2 = NpcsToSpawn - killedNpcs; WarmupText = FPSPlayerComponent.warmupUiObj.GetComponent <WarmupText>(); WarmupTextShadow = FPSPlayerComponent.warmupUiObjShadow.GetComponent <WarmupText>(); tempColor = WarmupText.textColor; tempColor2 = WarmupTextShadow.textColor; WarmupText.warmupGui = countDown; WarmupTextShadow.warmupGui = countDown; WarmupUIText1 = WarmupText.GetComponent <Text>(); WarmupUIText2 = WarmupTextShadow.GetComponent <Text>(); warmupTextPos1Orig = WarmupUIText1.rectTransform.anchoredPosition; warmupTextPos2Orig = WarmupUIText2.rectTransform.anchoredPosition; StartCoroutine(StartWave()); }
protected void Awake() { gm = FindObjectOfType <GameManager>(); if (gm == null) { Debug.LogError($"{name}: cannot find game manager!"); } waveText = FindObjectOfType <WaveText>(); if (waveText == null) { Debug.LogError($"{name}: cannot find wave text!"); } waveCounter = FindObjectOfType <WaveCounter>(); if (waveCounter == null) { Debug.LogError($"{name}: cannot find wave counter!"); } if (LevelMap == null) { Debug.LogError($"{name}: No level map assigned!"); } // Register listeners GameStartEvent.RegisterListener(StartAssault); }
private void Update() { // Make sure all enemies are destroyed to start counting peace if (state == "peace" && GetEnemiesLeft() == 0) { peaceTimer += Time.deltaTime; if (firstPeace) { // Say wave is over firstPeace = false; Radar.DeclarePeace(); PeaceText.ShowPeaceText(peaceTimeMax); } } if (peaceTimer >= peaceTimeMax) { peaceTimer = 0f; enemiesWaveCounter = 0; state = "wave"; wave++; enemiesPerWave++; spawnTimer = 1f; // Start the wave a bit faster Radar.DeclareWave(); WaveText.ShowWaveText(wave); } if (state == "wave") { spawnTimer += Time.deltaTime; float difficulty = Mathf.Clamp(wave * 3f / 10f, 0f, 3.5f); if (spawnTimer >= spawnTimeMax - difficulty && enemiesWaveCounter < enemiesPerWave) { spawnTimer = 0f; int r = wave >= 3 ? Random.Range(0, 2) : 0; // First-Second wave only missiles if (r == 0) { Instantiate(MissilePrefab, GetRandomPosOut(), Quaternion.identity, GameManager.Instance.EnemiesHolder.GetChild(0)); } else { Instantiate(ShipPrefab, GetRandomPosOut(), Quaternion.identity, GameManager.Instance.EnemiesHolder.GetChild(1)); } enemiesWaveCounter++; if (enemiesWaveCounter == enemiesPerWave) // Go to peace if all enemies have been spawned { state = "peace"; firstPeace = true; } } } else if (state == "peace") { // Do nothing... let the player rebuild } }
void Start() { BuildFloor(boardSize); guards = FindObjectsOfType <Guard>(); goal = FindObjectOfType <Goal>(); wavesRemaining = maximumWaves; waveText = GameObject.Find("WaveCounter").GetComponent <WaveText>(); playerString = GameObject.FindGameObjectWithTag("string"); }
void Start() { FPSPlayerComponent = Camera.main.GetComponent <CameraControl>().playerObj.GetComponent <FPSPlayer>(); asource = gameObject.AddComponent <AudioSource>(); asource.spatialBlend = 0.0f; //create instance of GUIText to display health amount on hud waveGuiObjInstance = Instantiate(waveGuiObj, Vector3.zero, transform.rotation) as GameObject; //set reference for main color element of heath GUIText WaveText = waveGuiObjInstance.GetComponent <WaveText>(); //set reference for shadow background color element of GUIText //this object is a child of the main GUIText object, so access it as an array WaveText2 = waveGuiObjInstance.GetComponentsInChildren <WaveText>(); //initialize health amounts on GUIText objects WaveText.waveGui = waveNumber; WaveText2[1].waveGui = waveNumber; WaveText.waveGui2 = NpcsToSpawn - killedNpcs; WaveText2[1].waveGui2 = NpcsToSpawn - killedNpcs; //create instance of GUIText to display health amount on hud warmupGuiObjInstance = Instantiate(warmupGuiObj, Vector3.zero, transform.rotation) as GameObject; //set reference for main color element of heath GUIText WarmupText = warmupGuiObjInstance.GetComponent <WarmupText>(); //set reference for shadow background color element of GUIText //this object is a child of the main GUIText object, so access it as an array WarmupText2 = warmupGuiObjInstance.GetComponentsInChildren <WarmupText>(); tempColor = WarmupText.textColor; tempColor2 = WarmupText2[1].textColor; WarmupText.warmupGui = countDown; WarmupText2[1].warmupGui = countDown; WarmupGUIText1 = WarmupText.GetComponent <GUIText>(); WarmupGUIText2 = WarmupText2[1].GetComponent <GUIText>(); StartCoroutine(StartWave()); }