void Spawn() { // If the player has no health left... if (playerHealth.currentHealth <= 0f) { // ... exit the function. return; } if (Amount > 0) { // Find a random index between zero and one less than the number of spawn points. int spawnPointIndex = Random.Range(0, spawnPoints.Length); // Create an instance of the enemy prefab at the randomly selected spawn point's position and rotation. GameObject SpawnedEnemy = Instantiate(enemy, spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation); Main = SpawnedEnemy.GetComponent <EnemyMain>(); Main.StartingHP = Mathf.RoundToInt(Main.StartingHP * HpModifier); Main.CurrentHP = Main.StartingHP; Main.AttackDMG = Mathf.RoundToInt(Main.AttackDMG * DamageModifier); Main.XPValue = Mathf.RoundToInt(Main.XPValue * XPModifier); Amount--; RefreshNumbers(); } RefreshAmount(); }
void Awake() { render = GetComponent <MeshRenderer>(); main = GetComponentInParent <EnemyMain>(); }