コード例 #1
0
        public LogicGameObject EvaluateTargets(LogicMovementComponent component)
        {
            if (component != null && !component.IsFlying() && this.m_targetListSize > 1)
            {
                bool fullChar = true;

                int count = 0;

                int minCost = 0x7FFFFFFF;
                int maxCost = 0;

                LogicGameObject minCostTarget = null;

                for (int i = 0; i < this.m_targetListSize; i++)
                {
                    LogicGameObject target = this.m_targets[i];

                    if (target != null)
                    {
                        LogicCombatComponent combatComponent = component.GetParent().GetCombatComponent();

                        if (combatComponent != null && combatComponent.IsInRange(target))
                        {
                            return(target);
                        }

                        int targetCost = component.EvaluateTargetCost(target);

                        if (target.GetMovementComponent() == null)
                        {
                            fullChar = false;
                        }

                        if (targetCost > maxCost)
                        {
                            maxCost = targetCost;
                        }

                        if (targetCost < minCost)
                        {
                            minCost       = targetCost;
                            minCostTarget = target;
                        }

                        ++count;
                    }
                }

                if (count >= 2 && fullChar && minCost != 0x7FFFFFFF && maxCost - minCost < this.m_charVersusCharRandomDistance)
                {
                    return(this.m_targets[component.GetParent().GetGlobalID() % count]);
                }

                return(minCostTarget);
            }

            return(this.m_targets[0]);
        }