예제 #1
0
        private ArrowBase CreateArrow()
        {
            ArrowBase arrow = _arrowFactory.CreateArrow <Arrow>();

            arrow.OnUnStick += AddArrowToQueueUnstick;
            arrow.gameObject.SetActive(false);
            return(arrow);
        }
예제 #2
0
        private void ShotArrow(ArrowBase arrow)
        {
            arrow.gameObject.SetActive(true);
            Rigidbody arrowRigidbody = arrow.GetRigidbody();

            arrow.transform.SetParent(transform);
            arrow.transform.rotation = transform.rotation;
            arrow.transform.position = _arrowStartPosition.position;

            arrowRigidbody.angularVelocity = Vector3.zero;
            arrowRigidbody.velocity        = Vector3.zero;

            arrow.StickStatus = StickStatus.None;

            arrowRigidbody.AddRelativeForce(1000, 0, 0);
            arrow.SetRigidbody(arrowRigidbody);
        }
예제 #3
0
        public override void MonoUpdateFunc()
        {
            if (_time <= 0)
            {
                _time = _shotIntervalTime;
                ArrowBase arrow = _objectsPoolQueue.Dequeue();

                if (arrow == null)
                {
                    arrow = CreateArrow();
                }

                ShotArrow(arrow);
            }
            else
            {
                _time -= Time.deltaTime;
            }
        }
예제 #4
0
 private void AddArrowToQueueUnstick(ArrowBase arrow)
 {
     _objectsPoolQueue.Enqueue(arrow);
 }