Example #1
0
        public override void OnEnable()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
            base.OnEnable();
            if (enemyGroup != null)
            {
                bulletParent = enemyGroup.trs;
            }
            for (int i = 0; i < shootEntries.Length; i++)
            {
                ShootEntry shootEntry = shootEntries[i];
                if (!shootEntry.enabled)
                {
                    shootEntries = shootEntries.RemoveAt(i);
                    i--;
                }
                else
                {
                    shootEntry.shootTimer.duration    = shootEntry.defaultShootInterval * shootIntervalsMultiplier;
                    shootEntry.shootTimer.onFinished += _Shoot;
                    shootEntry.shootTimer.args        = new object[] { shootEntry };
                    shootEntry.bulletPattern.Init(shootEntry.spawner);
                    shootEntry.shootTimer.Start();
                }
            }
        }
Example #2
0
        public virtual Weapon[] Shoot(params object[] args)
        {
            ShootEntry shootEntry     = (ShootEntry)args[0];
            float      positionOffset = shootEntry.positionOffsetOverride;

            if (!shootEntry.overridePositionOffset)
            {
                positionOffset = shootEntry.bulletPrefab.radius;
                if (shootEntry.spawner == body.trs)
                {
                    positionOffset += radius;
                }
            }
            Weapon[] bullets = shootEntry.bulletPattern.Shoot(shootEntry.spawner, shootEntry.bulletPrefab, positionOffset);
            foreach (Weapon bullet in bullets)
            {
                bullet.player = this;
                bullet.Move(bullet.trs.up);
                bullet.trs.SetParent(bulletParent);
            }
            return(bullets);
        }