private void Start() { playerHealth = FindObjectOfType <HealthBarScript>(); //gets the player's health at game start budget = FindObjectOfType <MoneyMeterScript>(); originalNumberOfEnemies = numberOfEnemiesPerWave; Time.timeScale = 1; try { budget.ChangeMoney(startingCash); } catch { Debug.Log("MoneyMeterScript not present in scene."); } try { spawner = GameObject.Find("Spawn point").transform; } catch { Debug.Log("'Spawn point' not present or renamed."); } StartCoroutine(WavesSpawner()); }
// Use this for initialization void Start() { //finds a reference to the player's funds //this script could be improved to handle an exception if (moneyMeter == null) { moneyMeter = FindObjectOfType <MoneyMeterScript>(); } }
public int damageDoneAtGoal; //how much damage does the enemy do when it reaches the finish line void Start() { //at start, gets a reference to the attached object's components, the game manager, and the player's health and budget Animator = GetComponent <Animator>(); rb2D = GetComponent <Rigidbody2D>(); boxCollider2d = GetComponent <BoxCollider2D>(); moneyMeter = FindObjectOfType <MoneyMeterScript>(); healthBarScript = FindObjectOfType <HealthBarScript>(); gameManager = FindObjectOfType <GameManagerScript>(); currentWaypoint = gameManager.firstWaypoint; if (gameManager.waveNumber != 0 && gameManager.waveNumber % 4 == 0) //every 4 waves, increases enemy health by a fixed percentage { health = health * 1.2f; } if (gameManager.waveNumber != 0 && gameManager.waveNumber % 6 == 0) //every 6 waves gain additional speed and a minor health bonus { health = health * 1.2f; speed = speed * 1.1f; } }