コード例 #1
0
        public void handleWarps(Rectangle position)
        {
            Warp w = location.isCollidingWithWarpOrDoor(position);

            if (w == null)
            {
                return;
            }
            if (w.TargetName == "Trailer" && Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade"))
            {
                w = new Warp(w.X, w.Y, "Trailer_Big", 13, 24, flipFarmer: false);
            }
            if (character is NPC && (character as NPC).isMarried() && (character as NPC).followSchedule)
            {
                NPC i = character as NPC;
                if (location is FarmHouse)
                {
                    w = new Warp(w.X, w.Y, "BusStop", 0, 23, flipFarmer: false);
                }
                if (location is BusStop && w.X <= 0)
                {
                    w = new Warp(w.X, w.Y, i.getHome().name, (i.getHome() as FarmHouse).getEntryLocation().X, (i.getHome() as FarmHouse).getEntryLocation().Y, flipFarmer: false);
                }
                if (i.temporaryController != null && i.controller != null)
                {
                    i.controller.location = Game1.getLocationFromName(w.TargetName);
                }
            }
            location = Game1.getLocationFromName(w.TargetName);
            if (character is NPC && (w.TargetName == "FarmHouse" || w.TargetName == "Cabin") && (character as NPC).isMarried() && (character as NPC).getSpouse() != null)
            {
                location = Utility.getHomeOfFarmer((character as NPC).getSpouse());
                w        = new Warp(w.X, w.Y, location.name, (location as FarmHouse).getEntryLocation().X, (location as FarmHouse).getEntryLocation().Y, flipFarmer: false);
                if ((character as NPC).temporaryController != null && (character as NPC).controller != null)
                {
                    (character as NPC).controller.location = location;
                }
                Game1.warpCharacter(character as NPC, location, new Vector2(w.TargetX, w.TargetY));
            }
            else
            {
                Game1.warpCharacter(character as NPC, w.TargetName, new Vector2(w.TargetX, w.TargetY));
            }
            if (isPlayerPresent() && location.doors.ContainsKey(new Point(w.X, w.Y)))
            {
                location.playSoundAt("doorClose", new Vector2(w.X, w.Y), NetAudio.SoundContext.NPC);
            }
            if (isPlayerPresent() && location.doors.ContainsKey(new Point(w.TargetX, w.TargetY - 1)))
            {
                location.playSoundAt("doorClose", new Vector2(w.TargetX, w.TargetY), NetAudio.SoundContext.NPC);
            }
            if (pathToEndPoint.Count > 0)
            {
                pathToEndPoint.Pop();
            }
            while (pathToEndPoint.Count > 0 && (Math.Abs(pathToEndPoint.Peek().X - character.getTileX()) > 1 || Math.Abs(pathToEndPoint.Peek().Y - character.getTileY()) > 1))
            {
                pathToEndPoint.Pop();
            }
        }