leeanneb / FruitSpace-Invaders

A space invaders game created by Unity. I created a spaceship which will be controlled by a user and it will have to hit all the aliens in the game to win. The spaceship can only move left and right and fire the bullets to the aliens. The aliens also will shoot the bullets to the space ship and the more the level goes up the more aliens will increase. When the aliens hit the spaceship, its health will decrease with -5, and when the health is 0, it will automaticly goes to the "Game Over". But when the user wins the game, it will goes in the "You Win".
0 stars 0 forks source link

When the Aliens are all hit, the next level does not work #2

Open leeanneb opened 11 years ago

leeanneb commented 11 years ago

Error: function Update () { if (GameObject.FindGameObjectsWithTag("alien").Length == 0) {

leeanneb commented 11 years ago

Fixed Error:

function Update () { if (GameObject.FindGameObjectsWithTag("alien").Length == 0) { // if aliens are all killed it will go to the next level NextLevel();

function NextLevel() { level++; //change level 2 switch (level) { case 2: score = 0; generateAliens(3, 6); // setting the aliens this.GetComponent(SwarmController).rightmargin = 3; //setting the border break; //change level 3 case 3: score = 0; generateAliens(5, 8); this.GetComponent(SwarmController).rightmargin = -1; break; case 4: //if the player passes the level it will go to the win page Application.LoadLevel(2); break; }

I added a function "NextLevel();" so that it will go to the next level when the aliens are all hit. In this function I am arranging the alein swarm ( increasing rows and coloms when it goes to another level) and setting the background and the margin.