mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-06 21:25:42 +12:00
Add files via upload
This commit is contained in:
parent
14ff669234
commit
b0652c2c83
23 changed files with 2422 additions and 2323 deletions
|
@ -108,6 +108,9 @@ namespace Horse_Isle_Server
|
|||
|
||||
public void Disconnect()
|
||||
{
|
||||
Logger.DebugPrint(ClientSocket.RemoteEndPoint + " has Disconnected.");
|
||||
LoggedIn = false;
|
||||
LoggedinUser = null;
|
||||
Server.ConnectedClients.Remove(this);
|
||||
ClientSocket.Dispose();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ namespace Horse_Isle_Server
|
|||
|
||||
public static string Motd;
|
||||
public static string MapFile;
|
||||
public static string OverlayMapFile;
|
||||
public static string GameDataFile;
|
||||
public static string CrossDomainPolicyFile;
|
||||
public static bool Debug;
|
||||
|
@ -85,9 +84,6 @@ namespace Horse_Isle_Server
|
|||
case "gamedata":
|
||||
GameDataFile = data;
|
||||
break;
|
||||
case "overlaymap":
|
||||
OverlayMapFile = data;
|
||||
break;
|
||||
case "crossdomain":
|
||||
CrossDomainPolicyFile = data;
|
||||
break;
|
||||
|
|
|
@ -233,10 +233,10 @@ namespace Horse_Isle_Server
|
|||
throw new Exception("Userid " + id + " Allready in userext.");
|
||||
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "INSERT INTO UserExt VALUES(@id,@x,@y,0,0,'',5)";
|
||||
sqlCommand.CommandText = "INSERT INTO UserExt VALUES(@id,@x,@y,0,0,'',0)";
|
||||
sqlCommand.Parameters.AddWithValue("@id", id);
|
||||
sqlCommand.Parameters.AddWithValue("@x", Gamedata.NewUserStartX);
|
||||
sqlCommand.Parameters.AddWithValue("@y", Gamedata.NewUserStartY);
|
||||
sqlCommand.Parameters.AddWithValue("@x", Map.NewUserStartX);
|
||||
sqlCommand.Parameters.AddWithValue("@y", Map.NewUserStartY);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Horse_Isle_Server
|
||||
{
|
||||
|
@ -9,15 +10,6 @@ namespace Horse_Isle_Server
|
|||
|
||||
class Gamedata
|
||||
{
|
||||
public static string TileFlags;
|
||||
|
||||
public static int NewUserStartX;
|
||||
public static int NewUserStartY;
|
||||
// Messages
|
||||
public static string NewUserMessage;
|
||||
public static string AreaMessage;
|
||||
public static string NothingMessage;
|
||||
public static string LoginMessage;
|
||||
|
||||
public static void ReadGamedata()
|
||||
{
|
||||
|
@ -45,15 +37,19 @@ namespace Horse_Isle_Server
|
|||
World.Isles.Add(isle);
|
||||
}
|
||||
|
||||
NewUserMessage = gameData.new_user.starting_message;
|
||||
NewUserStartX = gameData.new_user.starting_x;
|
||||
NewUserStartY = gameData.new_user.starting_y;
|
||||
Messages.NewUserMessage = gameData.new_user.starting_message;
|
||||
Map.NewUserStartX = gameData.new_user.starting_x;
|
||||
Map.NewUserStartY = gameData.new_user.starting_y;
|
||||
|
||||
LoginMessage = gameData.messages.login_format;
|
||||
AreaMessage = gameData.messages.area_format;
|
||||
NothingMessage = gameData.messages.nothing_message;
|
||||
Messages.LoginFormat = gameData.messages.login_format;
|
||||
Messages.AreaMessage = gameData.messages.area_format;
|
||||
Messages.NothingMessage = gameData.messages.nothing_message;
|
||||
Messages.MotdFormat = gameData.messages.motd_format;
|
||||
|
||||
TileFlags = gameData.map_flags;
|
||||
JArray overlayTileDepth = gameData.tile_paramaters.overlay_tiles.tile_depth;
|
||||
JArray terrainTilePassibility = gameData.tile_paramaters.terrain_tiles.passibility;
|
||||
Map.OverlayTileDepth = overlayTileDepth.ToObject<int[]>();
|
||||
Map.TerrainTilePassibility = terrainTilePassibility.ToObject<bool[]>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,33 +10,42 @@ namespace Horse_Isle_Server
|
|||
{
|
||||
class Map
|
||||
{
|
||||
public static int[] OverlayTileDepth;
|
||||
public static bool[] TerrainTilePassibility;
|
||||
|
||||
public static Bitmap MapData;
|
||||
public static Bitmap oMapData;
|
||||
|
||||
public static int NewUserStartX;
|
||||
public static int NewUserStartY;
|
||||
public static int GetTileId(int x, int y, bool overlay)
|
||||
{
|
||||
if ((x > MapData.Width || x < 0) || (y > MapData.Height || y < 0)) // Outside map?
|
||||
return 0x01;
|
||||
return 0x1;
|
||||
|
||||
|
||||
if (overlay)
|
||||
return oMapData.GetPixel(x, y).B;
|
||||
return MapData.GetPixel(x, y).R;
|
||||
else
|
||||
return MapData.GetPixel(x, y).B;
|
||||
}
|
||||
public static bool CheckPassable(int x, int y)
|
||||
{
|
||||
return true; // not implemented yet
|
||||
int tileId = GetTileId(x, y, false);
|
||||
bool passable = TerrainTilePassibility[tileId-1];
|
||||
Logger.DebugPrint("Checking tile passibility for tileid: " + tileId + " at " + x + "," + y+" passable: " +passable);
|
||||
return passable;
|
||||
}
|
||||
|
||||
public static void OpenMap()
|
||||
{
|
||||
if(!File.Exists(ConfigReader.MapFile) || !File.Exists(ConfigReader.OverlayMapFile))
|
||||
if(!File.Exists(ConfigReader.MapFile))
|
||||
{
|
||||
Logger.ErrorPrint("Map file not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
MapData = new Bitmap(ConfigReader.MapFile);
|
||||
oMapData = new Bitmap(ConfigReader.OverlayMapFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,10 +8,20 @@ namespace Horse_Isle_Server
|
|||
{
|
||||
class Messages
|
||||
{
|
||||
public static string NewUserMessage;
|
||||
public static string AreaMessage;
|
||||
public static string NothingMessage;
|
||||
public static string LoginFormat;
|
||||
|
||||
public static string LoginMessage(string username)
|
||||
public static string MotdFormat;
|
||||
|
||||
public static string GetMOTD()
|
||||
{
|
||||
return Gamedata.LoginMessage.Replace("%USERNAME%", username);
|
||||
return MotdFormat.Replace("%MOTD%", ConfigReader.Motd);
|
||||
}
|
||||
public static string GetLoginMessage(string username)
|
||||
{
|
||||
return LoginFormat.Replace("%USERNAME%", username);
|
||||
}
|
||||
|
||||
public static string LocationData(int x, int y)
|
||||
|
@ -20,13 +30,13 @@ namespace Horse_Isle_Server
|
|||
try
|
||||
{
|
||||
World.Isle isle = World.GetIsle(x, y);
|
||||
message = Gamedata.AreaMessage.Replace("%AREA%", isle.Name);
|
||||
message = AreaMessage.Replace("%AREA%", isle.Name);
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
int[] itemIds = World.GetDroppedItems(x, y);
|
||||
if (itemIds.Length == 0)
|
||||
message += Gamedata.NothingMessage;
|
||||
message += NothingMessage;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Horse_Isle_Server
|
|||
public const byte PACKET_BASE_STATS = 0x7B;
|
||||
public const byte PACKET_PLACE_INFO = 0x1E;
|
||||
public const byte PACKET_AREA_DEFS = 0x79;
|
||||
public const byte PACKET_ANNOUNCEMENT = 0x7E;
|
||||
public const byte PACKET_TILE_FLAGS = 0x75;
|
||||
|
||||
public const byte AREA_SEPERATOR = 0x5E;
|
||||
|
@ -43,6 +44,7 @@ namespace Horse_Isle_Server
|
|||
public const byte DIRECTION_DOWN = 2;
|
||||
public const byte DIRECTION_LEFT = 3;
|
||||
public const byte DIRECTION_LOGIN = 4;
|
||||
public const byte DIRECTION_NONE = 10;
|
||||
|
||||
|
||||
|
||||
|
@ -69,11 +71,11 @@ namespace Horse_Isle_Server
|
|||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_MOVE);
|
||||
|
||||
ms.WriteByte((byte)((x / 64) + 20)); //1
|
||||
ms.WriteByte((byte)((x % 64) + 20)); //2
|
||||
ms.WriteByte((byte)(((x-4) / 64) + 20)); //1
|
||||
ms.WriteByte((byte)(((x-4) % 64) + 20)); //2
|
||||
|
||||
ms.WriteByte((byte)((y / 64) + 20)); //3
|
||||
ms.WriteByte((byte)((y % 64) + 20)); //4
|
||||
ms.WriteByte((byte)(((y-1) / 64) + 20)); //3
|
||||
ms.WriteByte((byte)(((y-1) % 64) + 20)); //4
|
||||
|
||||
ms.WriteByte((byte)(facing + 20)); //5
|
||||
|
||||
|
@ -91,8 +93,8 @@ namespace Horse_Isle_Server
|
|||
direction -= 20;
|
||||
}
|
||||
|
||||
int ystart = y - 3;
|
||||
int xstart = x - 2;
|
||||
int ystart = y - 4;
|
||||
int xstart = x - 6;
|
||||
|
||||
|
||||
if (direction == DIRECTION_UP)
|
||||
|
@ -102,13 +104,13 @@ namespace Horse_Isle_Server
|
|||
int tileId = Map.GetTileId(xstart + relx, ystart, false);
|
||||
int otileId = Map.GetTileId(xstart + relx, ystart, true);
|
||||
|
||||
if (tileId == 290)
|
||||
tileId -= 100;
|
||||
if (otileId == 290)
|
||||
otileId -= 100;
|
||||
|
||||
ms.WriteByte((byte)tileId);
|
||||
if (tileId == 190)
|
||||
ms.WriteByte((byte)0x5B);
|
||||
ms.WriteByte((byte)otileId);
|
||||
if (otileId == 190)
|
||||
ms.WriteByte((byte)0x5A);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,13 +121,13 @@ namespace Horse_Isle_Server
|
|||
int tileId = Map.GetTileId(xstart, ystart + rely, false);
|
||||
int otileId = Map.GetTileId(xstart, ystart + rely, true);
|
||||
|
||||
if (tileId == 290)
|
||||
tileId -= 100;
|
||||
if (otileId == 290)
|
||||
otileId -= 100;
|
||||
|
||||
ms.WriteByte((byte)tileId);
|
||||
if (tileId == 190)
|
||||
ms.WriteByte((byte)0x5B);
|
||||
ms.WriteByte((byte)otileId);
|
||||
if (otileId == 190)
|
||||
ms.WriteByte((byte)0x5A);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,13 +139,13 @@ namespace Horse_Isle_Server
|
|||
int tileId = Map.GetTileId(xstart + 12, ystart + rely, false);
|
||||
int otileId = Map.GetTileId(xstart + 12, ystart + rely, true);
|
||||
|
||||
if (tileId == 290)
|
||||
tileId -= 100;
|
||||
if (otileId == 290)
|
||||
otileId -= 100;
|
||||
|
||||
ms.WriteByte((byte)tileId);
|
||||
if (tileId == 190)
|
||||
ms.WriteByte((byte)0x5B);
|
||||
ms.WriteByte((byte)otileId);
|
||||
if (otileId == 190)
|
||||
ms.WriteByte((byte)0x5A);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,13 +156,13 @@ namespace Horse_Isle_Server
|
|||
int tileId = Map.GetTileId(xstart + relx, ystart + 9, false);
|
||||
int otileId = Map.GetTileId(xstart + relx, ystart + 9, true);
|
||||
|
||||
if (tileId == 290)
|
||||
tileId -= 100;
|
||||
if (otileId == 290)
|
||||
otileId -= 100;
|
||||
|
||||
ms.WriteByte((byte)tileId);
|
||||
if (tileId == 190)
|
||||
ms.WriteByte((byte)0x5B);
|
||||
ms.WriteByte((byte)otileId);
|
||||
if (otileId == 190)
|
||||
ms.WriteByte((byte)0x5A);
|
||||
}
|
||||
}
|
||||
if (direction == DIRECTION_LOGIN)
|
||||
|
@ -172,13 +174,14 @@ namespace Horse_Isle_Server
|
|||
int tileId = Map.GetTileId(xstart + relx, ystart + rely, false);
|
||||
int otileId = Map.GetTileId(xstart + relx, ystart + rely, true);
|
||||
|
||||
if (tileId == 290)
|
||||
tileId -= 100;
|
||||
if(otileId == 290)
|
||||
otileId -= 100;
|
||||
|
||||
ms.WriteByte((byte)tileId);
|
||||
if (tileId == 190)
|
||||
ms.WriteByte((byte)0x5B);
|
||||
|
||||
ms.WriteByte((byte)otileId);
|
||||
if (otileId == 190)
|
||||
ms.WriteByte((byte)0x5A);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,6 +192,9 @@ namespace Horse_Isle_Server
|
|||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] Packet = ms.ToArray();
|
||||
ms.Dispose();
|
||||
|
||||
Logger.DebugPrint(BitConverter.ToString(Packet).Replace('-', ' '));
|
||||
|
||||
return Packet;
|
||||
}
|
||||
|
||||
|
@ -230,17 +236,6 @@ namespace Horse_Isle_Server
|
|||
return Packet;
|
||||
}
|
||||
|
||||
public static byte[] CreateAreaMessage(int x, int y)
|
||||
{
|
||||
string locationStr = Messages.LocationData(x, y);
|
||||
return CreatePlaceInfo(locationStr);
|
||||
}
|
||||
public static byte[] CreateLoginMessage(string username)
|
||||
{
|
||||
string formattedStr = Messages.LoginMessage(username);
|
||||
return CreateChat(formattedStr,CHAT_BOTTOM_RIGHT);
|
||||
}
|
||||
|
||||
public static byte[] CreateWorldData(int gameTime, int gameDay, int gameYear, string weather)
|
||||
{
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(weather);
|
||||
|
@ -277,17 +272,17 @@ namespace Horse_Isle_Server
|
|||
|
||||
ms.WriteByte(AREA_SEPERATOR);
|
||||
|
||||
ms.WriteByte((byte)((isle.StartX / 64) + 20));
|
||||
ms.WriteByte((byte)((isle.StartX % 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.StartX - 4) / 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.StartX - 4) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)((isle.EndX / 64) + 20));
|
||||
ms.WriteByte((byte)((isle.EndX % 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.EndX - 4) / 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.EndX - 4) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)((isle.StartY / 64) + 20));
|
||||
ms.WriteByte((byte)((isle.StartY % 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.StartY - 1) / 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.StartY - 1) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)((isle.EndY / 64) + 20));
|
||||
ms.WriteByte((byte)((isle.EndY % 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.EndY - 1) / 64) + 20));
|
||||
ms.WriteByte((byte)(((isle.EndY - 1) % 64) + 20));
|
||||
|
||||
ms.WriteByte((byte)isle.Tileset.ToString()[0]);
|
||||
|
||||
|
@ -325,13 +320,15 @@ namespace Horse_Isle_Server
|
|||
return Packet;
|
||||
}
|
||||
|
||||
public static byte[] CreateTileFlags(string tileFlags)
|
||||
public static byte[] CreateTileOverlayFlags(int[] tileDepthFlags)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_TILE_FLAGS);
|
||||
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(tileFlags);
|
||||
ms.Write(strBytes, 0x00, strBytes.Length);
|
||||
foreach(int tileDepthFlag in tileDepthFlags)
|
||||
{
|
||||
ms.WriteByte((byte)tileDepthFlag.ToString()[0]);
|
||||
}
|
||||
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
|
||||
|
@ -366,6 +363,36 @@ namespace Horse_Isle_Server
|
|||
|
||||
return Packet;
|
||||
}
|
||||
public static byte[] CreateAnnouncement(string announcement)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.WriteByte(PACKET_ANNOUNCEMENT);
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(announcement);
|
||||
ms.Write(strBytes, 0x00, strBytes.Length);
|
||||
ms.WriteByte(PACKET_TERMINATOR);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] Packet = ms.ToArray();
|
||||
ms.Dispose();
|
||||
|
||||
return Packet;
|
||||
}
|
||||
|
||||
public static byte[] CreateAreaMessage(int x, int y)
|
||||
{
|
||||
string locationStr = Messages.LocationData(x, y);
|
||||
return CreatePlaceInfo(locationStr);
|
||||
}
|
||||
public static byte[] CreateMotd()
|
||||
{
|
||||
string formattedMotd = Messages.GetMOTD();
|
||||
return CreateAnnouncement(formattedMotd);
|
||||
}
|
||||
public static byte[] CreateLoginMessage(string username)
|
||||
{
|
||||
string formattedStr = Messages.GetLoginMessage(username);
|
||||
return CreateChat(formattedStr, CHAT_BOTTOM_RIGHT);
|
||||
}
|
||||
|
||||
public static byte[] CreateUserInfo(Client client)
|
||||
{
|
||||
|
@ -374,7 +401,7 @@ namespace Horse_Isle_Server
|
|||
throw new Exception("Client is not logged in.");
|
||||
User user = client.LoggedinUser;
|
||||
|
||||
byte[] MovementPacket = CreateMovementPacket(user.X, user.Y, user.CharacterId, DIRECTION_DOWN, DIRECTION_LOGIN, false);
|
||||
byte[] MovementPacket = CreateMovementPacket(user.X, user.Y, user.CharacterId, DIRECTION_DOWN, DIRECTION_LOGIN, true);
|
||||
ms.Write(MovementPacket, 0x00, MovementPacket.Length);
|
||||
|
||||
byte[] LoginMessage = CreateLoginMessage(user.Username);
|
||||
|
@ -399,9 +426,12 @@ namespace Horse_Isle_Server
|
|||
byte[] IsleData = CreateIsleData(World.Isles.ToArray());
|
||||
ms.Write(IsleData, 0x00, IsleData.Length);
|
||||
|
||||
byte[] TileFlags = CreateTileFlags(Gamedata.TileFlags);
|
||||
byte[] TileFlags = CreateTileOverlayFlags(Map.OverlayTileDepth);
|
||||
ms.Write(TileFlags, 0x00, TileFlags.Length);
|
||||
|
||||
byte[] MotdData = CreateMotd();
|
||||
ms.Write(MotdData, 0x00, MotdData.Length);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] Packet = ms.ToArray();
|
||||
ms.Dispose();
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
|
@ -8,6 +10,28 @@ namespace Horse_Isle_Server
|
|||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
/*
|
||||
Bitmap mbmp = new Bitmap("MapData.bmp");
|
||||
Bitmap bmp = new Bitmap("oMapData.bmp");
|
||||
Console.WriteLine(bmp.PixelFormat);
|
||||
Bitmap bbmp = new Bitmap(bmp.Width, bmp.Height, PixelFormat.Format24bppRgb);
|
||||
for(int x = 0; x < bmp.Width; x++)
|
||||
{
|
||||
for(int y = 0; y < bmp.Height; y++)
|
||||
{
|
||||
Color col = mbmp.GetPixel(x, y);
|
||||
Color col2 = bmp.GetPixel(x, y);
|
||||
|
||||
bbmp.SetPixel(x,y,Color.FromArgb(col2.B, 0, col.B));
|
||||
|
||||
}
|
||||
}
|
||||
bbmp.Save("MapData2.bmp", ImageFormat.Bmp);
|
||||
Console.WriteLine("image checked");
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
|
||||
ConfigReader.OpenConfig();
|
||||
CrossDomainPolicy.GetPolicy();
|
||||
|
|
|
@ -13,8 +13,7 @@ db_password=test123
|
|||
db_port=3306
|
||||
|
||||
# Map Data
|
||||
map=MapData.bmp
|
||||
overlaymap=oMapData.bmp
|
||||
map=MapDataCombined.bmp
|
||||
|
||||
# Game Data JSON
|
||||
gamedata=gamedata.json
|
||||
|
|
|
@ -45,33 +45,65 @@ namespace Horse_Isle_Server
|
|||
|
||||
User loggedInUser = sender.LoggedinUser;
|
||||
byte movementDirection = packet[1];
|
||||
switch(movementDirection)
|
||||
|
||||
if(movementDirection == PacketBuilder.MOVE_UP)
|
||||
{
|
||||
if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y - 1))
|
||||
{
|
||||
case PacketBuilder.MOVE_UP:
|
||||
if(Map.CheckPassable(loggedInUser.X, loggedInUser.Y+1))
|
||||
loggedInUser.Y -= 1;
|
||||
byte[] moveUpResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, PacketBuilder.DIRECTION_UP, PacketBuilder.DIRECTION_UP, true);
|
||||
sender.SendPacket(moveUpResponse);
|
||||
break;
|
||||
case PacketBuilder.MOVE_LEFT:
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] moveUpResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, PacketBuilder.DIRECTION_UP, PacketBuilder.DIRECTION_NONE, false);
|
||||
sender.SendPacket(moveUpResponse);
|
||||
}
|
||||
}
|
||||
else if(movementDirection == PacketBuilder.MOVE_LEFT)
|
||||
{
|
||||
if (Map.CheckPassable(loggedInUser.X - 1, loggedInUser.Y))
|
||||
{
|
||||
loggedInUser.X -= 1;
|
||||
byte[] moveLeftResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, PacketBuilder.DIRECTION_LEFT, PacketBuilder.DIRECTION_LEFT, true);
|
||||
sender.SendPacket(moveLeftResponse);
|
||||
break;
|
||||
case PacketBuilder.MOVE_RIGHT:
|
||||
if (Map.CheckPassable(loggedInUser.X +1 , loggedInUser.Y))
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] moveLeftResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, PacketBuilder.DIRECTION_LEFT, PacketBuilder.DIRECTION_NONE, false);
|
||||
sender.SendPacket(moveLeftResponse);
|
||||
}
|
||||
}
|
||||
else if(movementDirection == PacketBuilder.MOVE_RIGHT)
|
||||
{
|
||||
if (Map.CheckPassable(loggedInUser.X + 1, loggedInUser.Y))
|
||||
{
|
||||
loggedInUser.X += 1;
|
||||
byte[] moveRightResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, PacketBuilder.DIRECTION_RIGHT, PacketBuilder.DIRECTION_RIGHT, true);
|
||||
sender.SendPacket(moveRightResponse);
|
||||
break;
|
||||
case PacketBuilder.MOVE_DOWN:
|
||||
byte[] moveLeftResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, PacketBuilder.DIRECTION_RIGHT, PacketBuilder.DIRECTION_RIGHT, true);
|
||||
sender.SendPacket(moveLeftResponse);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] moveLeftResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, PacketBuilder.DIRECTION_RIGHT, PacketBuilder.DIRECTION_NONE, false);
|
||||
sender.SendPacket(moveLeftResponse);
|
||||
}
|
||||
}
|
||||
else if(movementDirection == PacketBuilder.MOVE_DOWN)
|
||||
{
|
||||
if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y + 1))
|
||||
{
|
||||
loggedInUser.Y += 1;
|
||||
byte[] moveDownResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, PacketBuilder.DIRECTION_DOWN, PacketBuilder.DIRECTION_DOWN, true);
|
||||
sender.SendPacket(moveDownResponse);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] moveDownResponse = PacketBuilder.CreateMovementPacket(loggedInUser.X, loggedInUser.Y, loggedInUser.CharacterId, PacketBuilder.DIRECTION_DOWN, PacketBuilder.DIRECTION_NONE, false);
|
||||
sender.SendPacket(moveDownResponse);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
byte[] tileData = PacketBuilder.CreateAreaMessage(loggedInUser.X, loggedInUser.Y);
|
||||
sender.SendPacket(tileData);
|
||||
|
|
Loading…
Add table
Reference in a new issue