Пример #1
0
    protected override IEnumerator ShotPattern()
    {
        originEnemy.CanBeDamaged = false;
        var result = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.85f)), 2f, UDETransitionHelper.easeOutCubic, UDETime.TimeScale.ENEMY, true);

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

        originEnemy.CanBeDamaged = true;

        float angleDiff = 360f / (float)bulletNumber;

        float angleClockwise     = 0;
        float angleAntiClockwise = 0;

        UDEPolarMovementBuilder builder = UDEPolarMovementBuilder.Create().RadialSpeed(bulletSpeed);

        while (true)
        {
            for (int i = 0; i < bulletNumber; i++)
            {
                float angle = angleDiff * i + angleClockwise;
                builder.InitialAngle(angle);

                UDEAbstractBullet bullet  = UDEBulletPool.Instance.GetBullet(patternBullets[0]);
                Vector2           origin  = originEnemy.transform.position;
                Vector2           formLoc = origin + (UDEMath.CartesianCoord) new UDEMath.PolarCoord(0.35f, angle);
                bullet.Initialize(formLoc, origin, 0, originEnemy, this, builder.Build());

                angle = angleDiff * i + angleAntiClockwise;
                builder.InitialAngle(angle);

                UDEAbstractBullet bullet2 = UDEBulletPool.Instance.GetBullet(patternBullets[0]);
                formLoc = origin + (UDEMath.CartesianCoord) new UDEMath.PolarCoord(0.35f, angle);
                bullet2.Initialize(formLoc, origin, 0, originEnemy, this, builder.Build());
            }

            angleClockwise     -= angularSpeed;
            angleAntiClockwise += angularSpeed;
            while (angleClockwise < 0)
            {
                angleClockwise += 360f;
            }
            while (angleAntiClockwise > 360)
            {
                angleAntiClockwise -= 360f;
            }

            yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.12f, UDETime.TimeScale.ENEMY)));
        }
    }
Пример #2
0
    protected override IEnumerator ShotPattern()
    {
        originEnemy.CanBeDamaged = false;
        var result = UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f)), 2f, UDETransitionHelper.easeInOutCubic, UDETime.TimeScale.ENEMY, true);

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

        originEnemy.CanBeDamaged = true;

        UDEMath.PolarFunction bulletPosition        = (deg, err) => 0.3f + 2.5f * (deg - err) / 360f;
        UDEMath.PolarFunction bulletPositionInverse = (deg, err) => 0.3f + 2.5f * (err - deg) / 360f;

        UDEPolarMovementBuilder first  = UDEPolarMovementBuilder.Create().DoNotFaceToMovingDirection();
        UDEPolarMovementBuilder second = UDEPolarMovementBuilder.Create(true).MinAngularSpeed(-30f).MinRadialSpeed(-2.2f).AngularAccel(-25f).RadialAccel(-1.8f).StartTime(1000);

        Vector2 origin = originEnemy.transform.position;

        int cnt = 0;

        while (true)
        {
            float error = Random.Range(-10f, 10f);
            UDEMath.PolarCoord[] coords = cnt % 2 == 0 ?
                                          UDEMath.GetPolarCoordStructs(bulletPosition, error, 3 * 360 + error, error, 500) :
                                          UDEMath.GetPolarCoordStructs(bulletPositionInverse, -error, -error - 3 * 360, -error, 500);
            for (int i = 0; i < coords.Length; i++)
            {
                UDEAbstractBullet   bullet    = UDEBulletPool.Instance.GetBullet(patternBullets[0]);
                Vector2             formLoc   = origin + (UDEMath.CartesianCoord)coords[i];
                float               angle     = coords[i].degree - 90f;
                UDEBulletMovement[] movements = new UDEBulletMovement[] { first.Build(), second.Build() };
                bullet.Initialize(formLoc, origin, angle, originEnemy, this, movements);
                bullets.Add(bullet);
                yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(0.012f, UDETime.TimeScale.ENEMY)));
            }

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

            for (int i = bullets.Count - 1; i > -1; i--)
            {
                ((dynamic)bullets[i]).ForceMoveToPhase(1);
                bullets.RemoveAt(i);
            }

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

            cnt++;
        }
    }
Пример #3
0
        protected override IEnumerator ShotPattern()
        {
            UDETransitionHelper.StopAllTransitions(originEnemy.gameObject);

            originalBackgroundColor = background.GetComponent <SpriteRenderer>().color;

            originEnemy.CanBeDamaged = false;
            UDETransitionHelper.MoveTo(originEnemy.gameObject, Camera.main.ViewportToWorldPoint(new Vector3(0.77f, 0.5f, 0)), 0.75f, UDETransitionHelper.easeOutCubic, UDE.Management.UDETime.TimeScale.ENEMY, true);
            UDETransitionHelper.ChangeScaleTo(background, new Vector3(1.2f, 1.2f, 1f), 1f, UDETransitionHelper.easeLinear, UDETime.TimeScale.ENEMY, false);
            UDETransitionHelper.ChangeColorTo(background, changeBackgroundColorTo, 1f, UDETransitionHelper.easeLinear, UDETime.TimeScale.ENEMY, false);
            yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(2f, UDETime.TimeScale.ENEMY)));

            originEnemy.CanBeDamaged = true;

            IEnumerator leafFallPattern = LeafFallSubPattern();

            StartSubpattern(leafFallPattern);

            UDEPolarMovementBuilder builder  = UDEPolarMovementBuilder.Create().RadialSpeed(radialSpeed);
            UDEBulletMovement       movement = builder.Build();

            float currAngle = 0f;
            float dtheta    = 360f / numberOfBullets;

            while (true)
            {
                for (int i = 0; i < numberOfBullets; i++)
                {
                    UDEAbstractBullet bullet = UDEBulletPool.Instance.GetBullet(patternBullets[LightBlueCircleBullet]);
                    bullet.SummonTime = 0.1f;
                    Vector2 origin  = originEnemy.transform.position;
                    Vector2 initPos = UDEMath.Polar2Cartesian(0.1f, currAngle + dtheta * i).ToVector2() + origin;

                    bullet.Initialize(initPos, origin, 0, originEnemy, this, movement);
                }

                currAngle += angleDifference;
                yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(1.5f, UDETime.TimeScale.ENEMY)));
            }
        }
        public static void RotateBulletAroundCharacter(
            this UDEAbstractBullet bullet,
            UDEBaseCharacter character,
            UDEBaseShotPattern originShotPattern,
            UDEMath.PolarCoord initialPolarCoord,
            float initialRotation,
            float angularSpeed,
            float radialSpeed          = 0.0f,
            bool faceToMovingDirection = true)
        {
            if (!bullet.gameObject.activeSelf)
            {
                return;
            }

            UDEPolarMovementBuilder builder = UDEPolarMovementBuilder.Create().AngularSpeed(angularSpeed).RadialSpeed(radialSpeed);

            if (!faceToMovingDirection)
            {
                builder = builder.DoNotFaceToMovingDirection();
            }

            Vector2 origin = character.transform.position;

            bullet.Initialize(origin + (Vector2)initialPolarCoord, origin, initialRotation, character, originShotPattern, builder.Build(), true);
        }