Exemple #1
0
        protected override void Awake()
        {
            base.Awake();

            subWeapons[0].gameObject.SetActive(false);
            subWeapons[1].gameObject.SetActive(false);
            subWeapons[2].gameObject.SetActive(false);
            subWeapons[3].gameObject.SetActive(false);

            float innerAngle = subWeaponAngle * 0.5f;
            float outerAngle = subWeaponAngle * 1.5f;

            var sb1 = UDEMath.Polar2Cartesian(subWeaponsDistance, innerAngle);
            var sb3 = UDEMath.Polar2Cartesian(subWeaponsDistance, outerAngle);

            subWeapons[0].localPosition = new Vector3(-sb1.x, sb1.y, 0);
            subWeapons[1].localPosition = new Vector3(-sb1.x, -sb1.y, 0);
            subWeapons[2].localPosition = new Vector3(-sb3.x, sb3.y, 0);
            subWeapons[3].localPosition = new Vector3(-sb3.x, -sb3.y, 0);

            UDECartesianPolarMovementBuilder builder = UDECartesianPolarMovementBuilder.Create();

            builder.Speed(arrowBulletSpeed * subHomingBulletSpeedSlowMultiplier).Angle(subWeaponShotAngle * 2);
            homingMove1     = builder.Build();
            homingMoveSlow1 = builder.Angle(subWeaponShotAngle * 2 * subWeaponShotAngleSlowMultiplier).Build();
            homingMove2     = builder.Angle(-subWeaponShotAngle * 2).Build();
            homingMoveSlow2 = builder.Angle(-subWeaponShotAngle * 2 * subWeaponShotAngleSlowMultiplier).Build();
        }
Exemple #2
0
        private IEnumerator Wave2FairyPattern(LambdaShotPattern pattern, List <UDEAbstractBullet> bullets, UDEEnemy enemy)
        {
            UDETransitionHelper.MoveAmount(enemy.gameObject, new Vector2(-3, 0), 1f, UDETransitionHelper.easeOutQuad, UDETime.TimeScale.ENEMY, true);
            yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.3f, UDETime.TimeScale.ENEMY)));

            Transform enemyTr = enemy.transform;

            float angle     = 25;
            var   easeInOut = UDETransitionHelper.easeInOutQuad.Composite(t => t / 4);
            float dt        = 0.4f;

            UDECartesianPolarMovementBuilder builder = UDECartesianPolarMovementBuilder.Create().Speed(4.5f).Angle(180);
            UDEBulletMovement central = builder.Build();

            float accTime = 0;

            for (int i = 0; i < (int)(8 / dt); i++)
            {
                if (accTime <= 4)
                {
                    angle = 25 - 50 * easeInOut(accTime);
                }
                else
                {
                    angle = -25 + 50 * easeInOut(accTime - 4);
                }

                UDEBulletMovement upper = builder.Angle(180 - angle).Build();
                UDEBulletMovement lower = builder.Angle(180 + angle).Build();

                UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(bullets[0]); // Upper
                bullet.SummonTime           = 0.05f;
                bullet.transform.localScale = new Vector3(0.85f, 0.85f);
                bullet.Initialize(enemyTr.position, enemyTr.position, 0, enemy, pattern, upper);

                bullet                      = UDEBulletPool.Instance.GetBullet(bullets[1]); // Lower
                bullet.SummonTime           = 0.05f;
                bullet.transform.localScale = new Vector3(0.85f, 0.85f);
                bullet.Initialize(enemyTr.position, enemyTr.position, 0, enemy, pattern, lower);

                float accTimeD = accTime + 1f;
                if (accTimeD >= 8)
                {
                    accTimeD -= 8;
                }

                if (accTimeD <= 4)
                {
                    angle = 25 - 50 * easeInOut(accTimeD);
                }
                else
                {
                    angle = -25 + 50 * easeInOut(accTimeD - 4);
                }

                upper.angle                 = 180 - angle * 2f;
                bullet                      = UDEBulletPool.Instance.GetBullet(bullets[2]);
                bullet.SummonTime           = 0.05f;
                bullet.transform.localScale = new Vector3(0.85f, 0.85f);
                bullet.Initialize(enemyTr.position, enemyTr.position, 0, enemy, pattern, upper);

                lower.angle                 = 180 + angle * 2f;
                bullet                      = UDEBulletPool.Instance.GetBullet(bullets[2]);
                bullet.SummonTime           = 0.05f;
                bullet.transform.localScale = new Vector3(0.85f, 0.85f);
                bullet.Initialize(enemyTr.position, enemyTr.position, 0, enemy, pattern, lower);

                accTime += dt;
                yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(dt, UDETime.TimeScale.ENEMY)));
            }

            Vector2 movePoint = Camera.main.ViewportToWorldPoint(new Vector3(-0.1f, 0));

            movePoint.y = enemyTr.position.y;

            var trResult = UDETransitionHelper.MoveTo(enemy.gameObject, movePoint, 6f, UDETransitionHelper.easeInQuad, UDETime.TimeScale.ENEMY, true);

            yield return(new WaitUntil(() => trResult.EndTransition));

            ((EnemyBase)enemy).OnDestroy();
            Destroy(enemy);

            yield return(null);
        }
