Example #1
0
        public void Fire(DanmakuEditor.BaseBullet p_baseBullet, Vector3 p_direction)
        {
            DanmakuEditor.NormalBullet baseBullet     = (DanmakuEditor.NormalBullet)p_baseBullet;
            DanmakuEditor.BulletPath   initBulletPath = baseBullet.path[0];

            string fireCDKey    = baseBullet._id + "_fireCD";
            string bulletNumKey = baseBullet._id + "_bulletNum";

            AddRecordKey(baseBullet._id, PropertiesUtility.time + initBulletPath.start_delay);
            AddRecordKey(fireCDKey, 0);

            if (PropertiesUtility.time > RecordTimeTable[baseBullet._id])
            {
                AddRecordKey(bulletNumKey, GetDictValue(bulletNumKey) + 1, true);
                float fireQueue = GetDictValue(bulletNumKey) % baseBullet.fireNumCd;

                float   angle     = MathParserRouter.Instance.CalculateAnswer(initBulletPath.angle_formula);
                Vector3 direction = new Vector3(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad), 0);

                if (initBulletPath.angleOnTarget)
                {
                    direction = p_direction;
                }

                //Calculate angle range, if we want to fire multiple bullet at once
                float startAngle       = Utility.MathUtility.VectorToAngle(direction) - (initBulletPath.range / 2);
                float incrementalAngle = initBulletPath.range / initBulletPath.numberOfBullet;

                for (int b = 0; b < initBulletPath.numberOfBullet; b++)
                {
                    var projectile = SetProjectile(baseBullet, (startAngle + (incrementalAngle * b)));

                    float fireQueueIndex      = (fireQueue == 0) ? (baseBullet.fireNumCd - 1) : (fireQueue - 1);
                    float duration_percentage = (baseBullet.fireNumCd - fireQueueIndex) / baseBullet.fireNumCd;

                    projectile.duration = initBulletPath.duration * duration_percentage;

                    if (OnBulletCreate != null)
                    {
                        OnBulletCreate(projectile);
                    }
                    //_projectileHandler.AddProjectile(projectile);
                }

                RecordTimeTable[baseBullet._id] = PropertiesUtility.time + initBulletPath.frequency;

                //Debug.Log(GetDictValue(bulletNumKey) + ", " + fireQueue + " , " + baseBullet.fireNumCd);
                if (fireQueue == 0)
                {
                    RecordTimeTable[baseBullet._id] = RecordTimeTable[baseBullet._id] + baseBullet.loadUpCd;
                }
            }
        }
Example #2
0
 public override void Reset()
 {
     base.Reset();
     pathIndex  = 0;
     baseBullet = null;
 }
Example #3
0
 public override void SetUp(DanmakuEditor.BaseBullet p_baseBullet, float p_spawnTime)
 {
     base.SetUp(p_baseBullet, p_spawnTime);
     baseBullet = (DanmakuEditor.NormalBullet)p_baseBullet;
 }