示例#1
0
        public override void Start()
        {
            target = GetTarget();

            firePeriodically = FirePeriodically();
            StartCoroutine(firePeriodically);
        }
示例#2
0
        IEnumerator FirePeriodically()
        {
            while (true)
            {
                if (!targetIsAlive)
                {
                    _target = GetTarget();
                    if (_target != null)
                    {
                        targetIsAlive = true;
                    }
                }
                var offset = Random.Range(minFireDelayOffset,
                                          maxFireDelayOffset);

                yield return(new WaitForSeconds(offset));

                MessageBus.FireBullet.Invoke();

                yield return(new WaitForSeconds(fireDelay - offset));
            }
        }
示例#3
0
 void TargetDestroyed(BaseBehaviour destroyed)
 {
     targetIsAlive = false;
 }