does this work?

This commit is contained in:
Bruno Rybársky 2022-04-27 19:22:52 +02:00
parent 259f9402e8
commit b23be2e477
2 changed files with 24 additions and 2 deletions

@ -5,8 +5,11 @@ using UnityEngine;
public class enemykiller : MonoBehaviour
{
// Start is called before the first frame update
//get textmeshpro text
public TextMeshProUGUI text;
public ParticleSystem part;
public List<ParticleCollisionEvent> collisionEvents;
public int score = 0;
void Start()
{
part = GetComponent<ParticleSystem>();
@ -30,11 +33,30 @@ public class enemykiller : MonoBehaviour
{
Destroy(other);
Debug.Log("enemy killed");
//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
enemyclone.name = "enemy" + i;
enemyclone.tag = "enemy";
//increase score
score++;
//update text
text.text = "Score: " + score;
}
if (other.tag == "king")
{
Destroy(other);
Debug.Log("killed king");
//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";
//decrease score
score-= 10;
//update text
text.text = "Score: " + score;
}
i++;
}

@ -17,7 +17,7 @@ public class spawner : MonoBehaviour
for (int i = 0; i < numenemies; i++)
{
//spawn enemy
GameObject enemyclone = Instantiate(enemy, new Vector3(Random.Range(5, 100), Random.Range(-70, -60), Random.Range(-100, 0)), Quaternion.identity);
GameObject enemyclone = Instantiate(enemy, new Vector3(Random.Range(10, 100), Random.Range(-70, -60), Random.Range(-90, 0)), Quaternion.identity);
//set enemy name
enemyclone.name = "enemy" + i;
enemyclone.tag = "enemy";
@ -26,7 +26,7 @@ public class spawner : MonoBehaviour
for (int i = 0; i < numkings; i++)
{
//spawn king
GameObject kingclone = Instantiate(king, new Vector3(Random.Range(5, 100), Random.Range(-70, -60), Random.Range(-100, 0)), Quaternion.identity);
GameObject kingclone = Instantiate(king, 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";