Beispiel #1
0
        private IEnumerator IntroWhiteSpiritPattern(LambdaShotPattern pattern, List <UDEAbstractBullet> bullets, UDEEnemy enemy)
        {
            var trResult = UDETransitionHelper.MoveAmount(enemy.gameObject, new Vector2(-7, 0.6f), 6, UDETransitionHelper.easeOutQuad, UDETime.TimeScale.ENEMY, true);

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

            for (int i = 0; i < 5; i++)
            {
                UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(bullets[0]);
                bullet.SummonTime = 0.08f;
                bullet.MoveBulletToDirection(enemy, pattern, enemy.transform.position, 0, new Vector2(-5, 0), true);

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

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

            trResult = UDETransitionHelper.MoveAmount(enemy.gameObject, new Vector2(-6, 15), 6, UDETransitionHelper.easeInQuad, UDETime.TimeScale.ENEMY, true);
            yield return(new WaitUntil(() => trResult.EndTransition));

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

            yield return(null);
        }
        protected override IEnumerator ShotPattern()
        {
            originEnemy.transform.SetPositionAndRotation(Camera.main.ViewportToWorldPoint(new Vector3(1.1f, 0.5f, 0)), Quaternion.Euler(0, 0, 0));
            var trResult = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.8f, 0.5f, 0)), 0.5f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true);

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

            originEnemy.CanBeDamaged = true;

            IUDERandom random     = new UDEXORRandom();
            Vector2    moveVector = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.65f, 0));

            moveVector = new Vector2(0, moveVector.y);

            while (true)
            {
                float dtheta = 360f / numberOfGreenBullets;
                for (int i = 0; i < numberOfGreenBullets; i++)
                {
                    UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[GreenLuminusBullet]);
                    bullet.transform.localScale = new Vector3(0.7f, 0.7f);
                    bullet.SummonTime           = 0.08f;
                    (float x, float y)          = UDEMath.Polar2Cartesian(greenBulletSpeed, i * dtheta);
                    bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, new Vector2(x, y));
                }

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

                Vector2 playerPos = GameManager.player.transform.position;
                Vector2 direction = playerPos - (Vector2)originEnemy.transform.position;
                (_, float angle) = UDEMath.Cartesian2Polar(direction);

                Vector2 vel1 = UDEMath.Polar2Cartesian(blueBulletSpeed, angle).ToVector2();
                Vector2 vel2 = UDEMath.Polar2Cartesian(blueBulletSpeed, angle + blueBulletAngle).ToVector2();
                Vector2 vel3 = UDEMath.Polar2Cartesian(blueBulletSpeed, angle - blueBulletAngle).ToVector2();

                for (int i = 0; i < 5; i++)
                {
                    UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[LightBlueLuminusBullet]);
                    bullet.transform.localScale = new Vector3(0.7f, 0.7f);
                    bullet.SummonTime           = 0.08f;
                    bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, vel1);

                    bullet = UDEBulletPool.Instance.GetBullet(patternBullets[LightBlueLuminusBullet]);
                    bullet.transform.localScale = new Vector3(0.7f, 0.7f);
                    bullet.SummonTime           = 0.08f;
                    bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, vel2);

                    bullet = UDEBulletPool.Instance.GetBullet(patternBullets[LightBlueLuminusBullet]);
                    bullet.transform.localScale = new Vector3(0.7f, 0.7f);
                    bullet.SummonTime           = 0.08f;
                    bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, vel3);

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

                int     flag   = random.NextInt(0, 100);
                Vector2 curPos = Camera.main.WorldToViewportPoint(originEnemy.transform.position);
                if (flag < 50)             // Move up
                {
                    if (curPos.y >= 0.79f) // Move down
                    {
                        UDETransitionHelper.MoveAmount(originEnemy.gameObject, -moveVector, 1f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true);
                    }
                    else
                    {
                        UDETransitionHelper.MoveAmount(originEnemy.gameObject, moveVector, 1f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true);
                    }
                }
                else // Move down
                {
                    if (curPos.y <= 0.21f) // Move up
                    {
                        UDETransitionHelper.MoveAmount(originEnemy.gameObject, moveVector, 1f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true);
                    }
                    else
                    {
                        UDETransitionHelper.MoveAmount(originEnemy.gameObject, -moveVector, 1f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true);
                    }
                }

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

                for (int i = 0; i < numberOfGreenBullets; i++)
                {
                    UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[GreenLuminusBullet]);
                    bullet.transform.localScale = new Vector3(0.7f, 0.7f);
                    bullet.SummonTime           = 0.08f;
                    (float x, float y)          = UDEMath.Polar2Cartesian(greenBulletSpeed, i * dtheta);
                    bullet.MoveBulletToDirection(originEnemy, this, originEnemy.transform.position, 0, new Vector2(x, y));
                }

                yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.7f, UDETime.TimeScale.ENEMY)));
            }
        }
