Example #1
0
    public override void Update()
    {
        base.Update();

        if (!LevelController.Singleton.Paused)
        {
            time += Time.deltaTime;
            while (warningList.Count > 0 && time >= warningList[0].Data.Time)
            {
                Wave.SpawnWarning(warningList[0]);
                warningList.RemoveAt(0);
            }
            while (fireList.Count > 0 && time >= fireList[0].Time)
            {
                for (int i = 0; i < 360; i += 5)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        fireData.From(new Vector2(fireList[0].Location.x + Mathf.Cos((i + j) * Mathf.Deg2Rad) * (30 + j),
                                                  fireList[0].Location.y + Mathf.Sin((i + j) * Mathf.Deg2Rad) * (30 + j)));
                        fireData.Towards(new Vector2(fireList[0].Location.x + Mathf.Cos((i + j + 90) * Mathf.Deg2Rad) * fireRadius,
                                                     fireList[0].Location.y + Mathf.Sin((i + j + 90) * Mathf.Deg2Rad) * fireRadius));
                        fireData.Fire();
                    }
                }
                fireList.RemoveAt(0);
                if (fireList.Count == 0)
                {
                    Destroy(gameObject, 5);
                }
            }
        }
    }
Example #2
0
    protected override IEnumerator Run()
    {
        for (int i = 0; i < 4; i++)
        {
            // Moving left
            FacePlayer           = true;
            rigidbody2d.velocity = new Vector2(-5, 0);
            yield return(new WaitForSeconds(2));

            // Stop and face player
            rigidbody2d.velocity = Vector2.zero;
            fireData.Towards(Player.transform.position);
            FacePlayer = false;

            // Fire
            yield return(new WaitForSeconds(0.2f));

            for (int j = 0; j < 10; j++)
            {
                fireData.Fire();
                yield return(new WaitForSeconds(0.2f));
            }
        }
        Die();
    }
Example #3
0
    private IEnumerator Attack()
    {
        while (true)
        {
            Vector3 position;
            int     direction;
            for (int i = 0; i < 3; i++)
            {
                position  = Player.transform.position;
                direction = Random.Range(0, 2) * 2 - 1;
                for (int j = 0; j < 16; j++)
                {
                    fireDataBullet.Towards(position);
                    fireDataBullet.WithRotation((12f * Mathf.Sqrt((16 - j) * 24) - 80) * direction);
                    fireDataBullet.Fire();
                    yield return(new WaitForSeconds(0.08f));
                }
                yield return(new WaitForSeconds(0.5f));
            }

            for (int i = 0; i < (enraged ? 5 : 3); i++)
            {
                still          = true;
                FacePlayer     = false;
                TargetRotation = transform.rotation;
                fireDataLaser.Fire();
                yield return(new WaitForSeconds(0.25f));

                still      = false;
                FacePlayer = true;
                yield return(new WaitForSeconds((enraged ? 0.25f : 0.5f)));
            }
        }
    }
Example #4
0
    public override void Update()
    {
        base.Update();

        if (!LevelController.Singleton.Paused)
        {
            fireCooldown -= Time.deltaTime;
            if (fireCooldown < 0)
            {
                fireData.Fire();
            }
        }
    }
Example #5
0
    public override void Update()
    {
        base.Update();

        if (!LevelController.Singleton.Paused)
        {
            fireCooldown -= Time.deltaTime;
            if (fireCooldown <= 0)
            {
                fireData.Fire();
                fireCooldown = MAX_FIRE_COOLDOWN / (1 + Difficulty / 4);
            }
        }
    }
Example #6
0
    public void Update()
    {
        if (!LevelController.Singleton.Paused && dieTime >= 0)
        {
            fireCooldown  -= Time.deltaTime;
            pauseCooldown -= Time.deltaTime;
            if (fireCooldown <= 0 && pauseCooldown <= 0)
            {
                fireData.Fire();
                fireCooldown = MAX_FIRE_COOLDOWN;
            }

            if (pauseCooldown <= -1f)
            {
                pauseCooldown = MAX_PAUSE_COOLDOWN;
            }
        }
    }
Example #7
0
    public override void Update()
    {
        base.Update();

        if (!LevelController.Singleton.Paused)
        {
            if (moveTimer <= 0)
            {
                rigidbody2d.velocity = Vector2.zero;

                fireCooldown -= Time.deltaTime;
                if (fireCooldown <= 0)
                {
                    if (fireCount < 100)
                    {
                        fireCount++;
                        fireData.Fire();
                        fireCooldown = MAX_FIRE_COOLDOWN;
                    }
                    else
                    {
                        moveTimer            = 16;
                        direction            = -direction;
                        rigidbody2d.velocity = new Vector2(direction, 0);
                        transform.Rotate(Vector3.forward * 180);
                    }
                }
            }
            else
            {
                moveTimer -= Time.deltaTime;

                if (moveTimer <= 0 && fireCount == 100)
                {
                    Die();
                }
            }
        }
    }