Exemple #3
0
    protected override IEnumerator ShotPattern()
    {
        var result = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f)), 2, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true);

        originEnemy.CanBeDamaged = false;
        yield return(new WaitUntil(() => result.EndTransition));

        originEnemy.CanBeDamaged = true;

        StartCoroutine(GravityBullets());

        UDECartesianPolarMovementBuilder builder = UDECartesianPolarMovementBuilder.Create().Speed(4f);

        while (true)
        {
            for (int i = 0; i < 3; i++)
            {
                Vector2 playerPosition = GameObject.FindGameObjectWithTag("Player").transform.position;
                Vector2 enemyPosition  = originEnemy.transform.position;
                float   angle          = UDEMath.Deg(playerPosition - enemyPosition);

                Vector2 origin          = enemyPosition;
                Vector2 formOriginDispl = UDEMath.Polar2Cartesian(0.3f, angle).ToVector2();
                Vector2 formOrigin      = origin + formOriginDispl;
                builder.Angle(angle);
                UDEBulletMovement movement = builder.Build();

                Vector2 formHalfDispl = UDEMath.Polar2Cartesian(0.105f, angle + 90).ToVector2();

                for (int n = 1; n <= 6; n++)
                {
                    if (n % 2 == 0)
                    {
                        for (int j = 0; j < n / 2; j++)
                        {
                            UDEAbstractBullet negBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]);
                            UDEAbstractBullet posBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]);
                            negBullet.Initialize(formOrigin - (formHalfDispl * (j * 2 + 1)), origin, 0, originEnemy, this, movement);
                            posBullet.Initialize(formOrigin + (formHalfDispl * (j * 2 + 1)), origin, 0, originEnemy, this, movement);
                        }
                    }
                    else
                    {
                        UDEAbstractBullet middleBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]);
                        middleBullet.Initialize(formOrigin, origin, 0, originEnemy, this, movement);
                        for (int j = 0; j < n / 2; j++)
                        {
                            UDEAbstractBullet negBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]);
                            UDEAbstractBullet posBullet = UDEBulletPool.Instance.GetBullet(patternBullets[1]);
                            negBullet.Initialize(formOrigin - (formHalfDispl * (j + 1) * 2), origin, 0, originEnemy, this, movement);
                            posBullet.Initialize(formOrigin + (formHalfDispl * (j + 1) * 2), origin, 0, originEnemy, this, movement);
                        }
                    }

                    yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.11f, UDETime.TimeScale.ENEMY)));
                }

                yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.24f, UDETime.TimeScale.ENEMY)));
            }

            yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(2f, UDETime.TimeScale.ENEMY)));
        }
    }