Ejemplo n.º 1
0
        protected override void SpecialPath(ManagerHelper mH)
        {
            //do i have friends
            NPC friend = mH.GetNPCManager().GetClosestInList(mH.GetNPCManager().GetAllies(affiliation), this);

            if (friend != null)
            {
                float closestDistancetoTarget = float.PositiveInfinity;
                target = null;

                foreach (var team in mH.GetGametype().GetTeams())
                {
                    if (team != affiliation)
                    {
                        NPC closestTargetForTeam = mH.GetNPCManager()
                                                   .GetClosestInList(mH.GetNPCManager().GetAllies(team),
                                                                     friend.GetOriginPosition());

                        if (closestTargetForTeam != null)
                        {
                            float closestDiestanceToTargetForTeam = PathHelper.DistanceSquared(
                                closestTargetForTeam.GetOriginPosition(), friend.GetOriginPosition());

                            if (closestDiestanceToTargetForTeam < closestDistancetoTarget)
                            {
                                target = closestTargetForTeam;
                                closestDistancetoTarget = closestDiestanceToTargetForTeam;
                            }
                        }
                    }
                }
            }
            Vector2 destination;

            //if so
            if (friend != null && target != null)
            {
                //we can now get a midpoint
                destination = PathHelper.MidPoint(friend.GetOriginPosition(), target.GetOriginPosition());
                //and wedge ourselves in
                mH.GetPathHelper().FindClearPath(GetOriginPosition(), destination, mH, path);
            }
            //else, we shall wander the planes between heaven and hell
            else
            {
                RandomPath(mH);
            }
        }