highlighted enemies
fixed flamethrower added lives
This commit is contained in:
@@ -39,7 +39,12 @@ public class dragoncontrols : MonoBehaviour
|
||||
//control flames
|
||||
if (flamethrover)
|
||||
{
|
||||
flames.Play();
|
||||
//if not playing
|
||||
if (!flames.isPlaying)
|
||||
{
|
||||
//play flames
|
||||
flames.Play();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -12,6 +12,8 @@ public class enemykiller : MonoBehaviour
|
||||
public ParticleSystem part;
|
||||
public List<ParticleCollisionEvent> collisionEvents;
|
||||
public int score = 0;
|
||||
public int highscore = 0;
|
||||
public int lives = 3;
|
||||
void Start()
|
||||
{
|
||||
part = GetComponent<ParticleSystem>();
|
||||
@@ -31,10 +33,16 @@ public class enemykiller : MonoBehaviour
|
||||
while (i < numCollisionEvents)
|
||||
{
|
||||
GameObject other = collisionEvents[i].colliderComponent.gameObject;
|
||||
//check if object exists
|
||||
if (other == null)
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (other.tag == "enemy")
|
||||
{
|
||||
Destroy(other);
|
||||
Debug.Log("enemy killed");
|
||||
Debug.Log("enemy killed (" + other.name+ ")");
|
||||
//spawn new enemy
|
||||
GameObject enemyclone = Instantiate(other, new Vector3(Random.Range(10, 100), Random.Range(-70, -60), Random.Range(-90, 0)), Quaternion.identity);
|
||||
//set enemy name
|
||||
@@ -42,23 +50,35 @@ public class enemykiller : MonoBehaviour
|
||||
enemyclone.tag = "enemy";
|
||||
//increase score
|
||||
score++;
|
||||
if (score > highscore)
|
||||
{
|
||||
highscore = score;
|
||||
}
|
||||
//update text
|
||||
text.text = "Score: " + score;
|
||||
|
||||
text.text = "Score: " + score + "\nHighscore: " + highscore + "\nLives: " + lives;
|
||||
}
|
||||
if (other.tag == "king")
|
||||
{
|
||||
Destroy(other);
|
||||
Debug.Log("killed king");
|
||||
Debug.Log("killed king" + other.name);
|
||||
//spawn new king
|
||||
GameObject kingclone = Instantiate(other, new Vector3(Random.Range(10, 100), Random.Range(-70, -60), Random.Range(-90, -20)), Quaternion.identity);
|
||||
//set king name
|
||||
kingclone.name = "king" + i;
|
||||
kingclone.tag = "king";
|
||||
GameObject kingclone2 = Instantiate(other, new Vector3(Random.Range(10, 100), Random.Range(-70, -60), Random.Range(-90, -20)), Quaternion.identity);
|
||||
//set king name
|
||||
kingclone2.name = "kingy" + i;
|
||||
kingclone2.tag = "king";
|
||||
//decrease score
|
||||
score-= 10;
|
||||
score-= 20;
|
||||
lives--;
|
||||
if (lives <= 0)
|
||||
{
|
||||
text.text = "GAME OVER";
|
||||
}
|
||||
//update text
|
||||
text.text = "Score: " + score;
|
||||
text.text = "Score: " + score + "\nHighscore: " + highscore + "\nLives: " + lives;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user