void spawnSingleCreep(int wave) { // spawn creep at index (wave mod (however many creeps i have - 1)) // spawn creep at wheretospawn. // add creep to list of active creeps // If we start repeating the same enemies then we need to start incrimenting their health higher and higher. this is where that should be done GameObject x = Instantiate(creeps[wave % numberOfUniqueCreepTypes], whereToSpawn.position, whereToSpawn.rotation) as GameObject; CM.addCreepToActiveList(x); Creep creep = x.GetComponent <Creep>(); CreepNav creepNav = x.GetComponent <CreepNav>(); if (creep != null) { creep.SetHealth(wave * creep.healthIncrement); creep.SetMaxHealth(creep.GetHealth()); creep.SetSpeed(Random.Range(-1, 1)); creep.corners = movePointsforCreeps; } if (creepNav != null) { creepNav.SetHealth(wave * creepNav.healthIncrement); creepNav.SetMaxHealth(creepNav.GetHealth()); creepNav.SetSpeed(Random.Range(-1, 1)); creepNav.corners = movePointsforCreeps; } x.name = "Goblin" + names.ToString(); names++; }
void Update() { if (creep != null) { health.minValue = 0f; health.maxValue = (float)creep.GetMaxHealth(); health.value = (float)creep.GetHealth(); } if (creepNav != null) { health.minValue = 0f; health.maxValue = (float)creepNav.GetMaxHealth(); health.value = (float)creepNav.GetHealth(); } }