示例#1
0
        private void CompanionEndCleanup()
        {
            NPC companion = this.StateMachine.Companion;

            typeof(NPC).GetField("previousEndPoint", BindingFlags.NonPublic | BindingFlags.Instance)
            .SetValue(companion, companion.getTileLocationPoint());
            companion.checkSchedule(Game1.timeOfDay);

            // Set end of route behavior, message, and facingDirection
            MethodInfo getRouteEndBehaviorFunction = typeof(NPC).GetMethod("getRouteEndBehaviorFunction",
                                                                           BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(string), typeof(string) }, null);

            if (this.companionRescheduleEndRouteBehavior != null && this.companionRescheduleEndRouteBehavior != "")
            {
                PathFindController.endBehavior eB = (PathFindController.endBehavior)getRouteEndBehaviorFunction.Invoke(companion,
                                                                                                                       new object[] { this.companionRescheduleEndRouteBehavior, this.companionRescheduleEndRouteDialogue });
                eB(companion, companion.currentLocation);
            }
            if (this.companionRescheduleEndRouteDialogue != null && this.companionRescheduleEndRouteDialogue != "")
            {
                companion.CurrentDialogue.Push(new Dialogue(Game1.content.LoadString(this.companionRescheduleEndRouteDialogue), companion));
            }
            companion.faceDirection(this.companionRescheduleFacingDirection);

            if (companion.Schedule == null && this.StateMachine.CompanionManager.Farmer.spouse != null &&
                this.StateMachine.CompanionManager.Farmer.spouse.Equals(companion.Name))
            {
                companion.marriageDuties();
            }
        }
示例#2
0
 public PathFindController(Character c, GameLocation location, PathFindController.isAtEnd endFunction, int finalFacingDirection, bool eraseOldPathController, PathFindController.endBehavior endBehaviorFunction, int limit, Point endPoint)
 {
     this.limit     = limit;
     this.character = c;
     if (c is NPC && (c as NPC).CurrentDialogue.Count > 0 && (c as NPC).CurrentDialogue.Peek().removeOnNextMove)
     {
         (c as NPC).CurrentDialogue.Pop();
     }
     this.location            = location;
     this.endFunction         = endFunction == null ? new PathFindController.isAtEnd(PathFindController.isAtEndPoint) : endFunction;
     this.endBehaviorFunction = endBehaviorFunction;
     if (endPoint == Point.Zero)
     {
         endPoint = new Point((int)c.getTileLocation().X, (int)c.getTileLocation().Y);
     }
     this.finalFacingDirection = finalFacingDirection;
     if (!(this.character is NPC) && !Game1.currentLocation.Name.Equals(location.Name) && (endFunction == new PathFindController.isAtEnd(PathFindController.isAtEndPoint) && endPoint.X > 0) && endPoint.Y > 0)
     {
         this.character.position = new Vector2((float)(endPoint.X * Game1.tileSize), (float)(endPoint.Y * Game1.tileSize - Game1.tileSize / 2));
     }
     else
     {
         this.pathToEndPoint = PathFindController.findPath(new Point((int)c.getTileLocation().X, (int)c.getTileLocation().Y), endPoint, endFunction, location, this.character, limit);
         if (this.pathToEndPoint != null)
         {
             return;
         }
         FarmHouse farmHouse = location as FarmHouse;
     }
 }
示例#3
0
        private static void SpouseFindPath(FarmHouse farmHouse,
                                           NPC npc,
                                           Point endPoint,
                                           int finalFacingDirection,
                                           PathFindController.endBehavior endBehaviorFunction,
                                           bool clearMarriageDialogues)
        {
            Point currentPosition = npc.getTileLocationPoint();

            if (npc.currentLocation.Equals(farmHouse) && currentPosition != endPoint)
            {
                // To set clearMarriageDialogues we need the most complicated constructor...
                npc.controller = new PathFindController(
                    npc,
                    farmHouse,
                    PathFindController.isAtEndPoint,
                    finalFacingDirection,
                    false,
                    endBehaviorFunction,
                    10000,
                    endPoint,
                    clearMarriageDialogues
                    );
            }
        }
示例#4
0
 public PathFindController(Character c, GameLocation location, Point endPoint, int finalFacingDirection, PathFindController.endBehavior endBehaviorFunction, int limit)
     : this(c, location, new PathFindController.isAtEnd(PathFindController.isAtEndPoint), finalFacingDirection, false, (PathFindController.endBehavior)null, limit, endPoint)
 {
     this.endPoint            = endPoint;
     this.endBehaviorFunction = endBehaviorFunction;
 }