updated to 0.0.2

This commit is contained in:
Bruno Rybársky 2022-04-28 20:33:56 +02:00
parent 169dd3f24c
commit d98fbf5501
3 changed files with 26 additions and 37 deletions

@ -154,8 +154,8 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
enemy: {fileID: 636916275} enemy: {fileID: 636916275}
king: {fileID: 758130062} king: {fileID: 758130062}
numkings: 16 kings_modulo: 4
numenemies: 90 numenemies: 300
--- !u!4 &18701317 --- !u!4 &18701317
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -8192,7 +8192,7 @@ MonoBehaviour:
part: {fileID: 1570390066} part: {fileID: 1570390066}
score: 0 score: 0
highscore: 0 highscore: 0
lives: 3 lives: 12
--- !u!1 &1581468909 --- !u!1 &1581468909
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -13,7 +13,7 @@ public class enemykiller : MonoBehaviour
public List<ParticleCollisionEvent> collisionEvents; public List<ParticleCollisionEvent> collisionEvents;
public int score = 0; public int score = 0;
public int highscore = 0; public int highscore = 0;
public int lives = 3; public int lives = 12;
void Start() void Start()
{ {
part = GetComponent<ParticleSystem>(); part = GetComponent<ParticleSystem>();
@ -23,7 +23,14 @@ public class enemykiller : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (lives <= 0)
{
text.text = "GAME OVER";
}
else
{
text.text = "Score: " + score + "\nHighscore: " + highscore + "\nLives: " + lives + "\nKings remaining: " + GameObject.FindGameObjectsWithTag("king").Length + "\nEnemies remaining: " + GameObject.FindGameObjectsWithTag("enemy").Length;;
}
} }
//on particle coolision //on particle coolision
void OnParticleCollision(GameObject otherx) void OnParticleCollision(GameObject otherx)
@ -43,11 +50,6 @@ public class enemykiller : MonoBehaviour
{ {
Destroy(other); Destroy(other);
Debug.Log("enemy killed (" + other.name+ ")"); 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
enemyclone.name = "enemy" + i;
enemyclone.tag = "enemy";
//increase score //increase score
score++; score++;
if (score > highscore) if (score > highscore)
@ -55,30 +57,15 @@ public class enemykiller : MonoBehaviour
highscore = score; highscore = score;
} }
//update text //update text
text.text = "Score: " + score + "\nHighscore: " + highscore + "\nLives: " + lives;
} }
if (other.tag == "king") if (other.tag == "king")
{ {
Destroy(other); Destroy(other);
Debug.Log("killed king" + other.name); 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 //decrease score
score-= 20; score-= 20;
lives--; lives--;
if (lives <= 0)
{
text.text = "GAME OVER";
}
//update text
text.text = "Score: " + score + "\nHighscore: " + highscore + "\nLives: " + lives;
} }
i++; i++;
} }

@ -7,12 +7,14 @@ public class spawner : MonoBehaviour
//get enemy and king prefab //get enemy and king prefab
public GameObject enemy; public GameObject enemy;
public GameObject king; public GameObject king;
public int numkings = 16; public int kings_modulo = 4;
public int numenemies = 90; public int numenemies = 300;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
//spawn enemies //spawn enemies
for (int i = 0; i < numenemies; i++) for (int i = 0; i < numenemies; i++)
{ {
@ -21,15 +23,15 @@ public class spawner : MonoBehaviour
//set enemy name //set enemy name
enemyclone.name = "enemy" + i; enemyclone.name = "enemy" + i;
enemyclone.tag = "enemy"; enemyclone.tag = "enemy";
} //evenly ditribute kings
//spawn kings if (i % kings_modulo == 0)
for (int i = 0; i < numkings; i++) {
{ //spawn king
//spawn king GameObject kingclone = Instantiate(king, new Vector3(Random.Range(10, 125), Random.Range(-70, -60), Random.Range(-100, -10)), Quaternion.identity);
GameObject kingclone = Instantiate(king, new Vector3(Random.Range(10, 125), Random.Range(-70, -60), Random.Range(-100, -10)), Quaternion.identity); //set king name
//set king name kingclone.name = "king" + i;
kingclone.name = "king" + i; kingclone.tag = "king";
kingclone.tag = "king"; }
} }
} }