Enemy Spawn 1
Enemy Spawn 1
using System.Collections;
void Update()
{
if ((i == 15) && (step == 0))
{
spawnTime = spawnTime / 2;
CancelInvoke();
InvokeRepeating("Spawn", spawnTime, spawnTime);
step = 1;
}
if ((i == 35) && (step == 1))
{
step = 2;
}
if (((i >= 80) || (i == -1)) && (end == false))
{
if (i != -1)
{
CancelInvoke();
i = -1;
}
//Vector2 lookDir = Vector2.left;
//float velocity = 50;
if (!GameObject.FindGameObjectWithTag("Enemy"))
{
Instantiate(boss);
Destroy(GameObject.FindGameObjectWithTag("Music"));
musicSource.Play();
end = true;
}
}
if ((end == true) && (!GameObject.FindGameObjectWithTag("Enemy") && !
GameObject.FindGameObjectWithTag("Boss")))
{
lucy = GameObject.FindGameObjectWithTag("Player");
if (lucy != null)
{
color = lucy.GetComponent<SpriteRenderer>().color;
if (color.a > 0)
{
color.a -= (float)0.005;
lucy.GetComponent<SpriteRenderer>().color = color;
}
else
Destroy(lucy);
}
else
UnityEngine.SceneManagement.SceneManager.LoadScene("Menu");
//UnityEngine.SceneManagement.SceneManager.LoadScene("Level2");
}
}
void Spawn()
{
Vector2 lookDir = Vector2.left;
float velocity = 50;
// Find a random index between zero and one less than the number of spawn
points.
int spawnPointIndex = Random.Range(0, spawnPoints.Length);
newEnemy.transform.position =
spawnPoints[spawnPointIndex].transform.position;
i++;
}