Beispiel #1
0
 public void UpdateRocketFiredStatus(TimedRocket rocket)
 {
     if (playerGroupedRockets.TryGetValue(StatMaster.isMP ? PlayerMachine.GetLocal().Player.NetworkId : 0, out Dictionary <KeyCode, HashSet <TimedRocket> > groupedRockets))
     {
         RocketScript rocketScript = rocket.GetComponent <RocketScript>();
         if (rocketScript != null)
         {
             if (groupedRockets.TryGetValue(rocketScript.GroupFireKey.GetKey(0), out HashSet <TimedRocket> rockets))
             {
                 rockets.Remove(rocket);
             }
         }
     }
 }
Beispiel #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);
        }