Example #8
0
    //Moves back and forth shooting behind them
    protected override IEnumerator Run()
    {
        //SPAWN ON RIGHT SIDE
        if (transform.position.x > 0)
        {
            rigidbody2d.velocity = new Vector2(-3, 0);
            rigidbody2d.rotation = 90;
            yield return(new WaitForSeconds(2));

            rigidbody2d.velocity = Vector2.zero;

            while (alive)
            {
                fireData.Facing(Vector2.down);
                for (int j = 0; j < 1 + Difficulty; j++)
                {
                    fireData.Fire();
                    yield return(new WaitForSeconds(0.5f / (Difficulty + 1f)));
                }
                rigidbody2d.velocity = new Vector2(-14, 0);
                for (int i = 0; i < (4 * (Difficulty + 1)); i++)
                {
                    fireData.Fire();
                    yield return(new WaitForSeconds(0.5f / (Difficulty + 1f)));
                }
                rigidbody2d.velocity = Vector2.zero;
                rigidbody2d.MoveRotation(270);

                fireData.Facing(Vector2.up);
                for (int j = 0; j < 1 + Difficulty; j++)
                {
                    fireData.Fire();
                    yield return(new WaitForSeconds(0.5f / (Difficulty + 1f)));
                }
                rigidbody2d.velocity = new Vector2(14, 0);
                for (int i = 0; i < (4 * (Difficulty + 1)); i++)
                {
                    fireData.Fire();
                    yield return(new WaitForSeconds(0.5f / (Difficulty + 1f)));
                }
                rigidbody2d.velocity = Vector2.zero;
                rigidbody2d.MoveRotation(90);
            }

            //SPAWN ON LEFT SIDE
        }
        else if (transform.position.x < 0)
        {
            rigidbody2d.velocity = new Vector2(3, 0);
            rigidbody2d.rotation = 270;
            yield return(new WaitForSeconds(2));

            rigidbody2d.velocity = Vector2.zero;

            while (alive)
            {
                fireData.Facing(Vector2.up);
                for (int j = 0; j < 1 + Difficulty; j++)
                {
                    fireData.Fire();
                    yield return(new WaitForSeconds(0.5f / (Difficulty + 1f)));
                }
                rigidbody2d.velocity = new Vector2(14, 0);
                for (int i = 0; i < (4 * (Difficulty + 1)); i++)
                {
                    fireData.Fire();
                    yield return(new WaitForSeconds(0.5f / (Difficulty + 1f)));
                }
                rigidbody2d.velocity = Vector2.zero;
                rigidbody2d.MoveRotation(90);

                fireData.Facing(Vector2.down);
                for (int j = 0; j < 1 + Difficulty; j++)
                {
                    fireData.Fire();
                    yield return(new WaitForSeconds(0.5f / (Difficulty + 1f)));
                }
                rigidbody2d.velocity = new Vector2(-14, 0);
                for (int i = 0; i < (4 * (Difficulty + 1)); i++)
                {
                    fireData.Fire();
                    yield return(new WaitForSeconds(0.5f / (Difficulty + 1f)));
                }
                rigidbody2d.velocity = Vector2.zero;
                rigidbody2d.MoveRotation(270);
            }
        }
    }
Example #9
0
    protected override IEnumerator Run()
    {
        do
        {
            // Down Left
            FacePlayer           = true;
            rigidbody2d.velocity = new Vector2(4 + start, 4 + start);
            start = 0;
            yield return(new WaitForSeconds(2));

            // Stop and face player
            rigidbody2d.velocity = Vector2.zero;
            fireData.Towards(Player.transform.position);
            FacePlayer = false;

            // Fire
            yield return(new WaitForSeconds(0.2f));

            for (int j = 0; j < 3; j++)
            {
                fireData.Fire();
                yield return(new WaitForSeconds(0.2f));
            }

            //Up Left
            FacePlayer           = true;
            rigidbody2d.velocity = new Vector2(4, -4);
            yield return(new WaitForSeconds(2));

            // Stop and face player
            rigidbody2d.velocity = Vector2.zero;
            fireData.Towards(Player.transform.position);
            FacePlayer = false;

            // Fire
            yield return(new WaitForSeconds(0.2f));

            for (int j = 0; j < 3; j++)
            {
                fireData.Fire();
                yield return(new WaitForSeconds(0.2f));
            }

            //Up Right
            FacePlayer           = true;
            rigidbody2d.velocity = new Vector2(-4, -4);
            yield return(new WaitForSeconds(2));

            // Stop and face player
            rigidbody2d.velocity = Vector2.zero;
            fireData.Towards(Player.transform.position);
            FacePlayer = false;

            // Fire
            yield return(new WaitForSeconds(0.2f));

            for (int j = 0; j < 3; j++)
            {
                fireData.Fire();
                yield return(new WaitForSeconds(0.2f));
            }

            //Down Right
            FacePlayer           = true;
            rigidbody2d.velocity = new Vector2(-4, 4);
            yield return(new WaitForSeconds(2));

            // Stop and face player
            rigidbody2d.velocity = Vector2.zero;
            fireData.Towards(Player.transform.position);
            FacePlayer = false;

            // Fire
            yield return(new WaitForSeconds(0.2f));

            for (int j = 0; j < 3; j++)
            {
                fireData.Fire();
                yield return(new WaitForSeconds(0.2f));
            }
        } while (alive);
        Die();
    }