/// <summary>
 ///     Launch the rocket.
 /// </summary>
 public void Launch()
 {
     if (_tr.hasFired)
     {
         return;
     }
     _tr.hasFired = true;
     _tr.StartCoroutine(_tr.Fire(0));
 }
Exemple #2
0
        public IEnumerator LaunchRocketFromGroup(int id, KeyCode key)
        {
            launchStarted = true;
            float defaultDelay = 0.25f;

            if (playerGroupedRockets.TryGetValue(id, out Dictionary <KeyCode, HashSet <TimedRocket> > timedRocketDict))
            {
                if (timedRocketDict.TryGetValue(key, out HashSet <TimedRocket> timedRockets))
                {
                    if (timedRockets.Count > 0)
                    {
                        TimedRocket rocket = timedRockets.First();
                        timedRockets.Remove(rocket);
                        if (rocket != null)
                        {
                            RocketScript rocketScript = rocket.GetComponent <RocketScript>();
                            if (rocketScript != null)
                            {
                                rocket.Fire(0f);
                                rocket.hasFired    = true;
                                rocket.hasExploded = false;
                                if (rocketScript.autoGrabberRelease && rocket.grabbers.Count > 0)
                                {
                                    foreach (var grabber in rocket.grabbers)
                                    {
                                        grabber?.StartCoroutine(grabber.IEBreakJoint());
                                    }
                                }
                                defaultDelay = Mathf.Clamp(rocketScript.groupFireRate, 0.1f, 1f);
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < defaultDelay * 100; i++)
            {
                yield return(new WaitForFixedUpdate());
            }

            launchStarted = false;
            yield return(null);
        }