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

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

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