Exemplo n.º 1
0
 private static void RescheduleEvent(object senderEvent)
 {
     if (m_waveCounter > WAVES_IN_SHOWER)
     {
         TimeSpan time = CalculateShowerTime(MySession.Static.EnvironmentHostility);
         MyGlobalEvents.RescheduleEvent((MyGlobalEventBase)senderEvent, time);
         m_waveCounter   = -1;
         m_currentTarget = null;
         MySyncMeteorShower.UpdateShowerTarget(m_currentTarget);
     }
     else
     {
         TimeSpan nextWave = TimeSpan.FromSeconds(m_meteorcount / 5f + MyUtils.GetRandomFloat(2, 5));
         MyGlobalEvents.RescheduleEvent((MyGlobalEventBase)senderEvent, nextWave);
     }
 }
Exemplo n.º 2
0
        private static void MeteorWaveInternal(object senderEvent)
        {
            if (MySession.Static.EnvironmentHostility == MyEnvironmentHostilityEnum.SAFE)
            {
                Debug.Assert(false, "Meteor shower shouldnt be enabled in safe enviroment");
                ((MyGlobalEventBase)senderEvent).Enabled = false;
                return;
            }
            m_waveCounter++;
            SetupDirVectors();
            if (m_waveCounter == 0)
            {
                ClearMeteorList();
                if (m_targetList.Count == 0)
                {
                    GetTargets();
                    if (m_targetList.Count == 0)
                    {
                        m_waveCounter = WAVES_IN_SHOWER + 1;
                        RescheduleEvent(senderEvent);
                        return;
                    }
                }
                m_currentTarget = m_targetList.ElementAt(MyUtils.GetRandomInt(m_targetList.Count - 1));
                MySyncMeteorShower.UpdateShowerTarget(m_currentTarget);
                m_targetList.Remove(m_currentTarget.Value);
                m_meteorcount  = (int)(Math.Pow(m_currentTarget.Value.Radius, 2) * Math.PI / 3000);
                m_meteorcount /= (MySession.Static.EnvironmentHostility == MyEnvironmentHostilityEnum.CATACLYSM || MySession.Static.EnvironmentHostility == MyEnvironmentHostilityEnum.CATACLYSM_UNREAL) ? 1 : 10;
                m_meteorcount  = MathHelper.Clamp(m_meteorcount, 1, 60);
            }

            RescheduleEvent(senderEvent);
            CheckTargetValid();
            if (m_waveCounter < 0)
            {
                return;
            }

            StartWave();
        }