예제 #1
0
파일: Enemy.cs 프로젝트: stec6000/SpaceTemp
    void Update()
    {
        if (transform.position.y > 4.25f)
        {
            transform.Translate(0, speed, 0);
        }

        transform.Translate(direction * speed, 0, 0);
        if (transform.position.x <= xmin || transform.position.x >= xmax)
        {
            direction *= -1;
        }


        tempTime += Time.deltaTime;
        if (tempTime > timeBetweenShots)
        {
            {
                bullet.Fire(new Vector3(0, -1, 0), 3);
                tempTime = 0;
            }
        }

        if (lives <= 0)
        {
            Instantiate(particle, transform.position, transform.rotation);
            float bonusX = Random.Range(0, 100);
            if (bonusX <= 80)
            {
                enemySpawn.SpawnBonus(bonus, gameObject.transform.position);
            }
            enemySpawn.SetIsSpawned(false);
            Destroy(gameObject);
        }
    }