I am trying to make a survival game where each enemy I kill I get one added to my score. After I get to 10 my enemies “Level up” and I get 2 added to my score with them getting 50 more health. Here is my code for my score:
#pragma strict
static var scores: int = 0;
function OnGUI() {
GUI.Box(Rect(1, 1, 100, 20), "Score:" + scores);
}
function Update(){
if (scores == 10);{
EnemyHealth.levelUp += 1;
}
}
and for my enemies:
#pragma strict
var enemyHealth: int = 100;
static var levelUp: int = 0;
static var scoreUp: int = 1;
function Update(){
if (enemyHealth <= 0){
Destroy(gameObject);
Score.scores += scoreUp;
}
if (levelUp == 1){
enemyHealth += 50;
scoreUp += 1;
}
}
The problem I am having is that the first enemy that spawns(I am using one prefab and one spawnpoint) has the 150 health and adds two to my score and after that they keep adding two instead of one. When I get to ten it doesn’t add any to the health or the scoreUp. Please help. Thanks in advance =)