Пример #1
0
    public override IEnumerator ShootBullet()
    {
        UDEBulletMovement move1   = UDECartesianPolarMovementBuilder.Create().Speed(10).Angle(90).TangentialAccel(-10).Build();
        UDEBulletMovement move2_1 = UDECartesianPolarMovementBuilder.Create().Speed(10).Angle(45).TangentialAccel(-10).NormalAccel(-30).Build();
        UDEBulletMovement move3_1 = UDECartesianPolarMovementBuilder.Create().Speed(10).Angle(135).TangentialAccel(-10).NormalAccel(30).Build();
        UDEBulletMovement move2_2 = UDECartesianPolarMovementBuilder.Create().Speed(10).Angle(67).TangentialAccel(-10).NormalAccel(-50).Build();
        UDEBulletMovement move3_2 = UDECartesianPolarMovementBuilder.Create().Speed(10).Angle(113).TangentialAccel(-10).NormalAccel(50).Build();

        UDEBulletPool bulletPool = UDEBulletPool.Instance;
        Transform     tr         = gameObject.transform;

        while (true)
        {
            if (Input.GetKey(shoot))
            {
                UDEHomingBullet bullet1 = (UDEHomingBullet)bulletPool.GetBullet(bullet);

                bullet1.Initialize(tr.position, this, move1);

                UDEHomingBullet bullet2 = (UDEHomingBullet)bulletPool.GetBullet(bullet);
                UDEHomingBullet bullet3 = (UDEHomingBullet)bulletPool.GetBullet(bullet);
                if (Input.GetKey(slowMode))
                {
                    bullet2.Initialize(tr.position, this, move2_2);
                    bullet3.Initialize(tr.position, this, move3_2);
                }
                else
                {
                    bullet2.Initialize(tr.position, this, move2_1);
                    bullet3.Initialize(tr.position, this, move3_1);
                }


                if (!laserFiring)
                {
                    FireLaser();
                }
            }
            else
            {
                if (laserFiring)
                {
                    RemoveLaser();
                }
            }
            yield return(StartCoroutine(UDETime.Instance.WaitForScaledSeconds(BulletFireInterval, UDETime.TimeScale.PLAYER)));
        }
    }
Пример #2
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);
            }
        }