Beispiel #3
0
        private void ShotBullet()
        {
            UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(mainBullet);

            bullet.Damage = mainCenterBulletDamage;
            bullet.MoveBulletToDirection(this, null, mainShotPoint.position, 0, new Vector2(arrowBulletSpeed, 0));
            if (powerLevel >= 1)
            {
                bullet        = UDEBulletPool.Instance.GetBullet(mainBullet);
                bullet.Damage = mainSubBulletDamage;
                var vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, mainShotAngle * (isSlowMode ? mainShotAngleMultiplier : 1.0f));
                bullet.MoveBulletToDirection(this, null, mainShotPoint.position, 0, new Vector2(vel.x, vel.y));

                bullet        = UDEBulletPool.Instance.GetBullet(mainBullet);
                bullet.Damage = mainSubBulletDamage;
                vel           = UDEMath.Polar2Cartesian(arrowBulletSpeed, -mainShotAngle * (isSlowMode ? mainShotAngleMultiplier : 1.0f));
                bullet.MoveBulletToDirection(this, null, mainShotPoint.position, 0, new Vector2(vel.x, vel.y));
            }
            if (powerLevel >= 2)
            {
                bullet        = UDEBulletPool.Instance.GetBullet(subBullet);
                bullet.Damage = subBulletDamage;
                var vel = UDEMath.Polar2Cartesian(arrowBulletSpeed, subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f));
                bullet.MoveBulletToDirection(this, null, subWeapons[0].position, 0, new Vector2(vel.x, vel.y));

                bullet        = UDEBulletPool.Instance.GetBullet(subBullet);
                bullet.Damage = subBulletDamage;
                vel           = UDEMath.Polar2Cartesian(arrowBulletSpeed, subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f) + subArrowAngle * (isSlowMode ? subArrowAngleSlowMultiplier : 1.0f));
                bullet.MoveBulletToDirection(this, null, subWeapons[0].position, 0, new Vector2(vel.x, vel.y));

                bullet        = UDEBulletPool.Instance.GetBullet(subBullet);
                bullet.Damage = subBulletDamage;
                vel           = UDEMath.Polar2Cartesian(arrowBulletSpeed, subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f) - subArrowAngle * (isSlowMode ? subArrowAngleSlowMultiplier : 1.0f));
                bullet.MoveBulletToDirection(this, null, subWeapons[0].position, 0, new Vector2(vel.x, vel.y));

                bullet        = UDEBulletPool.Instance.GetBullet(subBullet);
                bullet.Damage = subBulletDamage;
                vel           = UDEMath.Polar2Cartesian(arrowBulletSpeed, -subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f));
                bullet.MoveBulletToDirection(this, null, subWeapons[1].position, 0, new Vector2(vel.x, vel.y));

                bullet        = UDEBulletPool.Instance.GetBullet(subBullet);
                bullet.Damage = subBulletDamage;
                vel           = UDEMath.Polar2Cartesian(arrowBulletSpeed, -subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f) + subArrowAngle * (isSlowMode ? subArrowAngleSlowMultiplier : 1.0f));
                bullet.MoveBulletToDirection(this, null, subWeapons[1].position, 0, new Vector2(vel.x, vel.y));

                bullet        = UDEBulletPool.Instance.GetBullet(subBullet);
                bullet.Damage = subBulletDamage;
                vel           = UDEMath.Polar2Cartesian(arrowBulletSpeed, -subWeaponShotAngle * (isSlowMode ? subWeaponShotAngleSlowMultiplier : 1.0f) - subArrowAngle * (isSlowMode ? subArrowAngleSlowMultiplier : 1.0f));
                bullet.MoveBulletToDirection(this, null, subWeapons[1].position, 0, new Vector2(vel.x, vel.y));
            }
            if (powerLevel >= 3 && shotCnt == 0)
            {
                UDEHomingBullet homingBullet = UDEBulletPool.Instance.GetBullet(subHomingBullet) as UDEHomingBullet;
                homingBullet.Damage = subHomingBulletDamage;
                homingBullet.Initialize(subWeapons[2].position, this, isSlowMode ? homingMoveSlow1 : homingMove1);

                homingBullet        = UDEBulletPool.Instance.GetBullet(subHomingBullet) as UDEHomingBullet;
                homingBullet.Damage = subHomingBulletDamage;
                homingBullet.Initialize(subWeapons[3].position, this, isSlowMode ? homingMoveSlow2 : homingMove2);
            }
        }