Exemplo n.º 1
0
        public static void Update()
        {
            if ((MyMinerGame.TotalTimeInMilliseconds - m_lastActualizeTime) > ACTUALIZE_TIME)
            {
                m_lastActualizeTime = MyMinerGame.TotalTimeInMilliseconds;

                if (MyHud.GetHudEnemiesOnScreen().Count > 0 && CurrentTarget == null)
                {
                    SwitchNextTarget(true);
                    return;
                }

                if (CurrentTarget != null && !MyHud.GetHudEnemiesOnScreen().Contains(CurrentTarget))
                {
                    SwitchNextTarget(true);
                    return;
                }

                MySmallShip smallShipTarget = CurrentTarget as MySmallShip;
                if (smallShipTarget != null)
                {
                    if (smallShipTarget.IsEngineTurnedOff())
                    {
                        SwitchNextTarget(true);
                        return;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static MyEntity SwitchNextTarget(bool forward)
        {
            MyEntity newTarget = null;

            m_targets.Clear();
            m_targets.AddRange(MyHud.GetHudEnemiesOnScreen());

            bool needActualizeIndex = NeedActualizeIndex();

            int targetsLeft = m_targets.Count;

            while (targetsLeft > 0)
            {
                if (needActualizeIndex)
                {
                    m_currentIndex         = 0;
                    m_lastOwnerWorldMatrix = m_owner.WorldMatrix;
                    needActualizeIndex     = false;
                }
                else
                {
                    m_currentIndex += forward ? 1 : -1;
                }

                if (m_currentIndex >= m_targets.Count)
                {
                    m_currentIndex = 0;
                }
                if (m_currentIndex < 0)
                {
                    m_currentIndex = m_targets.Count - 1;
                }
                if (CanSee(m_owner, m_targets[m_currentIndex]) == null)
                {
                    newTarget = m_targets[m_currentIndex];
                    break;
                }
                targetsLeft--;
            }
            m_lastTimeTargeting = MyMinerGame.TotalTimeInMilliseconds;

            if (m_owner is MySmallShip)
            {
                (m_owner as MySmallShip).TargetEntity = newTarget;
            }

            m_currentTarget = newTarget;
            return(m_currentTarget);
        }