In the game I'm currently designing, I'm spawning enemies over time and after a certain amount of enemies are spawned/killed (or after a certain amount of rounds), I want the boss to spawn at the top of my screen. How can I enable this type of control? I can't seem to figure it out because I have two scripts set, one for the enemies and one for the boss. I'm unsure as to how to limit enemy spawning and ensure that my boss spawns. Here's the code for spawning enemies and then I'll also attach the code that is attached to my boss character -
Enemy Code:
//Round Implementation
var roundNumber : int; //If necessary
var roundStarted : boolean; //If necessary
var enemyLimit : int;
function spawnEnemy() {
yield WaitForSeconds(spawnTime);
if(spawning) {
return;
}
spawning = true;
//Instantiate Enemies
var seed = Random.Range(0, enemy.length);
var x = Random.Range(-4f, 2f);
Instantiate(enemy[seed], Vector3(x, 14f, 178f), transform.rotation) ;
yield WaitForSeconds(spawnTime);
spawning = false;
}
Boss Code:
var enemyControl : Enemy_Controls;
var msDestruction : GameObject;
var destructionSpawned : boolean;
var destructionDefeated : boolean;
var timesSpawned : int;
var destructionLives = 10;
function Start () {
enemyControl = gameObject.GetComponent("Enemy_Controls");
}
function Update () {
}
function spawnMsDestruction() {
//Access enemy controls in order to spawn the boss
destructionSpawned = true;
timesSpawned++;
var go: GameObject;
if(timesSpawned == 1) {
//Ms.Destruction will "run away"
}
if(timesSpawned == 2) {
//Ms.Destruction will "die"
}
}
↧