Esempio n. 1
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);
            }
        }
Esempio n. 2
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)));
        }
    }