private ArrowBase CreateArrow() { ArrowBase arrow = _arrowFactory.CreateArrow <Arrow>(); arrow.OnUnStick += AddArrowToQueueUnstick; arrow.gameObject.SetActive(false); return(arrow); }
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); }
public override void MonoUpdateFunc() { if (_time <= 0) { _time = _shotIntervalTime; ArrowBase arrow = _objectsPoolQueue.Dequeue(); if (arrow == null) { arrow = CreateArrow(); } ShotArrow(arrow); } else { _time -= Time.deltaTime; } }
private void AddArrowToQueueUnstick(ArrowBase arrow) { _objectsPoolQueue.Enqueue(arrow); }