示例#1
0
        public static List <short> GetMapBorder(MapScrollType bordertype)
        {
            List <short> results = new List <short>();

            switch (bordertype)
            {
            case MapScrollType.TOP:
                results.AddRange(GetLineFromDirection(0, 14, DirectionsEnum.DIRECTION_EAST));
                results.AddRange(GetLineFromDirection(14, 14, DirectionsEnum.DIRECTION_EAST));
                break;

            case MapScrollType.LEFT:
                results.AddRange(GetLineFromDirection(14, 19, DirectionsEnum.DIRECTION_SOUTH));
                results.AddRange(GetLineFromDirection(0, 19, DirectionsEnum.DIRECTION_SOUTH));
                break;

            case MapScrollType.BOTTOM:
                results.AddRange(GetLineFromDirection(546, 14, DirectionsEnum.DIRECTION_WEST));
                results.AddRange(GetLineFromDirection(560, 14, DirectionsEnum.DIRECTION_WEST));
                break;

            case MapScrollType.RIGHT:
                results.AddRange(GetLineFromDirection(27, 19, DirectionsEnum.DIRECTION_SOUTH));
                results.AddRange(GetLineFromDirection(13, 19, DirectionsEnum.DIRECTION_SOUTH));
                break;

            default:
                break;
            }
            return(results);
        }
        public static short SearchScrollCellId(short cellid, MapScrollType type, MapRecord map)
        {
            var defaultCell = GetScrollDefaultCellId(cellid, type);
            var cells       = ShapesProvider.GetMapBorder(GetOposedTransition(type));
            var walkables   = cells.FindAll(x => map.Walkable(x));

            return(walkables.Count == 0 ? map.RandomWalkableCell() : walkables[new AsyncRandom().Next(0, walkables.Count - 1)]);
        }
        public static MapScrollType GetOposedTransition(MapScrollType type)
        {
            switch (type)
            {
            case MapScrollType.TOP:
                return(MapScrollType.BOTTOM);

            case MapScrollType.LEFT:
                return(MapScrollType.RIGHT);

            case MapScrollType.BOTTOM:
                return(MapScrollType.TOP);

            case MapScrollType.RIGHT:
                return(MapScrollType.LEFT);
            }
            throw new Exception("What is that MapScrollType dude?");
        }
        public static short GetScrollDefaultCellId(short cellid, MapScrollType type)
        {
            switch (type)
            {
            case MapScrollType.TOP:
                return((short)(cellid + 532));

            case MapScrollType.LEFT:
                return((short)(cellid + 27));

            case MapScrollType.BOTTOM:
                return((short)(cellid - 532));;

            case MapScrollType.RIGHT:
                return((short)(cellid - 27));

            default:
                return(0);
            }
        }
        public static sbyte GetScrollDirection(MapScrollType type)
        {
            switch (type)
            {
            case MapScrollType.TOP:
                return(6);

            case MapScrollType.LEFT:
                return(4);

            case MapScrollType.BOTTOM:
                return(2);

            case MapScrollType.RIGHT:
                return(0);

            default:
                return(0);
            }
        }
        public static int GetOverrideScrollMapId(int mapid, MapScrollType type)
        {
            var scroll = ScrollActions.Find(x => x.MapId == mapid);

            if (scroll != null)
            {
                switch (type)
                {
                case MapScrollType.TOP:
                    return(scroll.TopMapId);

                case MapScrollType.LEFT:
                    return(scroll.LeftMapId);

                case MapScrollType.BOTTOM:
                    return(scroll.BottomMapId);

                case MapScrollType.RIGHT:
                    return(scroll.RightMapId);
                }
            }
            return(-1);
        }
示例#7
0
        public static void HandleChangeMap(ChangeMapMessage message, WorldClient client)
        {
            MapScrollType scrollType = MapScrollType.UNDEFINED;

            if (client.Character.Map.LeftMap == message.mapId)
            {
                scrollType = MapScrollType.LEFT;
            }
            if (client.Character.Map.RightMap == message.mapId)
            {
                scrollType = MapScrollType.RIGHT;
            }
            if (client.Character.Map.DownMap == message.mapId)
            {
                scrollType = MapScrollType.BOTTOM;
            }
            if (client.Character.Map.TopMap == message.mapId)
            {
                scrollType = MapScrollType.TOP;
            }

            if (scrollType != MapScrollType.UNDEFINED)
            {
                int   overrided = MapScrollActionRecord.GetOverrideScrollMapId(client.Character.Map.Id, scrollType);
                short cellid    = MapScrollActionRecord.GetScrollDefaultCellId(client.Character.Record.CellId, scrollType);
                client.Character.Record.Direction = MapScrollActionRecord.GetScrollDirection(scrollType);

                int teleportMapId = overrided != -1 ? overrided : message.mapId;
                if (overrided == 0)
                {
                    teleportMapId = message.mapId;
                }
                MapRecord teleportedMap = MapRecord.GetMap(teleportMapId);
                if (teleportedMap != null)
                {
                    cellid = teleportedMap.Walkable(cellid) ? cellid : MapScrollActionRecord.SearchScrollCellId(cellid, scrollType, teleportedMap);
                    client.Character.Teleport(teleportMapId, cellid);
                }
                else
                {
                    client.Character.NotificationError("This map cannot be founded");
                }
            }
            else
            {
                scrollType = MapScrollActionRecord.GetScrollTypeFromCell(client.Character.Record.CellId);
                if (scrollType == MapScrollType.UNDEFINED)
                {
                    client.Character.NotificationError("Unknown Map Scroll Action...");
                }
                else
                {
                    int       overrided     = MapScrollActionRecord.GetOverrideScrollMapId(client.Character.Map.Id, scrollType);
                    short     cellid        = MapScrollActionRecord.GetScrollDefaultCellId(client.Character.Record.CellId, scrollType);
                    MapRecord teleportedMap = MapRecord.GetMap(overrided);
                    if (teleportedMap != null)
                    {
                        client.Character.Record.Direction = MapScrollActionRecord.GetScrollDirection(scrollType);
                        cellid = teleportedMap.Walkable(cellid) ? cellid : MapScrollActionRecord.SearchScrollCellId(cellid, scrollType, teleportedMap);
                        client.Character.Teleport(overrided, cellid);
                    }
                    else
                    {
                        client.Character.NotificationError("This map cannot be founded");
                    }
                }
            }
        }