Need help with spawn mobs in level.

hi all, need some help with this code, it is necessary that every fifth wave appeared boss. And so with each level increased health and armor mobs 0.2%. Thank you all.

using UnityEngine;
using System.Collections;

public class GamePlayManager : MonoBehaviour {

//Zombie objects
public GameObject zombieA; //we can have as many zombies as we want
public GameObject zombieBoss;

//Spawn Control
GameObject zombieSpawn;
Vector3 spawnPosition; //where zombie should spawn from

public int zombieMin = 1; //zombie spawning amount control in a specific range
public int zombieMax = 5;
int zombieLeft;
int currentZombieAmount;

//Wave Control
int waveCounter = 0; // to know whats the current wave
public float waveSpawnTimeInterval = 5.0f; //control the intercal time in between two waves
float timer;
public int maxWaves = 3; // control the max waves we want in a level

public float spawnTimeControl;
float spawnTimeTemp;
float currentSpawnTimeLeft;

void Start () {
//find the spawner in the scene, also tell unity where to spawn zombies
zombieSpawn = GameObject.Find(“Spawner”);
spawnPosition = zombieSpawn.transform.position; //assign the spawn objects position to new var

//initial swapning
currentZombieAmount = Random.Range (zombieMin, zombieMax);
zombieLeft = currentZombieAmount;
Debug.Log (“currentZombieAmount” + currentZombieAmount);
Debug.Log (“current wave:” + (waveCounter + 1)); //because count from 0
}

// Update is called once per frame
void Update () {
//ToDoc

if (zombieLeft <= 0) //check if current wave spawned all of zombies
{
//reset the spawn time for the wave spawning
timer = waveSpawnTimeInterval;

if (waveCounter == maxWaves - 1) //—check if current wave is the last wave, then we spawn last zombie, Boss
{
zombieLeft = 1; //we make the last wave can only spawn one zombie which is the Boss
}
//if not last wave, we keep swapning zombies
else if (waveCounter < maxWaves) //–and zombie amount that we want to spawn in the next wave
{
//keep spawning by waves
currentZombieAmount = Random.Range (zombieMin, zombieMax);
zombieLeft = currentZombieAmount;
}
}
else //check if still need to spawn zombies, keep spawinig
{
if(waveCounter < maxWaves && zombieLeft >0)
{
timer = timer - Time.deltaTime;

if((waveCounter == maxWaves - 1) && timer <= 0)
{
//spawn boss
spawnController(selectZombie(1));
}
else if (timer <=0)
{
//spawn other zombiers
spawnController(selectZombie(2));
}
}
}
//spawnController ();
}

//control spawn amount in each wave
void spawnController(GameObject zombie)
{
//add cool down function to avoid spawn zombies one by one
currentSpawnTimeLeft = Time.time - spawnTimeTemp;
if (currentSpawnTimeLeft >= spawnTimeControl)
{
if(zombieLeft > 0)
{
Instantiate (zombie, spawnPosition, Quaternion.identity);

//reset timer
spawnTimeTemp = Time.time; //reset timer
currentSpawnTimeLeft = 0;

zombieLeft–;
if (zombieLeft == 0) waveCounter++;
}
}
}

//allows to auto select regular zombie or the boss
GameObject selectZombie(int n) // return a GameObject
{
GameObject zombieType = null; //inititialize the return value
switch (n)
{
case 1:
zombieType = zombieBoss;
break;
case 2:
zombieType = zombieA;
break;
}

return zombieType;
}
}

Hi,

  1. Post scripting questions in the Scripting forum.

  2. Please use code tags.

  3. Since this is in the Asset Store forum, you may be interested in using a popular asset built for this purpose, Core GameKit.

i ask help with script. i dont need buy Gamekit