Beispiel #1
0
        public bool Use(User target)
        {
            Logger.DebugFormat("warp: {0} from {1} ({2},{3}) to {4} ({5}, {6}", target.Name, SourceMap.Name, X, Y,
                               DestinationMapName, DestinationX, DestinationY);
            switch (WarpType)
            {
            case WarpType.Map:
                Map map;
                if (SourceMap.World.MapCatalog.TryGetValue(DestinationMapName, out map))
                {
                    Thread.Sleep(250);
                    target.Teleport(map.Id, DestinationX, DestinationY);
                    return(true);
                }
                Logger.ErrorFormat("User {0} tried to warp to nonexistent map {1} from {2}: {3},{4}", target.Name,
                                   DestinationMapName, SourceMap.Name, X, Y);
                break;

            case WarpType.WorldMap:
                WorldMap wmap;
                if (SourceMap.World.WorldMaps.TryGetValue(DestinationMapName, out wmap))
                {
                    SourceMap.Remove(target);
                    target.SendWorldMap(wmap);
                    SourceMap.World.Maps[Hybrasyl.Constants.LAG_MAP].Insert(target, 5, 5, false);
                    return(true);
                }
                Logger.ErrorFormat("User {0} tried to warp to nonexistent worldmap {1} from {2}: {3},{4}",
                                   target.Name,
                                   DestinationMapName, SourceMap.Name, X, Y);
                break;
            }
            return(false);
        }