Ejemplo n.º 1
0
        /// <summary>
        /// Updates the internal subgoals array.  Will rebuild if out of sync.
        /// </summary>
        public override void Update()
        {
            mSubGoals.Clear();

            PC pc = new PC();

            // should check if we are on a level that doesn't have a waypoint

            // get the waypoint's preset unit on the target level
            AreaLevel area = mSource == AreaLevel.None ? pc.Area : mSource;

            foreach (PresetUnit waypoint in PresetUnit.Get(area, UnitType.Object))
            {
                foreach (int classid in new int[] { 119, 145, 156, 157, 237, 238, 288, 323, 324, 398, 402, 429, 494, 496, 511, 539 })
                {
                    if (waypoint.ClassID == classid)
                    {
                        if (Math.Abs(pc.X - waypoint.X) > 5 || Math.Abs(pc.Y - waypoint.Y) > 5)
                        {
                            mSubGoals.Enqueue(new MoveToWaypoint(this, mPriority + 2, area, mTeleport));
                        }
                        goto WAYPOINTFOUND;
                    }
                }
            }
WAYPOINTFOUND:

            // call base classes Update()
            base.Update();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the internal subgoals array.  Will rebuild if out of sync.
        /// </summary>
        public override void Update()          // change name to Update()
        {
            mSubGoals.Clear();

            PC pc = new PC();

            if (pc.Area != mArea)
            {
//				mSubGoals.Enqueue( new MoveToArea( ) );
            }

            if (mLocation == 1)              // this is TownPortal in all ActXTown enums
            {
                // do stuff here
            }
            else
            {
                UnitBase location = new Missile();                 // need to add UnitBase default constructor
                switch (mUnitType)
                {
                case UnitType.NPC:
                    location = new NPC(mLocation);
                    break;

                case UnitType.GameObject:
                    location = new GameObject(mLocation);
                    break;
                }

                if (location.IsValid())
                {
                    if (Math.Abs(pc.X - location.X) > 5 || Math.Abs(pc.Y - location.Y) > 5)
                    {
                        mSubGoals.Enqueue(new MoveToPoint(this, mPriority, location.Point, false));
                    }
                }
                else
                {
                    foreach (PresetUnit unit in PresetUnit.Get(mArea, mUnitType))
                    {
                        if (unit.ClassID == mLocation)
                        {
                            if (Math.Abs(pc.X - unit.X) > 5 || Math.Abs(pc.Y - unit.Y) > 5)
                            {
                                mSubGoals.Enqueue(new MoveToPoint(this, mPriority, unit.Point, false));
                            }
                            break;
                        }
                    }
                }
            }

            // call base classes Update()
            base.Update();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Finds a Path to the given Warps
        /// </summary>
        /// <param name="WarpID">The ID of the warp to path to</param>
        /// <returns></returns>
        public Path FindPathToWarp(int[] WarpID)
        {
            PC Me = new PC();

            PresetUnit[] presets = PresetUnit.Get(Me.Area, UnitType.Warp);

            foreach (PresetUnit p in presets)
            {
                foreach (int i in WarpID)
                {
                    if (p.ClassID == i)
                    {
                        return(FindPath(p));
                    }
                }
            }

            throw new ApplicationException("Could not find the given warp ID");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Finds a Path to the given Warp
        /// </summary>
        /// <returns></returns>
        public Path FindPathToWaypoint()
        {
            PC Me = new PC();

            int[] waypoints = new int[] { 119, 145, 156, 157, 237, 238, 288, 323, 324, 398, 402, 429, 494, 496, 511, 539 };

            PresetUnit[] presets = PresetUnit.Get(Me.Area, UnitType.Object);

            foreach (PresetUnit p in presets)
            {
                foreach (int i in waypoints)
                {
                    if (p.ClassID == i)
                    {
                        return(FindPath(p));
                    }
                }
            }

            throw new ApplicationException("Could not find a waypoint");
        }