예제 #1
0
 private IEnumerator MoveTo(Vector3 destination, BubbleAmmoView ammoView)
 {
     while ((ammoView.transform.position - destination).sqrMagnitude > 0.0001f)
     {
         ammoView.transform.position = Vector3.MoveTowards(ammoView.transform.position, destination, 1.0f * 0.5f);
         yield return(null);
     }
 }
예제 #2
0
        public void Setup()
        {
            _currentBubbleAmmo = Instantiate(_bubbleAmmoPrefab, CurrentAmmoPosition(), Quaternion.identity);
            _currentBubbleAmmo.SetBubbleConfig(GetRandomAmmoBubbleConfig());

            _nextBubbleAmmo = Instantiate(_bubbleAmmoPrefab, NextAmmoPosition(), Quaternion.identity);
            _nextBubbleAmmo.transform.localScale = Vector3.one * _nextAmmoScale;
            _nextBubbleAmmo.SetBubbleConfig(GetRandomAmmoBubbleConfig());
        }
예제 #3
0
        public BubbleAmmoView TakeCurrentAmmo()
        {
            var ammoToShoot = _currentBubbleAmmo;

            _currentBubbleAmmo = _nextBubbleAmmo;
            _currentBubbleAmmo.transform.position   = transform.position;
            _currentBubbleAmmo.transform.localScale = Vector3.one;

            _nextBubbleAmmo = Instantiate(_bubbleAmmoPrefab, NextAmmoPosition(), Quaternion.identity);
            _nextBubbleAmmo.transform.localScale = Vector3.one * _nextAmmoScale;
            _nextBubbleAmmo.SetBubbleConfig(GetRandomAmmoBubbleConfig());

            return(ammoToShoot);
        }
예제 #4
0
        private IEnumerator ShootBubble(BubbleAimTarget aimTarget, BubbleAmmoView ammoView)
        {
            if (aimTarget.Bounces())
            {
                yield return(StartCoroutine(MoveTo(aimTarget.BouncePosition(), ammoView)));
            }

            yield return(StartCoroutine(MoveTo(aimTarget.BubbleSlotView().transform.position, ammoView)));

            OnBubbleAdded(aimTarget.BubbleSlotView(), ammoView.BubbleConfig());

            yield return(null);

            Destroy(ammoView.gameObject);
        }