Пример #1
0
        public static List <short> GetMapBorder(MapScrollEnum bordertype)
        {
            List <short> results = new List <short>();

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

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

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

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

            default:
                break;
            }
            return(results);
        }
Пример #2
0
        public static ushort SearchScrollCellId(ushort cellid, MapScrollEnum type, MapRecord map)
        {
            var defaultCell = GetScrollDefaultCellId(cellid, type);
            var cells       = CellShapesProvider.GetMapBorder(GetOposedTransition(type));
            var walkables   = cells.FindAll(x => map.Walkable((ushort)x));

            return(walkables.Count == 0 ? map.RandomWalkableCell() : (ushort)walkables[new AsyncRandom().Next(0, walkables.Count - 1)]);
        }
Пример #3
0
        public static MapScrollEnum GetOposedTransition(MapScrollEnum type)
        {
            switch (type)
            {
            case MapScrollEnum.Top:
                return(MapScrollEnum.Bottom);

            case MapScrollEnum.Left:
                return(MapScrollEnum.Right);

            case MapScrollEnum.Bottom:
                return(MapScrollEnum.Top);

            case MapScrollEnum.Right:
                return(MapScrollEnum.Left);
            }
            throw new Exception("What is that MapScrollType dude?");
        }
Пример #4
0
        public static sbyte GetScrollDirection(MapScrollEnum type)
        {
            switch (type)
            {
            case MapScrollEnum.Top:
                return(6);

            case MapScrollEnum.Left:
                return(4);

            case MapScrollEnum.Bottom:
                return(2);

            case MapScrollEnum.Right:
                return(0);

            default:
                return(0);
            }
        }
Пример #5
0
        public static ushort GetScrollDefaultCellId(ushort cellid, MapScrollEnum type)
        {
            switch (type)
            {
            case MapScrollEnum.Top:
                return((ushort)(cellid + 532));

            case MapScrollEnum.Left:
                return((ushort)(cellid + 27));

            case MapScrollEnum.Bottom:
                return((ushort)(cellid - 532));;

            case MapScrollEnum.Right:
                return((ushort)(cellid - 27));

            default:
                return(0);
            }
        }
Пример #6
0
        public static int GetOverrideScrollMapId(int mapid, MapScrollEnum type)
        {
            var scroll = ScrollActions.Find(x => x.MapId == mapid);

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

                case MapScrollEnum.Left:
                    return(scroll.LeftMapId);

                case MapScrollEnum.Bottom:
                    return(scroll.BottomMapId);

                case MapScrollEnum.Right:
                    return(scroll.RightMapId);
                }
            }
            return(-1);
        }
Пример #7
0
        public static void ChangeMapMessage(ChangeMapMessage message, WorldClient client)
        {
            MapScrollEnum scrollType = MapScrollEnum.UNDEFINED;

            if (client.Character.Map.LeftMap == message.mapId)
            {
                scrollType = MapScrollEnum.Left;
            }
            if (client.Character.Map.RightMap == message.mapId)
            {
                scrollType = MapScrollEnum.Right;
            }
            if (client.Character.Map.DownMap == message.mapId)
            {
                scrollType = MapScrollEnum.Bottom;
            }
            if (client.Character.Map.TopMap == message.mapId)
            {
                scrollType = MapScrollEnum.Top;
            }

            if (scrollType != MapScrollEnum.UNDEFINED)
            {
                int    overrided = ScrollActionRecord.GetOverrideScrollMapId(client.Character.Map.Id, scrollType);
                ushort cellid    = ScrollActionRecord.GetScrollDefaultCellId(client.Character.Record.CellId, scrollType);
                client.Character.Record.Direction = ScrollActionRecord.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 : ScrollActionRecord.SearchScrollCellId(cellid, scrollType, teleportedMap);
                    client.Character.Teleport(teleportMapId, cellid);
                }
                else
                {
                    client.Character.ReplyError("This map cannot be founded");
                }
            }
            else
            {
                scrollType = ScrollActionRecord.GetScrollTypeFromCell((short)client.Character.Record.CellId);
                if (scrollType == MapScrollEnum.UNDEFINED)
                {
                    client.Character.ReplyError("Unknown Map Scroll Action...");
                }
                else
                {
                    int       overrided     = ScrollActionRecord.GetOverrideScrollMapId(client.Character.Map.Id, scrollType);
                    ushort    cellid        = ScrollActionRecord.GetScrollDefaultCellId(client.Character.Record.CellId, scrollType);
                    MapRecord teleportedMap = MapRecord.GetMap(overrided);
                    if (teleportedMap != null)
                    {
                        client.Character.Record.Direction = ScrollActionRecord.GetScrollDirection(scrollType);
                        cellid = teleportedMap.Walkable(cellid) ? cellid : ScrollActionRecord.SearchScrollCellId(cellid, scrollType, teleportedMap);
                        client.Character.Teleport(overrided, cellid);
                    }
                    else
                    {
                        client.Character.ReplyError("This map cannot be founded");
                    }
                }
            }
        }