Spawning Zombies Different Rounds

Ok so i wanna make a zombie game kinda of like in CoD black ops. So i want the zombies to spawn in only the room the player is in. So say in room 1 and the other doors are closed right, so the zombies only spawn in that room. Once you open a door zombies can spawn from the room as well. And for each round the numbers increase like round 1 there are only 10 zombies round 2 20 zombies and in round 3 is 30. So for each round multiply by 10. So i need help with that please. Dont say go to the forums or telling me to put down a script. If you would like to help more your name will be in the credits.

+1 to trolling.

2 Answers

2

Not quite clear what you’re asking. But if you need an outline, here it is:

- create an enemy spawn script with a public parameter 'round' and a private parameter 'zombiesperround'
 - attach the enemy spawn script to an empty gameobject in your zone
 - create an empty gameobject (call it zonespawn) and place it in your zone.
 - attach a zone wide trigger or another proper trigger (like 'dooropen') to zonespawn.
 - attach the enemy spawn script to zonespawn
 - use OnTriggerEnter in zonespawn to call your enemy spawn script.

Voila.

I times zombies per round * round so part of code not completely working spawns 55 zombies for some reason.
var zombiePrefab : GameObject;
var zombieSpawned : int;
var player : GameObject;
var spawn : boolean;
var minWait : int;
var maxWait : int;
var waitTime : int;
var zombiesperround : int = 3;
var round : int = 1;
var roundclock : GUIText;

function Start () 
{
	minWait = 60;
	maxWait = 120;
	waitTime = Random.Range(minWait, maxWait);
	spawn = true;
}

function Update () 
{
roundclock.text = ""+round;
zombiesperround = zombiesperround * round;
	if(spawn)
	{
		Spawn();
	}
}
function Spawn ()
{
if (zombiesperround > 0)
	{
		yield WaitForSeconds(1);
		Instantiate(zombiePrefab, transform.position, transform.rotation);
		zombieSpawned +=1;
		zombiesperround --;
		waitspawn();
	}
else
	{
	if (zombieSpawned == 0)
		{
			round ++;
			spawn = false;
			SetSpawn();
		}
	}
}
function SetSpawn ()
{
	yield WaitForSeconds(waitTime);
	spawn = true;
}
function NewWaitTime()
{
waitTime = Random.Range(minWait, maxWait);
}
function waitspawn()
{
	yield WaitForSeconds(1);
	spawn = true;
}