Exemplo n.º 1
0
        private IEnumerator ShotTwo_CircleShot()
        {
            var winds = new WindArea[] { _fullScreeWindArea, _leftWindArea, _rightWindArea };

            while (true)
            {
                if (!_shotTwoShotCircleBullet)
                {
                    yield break;
                }

                float   angle  = Random.Range(0, 360);
                float   rad    = angle * Mathf.Deg2Rad;
                float   speed  = Random.Range(_shotTwoCirMinBulletSpeed, _shotTwoCirMaxBulletSpeed);
                Vector3 vSpeed = new Vector3(Mathf.Cos(rad), Mathf.Sin(rad), 0) * speed;

                var rotation = Quaternion.Euler(0, 0, angle - 90f);
                var bullet   = BulletUtils.GetBullet(
                    _shotTwoCirBullet, null, _falcon.position, rotation);
                bullet.GetComponent <JIBulletController> ()
                .Shot(WindBulletMove.LinearWindMove(bullet.transform, vSpeed, Vector3.zero, winds));

                float interval = Random.Range(_shotTwoCirMinEmitInterval, _shotTwoCirMaxEmitInterval);
                yield return(new WaitForSeconds(interval));
            }
        }
Exemplo n.º 2
0
        private IEnumerator SidenWind_Shot()
        {
            var winds = new WindArea[] { _fullScreeWindArea, _leftWindArea, _rightWindArea };

            float timer      = 0f;
            float deltAngle  = _sideWindSecRange / _sideWindNumberPerSector;
            float startAngle = 270f - _sideWindSecRange / 2 + deltAngle / 2;

            for (int i = 0; i < _sideWindSecNumber; i++)
            {
                for (int j = 0; j < _sideWindNumberPerSector; j++)
                {
                    float      angle    = startAngle + deltAngle * j;
                    Quaternion rotation = Quaternion.Euler(0, 0, angle - 90f);

                    float   rad = angle * Mathf.Deg2Rad;
                    Vector3 vec = new Vector3(Mathf.Cos(rad), Mathf.Sin(rad), 0f) * _sideWindBulletVec;

                    var bullet = BulletUtils.GetBullet(
                        _sideWindBullet, null, _falcon.position, Quaternion.identity);
                    bullet.GetComponent <JIBulletController> ().Shot(
                        WindBulletMove.LinearWindMove(bullet.transform, vec, Vector3.zero, winds));
                }

                while (timer < _sideWindShotInterval)
                {
                    timer += JITimer.Instance.DeltTime;
                    yield return(null);
                }

                timer = 0f;
            }

            yield return(new WaitForSeconds(_fullWindWaitTimeWhenEndShot));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Shot the expansion bullet
        /// </summary>
        private IEnumerator Expansion_Shot()
        {
            Vector3 destRight;
            Vector3 destLeft;
            float   timer = 0f;

            for (int i = _expanBulletNum - 1; i >= 0; i--)
            {
                destRight = _falcon.position + Vector3.right * (_expanInitDistance + i * _expanBulletLocaInterval);
                destLeft  = _falcon.position + Vector3.left * (_expanInitDistance + i * _expanBulletLocaInterval);

                var left = BulletUtils.GetBullet(
                    _expanBullet, null, _falcon.position, Quaternion.identity);
                left.GetComponent <JIBulletController> ().Shot(
                    Expansion_BulletMove(left.transform, destLeft));

                var right = BulletUtils.GetBullet(
                    _expanBullet, null, _falcon.position, Quaternion.identity);
                right.GetComponent <JIBulletController> ().Shot(
                    Expansion_BulletMove(right.transform, destRight));

                timer = _expanBulletShotInterval;
                while (timer > 0f)
                {
                    timer -= JITimer.Instance.DeltTime;
                    yield return(null);
                }
            }

            yield return(new WaitForSeconds(_expanBulletPauseTime));

            Expansion_Transition();
        }
Exemplo n.º 4
0
        private void ShotOne_ShotBullet(float emitRad, Vector3 emitPos, WindArea[] winds)
        {
            var bulletRotate = Quaternion.Euler(0, 0, emitRad * Mathf.Rad2Deg);
            var bulletSpeed  = new Vector3(Mathf.Cos(emitRad), Mathf.Sin(emitRad), 0) * _shotOneBulletSpeed;
            var bullet       = BulletUtils.GetBullet(_shotOneBullet, null, emitPos, bulletRotate);

            bullet.GetComponent <JIBulletController> ()
            .Shot(WindBulletMove.LinearWindMove(bullet.transform, bulletSpeed, Vector3.zero, winds));
        }
Exemplo n.º 5
0
        // Follow the player and shot
        private void MoveShot_LateUpdate()
        {
            var   playerProperty = _player.GetComponent <PlayerProperty> ();
            float moveSpeed      = playerProperty.GetHMoveSpeed();
            float shotSpeed      = 0.03f;
            float bulletSpeed    = 5;

            _moveShotTarget = _player.position.x;

            _moveShotShotTimer -= JITimer.Instance.DeltTime;

            // Shot bullet
            if (_moveShotShotTimer < 0f)
            {
                _moveShotShotTimer = shotSpeed;

                var left = BulletUtils.GetBullet(
                    _moveShotBullet, null,
                    _falcon.TransformPoint(_moveShotShotPosLeft),
                    Quaternion.identity);
                left.GetComponent <JIBulletController> ().Shot(bulletSpeed, 270f, 0, 0,
                                                               false, null, 0f, 0f,
                                                               false, 0f, 0f,
                                                               false, 0f, 0f);

                var right = BulletUtils.GetBullet(
                    _moveShotBullet, null,
                    _falcon.TransformPoint(_moveShotShotPosRight),
                    Quaternion.identity);
                right.GetComponent <JIBulletController> ().Shot(bulletSpeed, 270f, 0, 0,
                                                                false, null, 0f, 0f,
                                                                false, 0f, 0f,
                                                                false, 0f, 0f);
            }

            // Move
            float distance = _moveShotTarget - _falcon.position.x;

            if (Mathf.Abs(distance) <= moveSpeed * JITimer.Instance.DeltTime)
            {
                _falcon.position = new Vector3(_moveShotTarget, _falcon.position.y, _falcon.position.z);
                if (_moveShotMove)
                {
                    MoveShot_EndMove();
                    _moveShotMove = false;
                }
            }
            else
            {
                _falcon.position += new Vector3(Mathf.Sign(distance), 0, 0) * moveSpeed * JITimer.Instance.DeltTime;
            }
        }
Exemplo n.º 6
0
 protected JIBulletController GetBullet(Vector3 position, Quaternion rotation, bool forceInstantiate = false)
 {
     if (m_bind)
     {
         return(BulletUtils.GetBullet(m_bulletPrefab, m_bindTransform, position,
                                      rotation, forceInstantiate));
     }
     else
     {
         return(BulletUtils.GetBullet(m_bulletPrefab, null, position, rotation,
                                      forceInstantiate));
     }
 }
Exemplo n.º 7
0
        private void MutiShot_Shot()
        {
            float delt = 360 / _mutiShotNumberPerCircle;

            for (int i = 0; i < _mutiShotNumberPerCircle; i++)
            {
                float angle = i * delt;

                var bullet = BulletUtils.GetBullet(
                    _mutiShotBullet, null, _falcon.position, Quaternion.identity);
                bullet.GetComponent <JIBulletController> ().Shot(
                    MutiShot_BulletMove(bullet.transform, angle));
            }
        }
Exemplo n.º 8
0
        private void ShotThree_Shot()
        {
            var winds = new WindArea[] { _fullScreeWindArea, _leftWindArea, _rightWindArea };

            float delt = 360 / _shotThreeNumberPerCircle;

            for (int i = 0; i < _shotThreeNumberPerCircle; i++)
            {
                float   angle = i * delt;
                float   rad   = angle * Mathf.Deg2Rad;
                Vector3 speed = new Vector3(Mathf.Cos(rad), Mathf.Sin(rad), 0f) * _shotThreeInitVec;
                Vector3 accel = new Vector3(Mathf.Cos(rad), Mathf.Sin(rad), 0f) * _shotThreeAccel;

                var bullet = BulletUtils.GetBullet(
                    _shotThreeBullet, null, _falcon.position, Quaternion.identity);
                bullet.GetComponent <JIBulletController> ()
                .Shot(WindBulletMove.LinearWindMove(bullet.transform, speed, accel, winds));
            }
        }
Exemplo n.º 9
0
    private void Shot()
    {
        _shotTimer += JITimer.Instance.DeltTime;

        if (_shotTimer > ShotInterval)
        {
            var bullet = BulletUtils.GetBullet(BulletPrefab, null,
                                               transform.position + (Vector3)_bulletSpawnOffset,
                                               BulletPrefab.transform.rotation)
                         .GetComponent <JIBulletProperty> ();
            bullet.Damage = BulletDamage;

            var moveCtrl = bullet.gameObject.AddComponent <GeneralBulletMoveCtrl> ();
            moveCtrl.Speed = BulletSpeed;
            moveCtrl.Init();

            _shotTimer = 0f;
        }
    }
Exemplo n.º 10
0
    public void NormalShot()
    {
        if (NormalEmitters.Count == 0)
        {
            return;
        }

        foreach (var emitter in NormalEmitters)
        {
            var bullet = BulletUtils.GetBullet(BulletPrefab, null, emitter.position,
                                               emitter.rotation).gameObject;

            float angle = bullet.transform.rotation.eulerAngles.z + 90f;

            var moveController = bullet.AddComponent <GeneralBulletMoveCtrl> ();
            moveController.Angle = angle;
            moveController.Speed = BulletSpeed;
            moveController.Init();
        }
    }
Exemplo n.º 11
0
        private IEnumerator ShotTwo_SecDirShot(float angle)
        {
            var   winds    = new WindArea[] { _fullScreeWindArea, _leftWindArea, _rightWindArea };
            float secRange = 60f;

            for (int i = 0; i < _shotTwoSecBulletNum; i++)
            {
                float   speed       = Random.Range(_shotTwoSecMinBulletSpeed, _shotTwoSecMaxBulletSpeed);
                float   bulletAngle = angle + Random.Range(-secRange / 2, secRange / 2);
                float   bulletRad   = bulletAngle * Mathf.Deg2Rad;
                Vector3 vSpeed      = new Vector3(Mathf.Cos(bulletRad), Mathf.Sin(bulletRad), 0) * speed;

                var rotation = Quaternion.Euler(0, 0, bulletAngle - 90f);
                var bullet   = BulletUtils.GetBullet(
                    _shotTwoSecBullet, null, _falcon.position, rotation);
                bullet.GetComponent <JIBulletController> ().Shot(
                    WindBulletMove.LinearWindMove(bullet.transform, vSpeed, Vector3.zero, winds));

                float interval = Random.Range(_shotTwoSecMinEmitInterval, _shotTwoSecMaxEmitInterval);
                yield return(new WaitForSeconds(interval));
            }
        }