From a47f73d52380ce83db1ed5f96da606f5535211f3 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 17:38:59 +0300 Subject: [PATCH 01/23] fix texture names --- DangerousD/Content/Content.mgcb | 8 ++++---- DangerousD/Content/{MenuFon2.jpg => menuFon2.jpg} | Bin .../{SmokeAnimation2.png => smokeAnimation2.png} | Bin 3 files changed, 4 insertions(+), 4 deletions(-) rename DangerousD/Content/{MenuFon2.jpg => menuFon2.jpg} (100%) rename DangerousD/Content/{SmokeAnimation2.png => smokeAnimation2.png} (100%) diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index ea7bb60..b3ce6cc 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -140,7 +140,7 @@ /processorParam:TextureFormat=Color /build:menuFon.jpg -#begin MenuFon2.jpg +#begin menuFon2.jpg /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -150,7 +150,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:MenuFon2.jpg +/build:menuFon2.jpg #begin menuFon3.jpg /importer:TextureImporter @@ -255,7 +255,7 @@ /processorParam:Quality=Best /build:sounds/shotgun_shot.mp3 -#begin SmokeAnimation2.png +#begin smokeAnimation2.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -265,7 +265,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:SmokeAnimation2.png +/build:smokeAnimation2.png #begin textboxbackground1-1.png /importer:TextureImporter diff --git a/DangerousD/Content/MenuFon2.jpg b/DangerousD/Content/menuFon2.jpg similarity index 100% rename from DangerousD/Content/MenuFon2.jpg rename to DangerousD/Content/menuFon2.jpg diff --git a/DangerousD/Content/SmokeAnimation2.png b/DangerousD/Content/smokeAnimation2.png similarity index 100% rename from DangerousD/Content/SmokeAnimation2.png rename to DangerousD/Content/smokeAnimation2.png From f72cc03c660e3d500f1b8a5f831edd128b6b0491 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 17:45:17 +0300 Subject: [PATCH 02/23] remove try catch in network --- DangerousD/GameCore/Network/NetworkManager.cs | 140 +++++++----------- 1 file changed, 52 insertions(+), 88 deletions(-) diff --git a/DangerousD/GameCore/Network/NetworkManager.cs b/DangerousD/GameCore/Network/NetworkManager.cs index 56ac3a1..ed6d2f2 100644 --- a/DangerousD/GameCore/Network/NetworkManager.cs +++ b/DangerousD/GameCore/Network/NetworkManager.cs @@ -21,27 +21,19 @@ namespace DangerousD.GameCore.Network private void Init(string IpAddress) { - try - { - socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - IPAddress address = IPAddress.Parse(IpAddress); - int port = 51873; - endPoint = new IPEndPoint(address, port); - } - catch { } + socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + IPAddress address = IPAddress.Parse(IpAddress); + int port = 51873; + endPoint = new IPEndPoint(address, port); } private void AcceptSockets() { while (true) { - try - { - Socket clientSocket = socket.Accept(); - clientSockets.Add(clientSocket); - Thread receiveThread = new Thread(BeginHostReceive); - receiveThread.Start(clientSocket); - } - catch { } + Socket clientSocket = socket.Accept(); + clientSockets.Add(clientSocket); + Thread receiveThread = new Thread(BeginHostReceive); + receiveThread.Start(clientSocket); } } @@ -50,46 +42,34 @@ namespace DangerousD.GameCore.Network Socket clientSocket = clSocket as Socket; while (clientSocket != null) { - try - { - byte[] bytesCount = new byte[4]; - clientSocket.Receive(bytesCount); - byte[] Data = new byte[BitConverter.ToInt32(bytesCount)]; - StateObject so = new StateObject(clientSocket, Data); - IAsyncResult count = clientSocket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, AsyncReceiveCallback, so); - } - catch { } + byte[] bytesCount = new byte[4]; + clientSocket.Receive(bytesCount); + byte[] Data = new byte[BitConverter.ToInt32(bytesCount)]; + StateObject so = new StateObject(clientSocket, Data); + IAsyncResult count = clientSocket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, AsyncReceiveCallback, so); } } public void HostInit(string IpAddress) { - try - { - Init(IpAddress); - socket.Bind(endPoint); - socket.Listen(4); - Thread acceptThread = new Thread(AcceptSockets); - acceptThread.Start(); - state = "Host"; - AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Host); - } - catch { } + Init(IpAddress); + socket.Bind(endPoint); + socket.Listen(4); + Thread acceptThread = new Thread(AcceptSockets); + acceptThread.Start(); + state = "Host"; + AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Host); } public void ClientInit(string IpAddress) { - try - { - Init(IpAddress); - socket.Connect(endPoint); - state = "Client"; - Thread.Sleep(10); - Thread ReceivingThread = new Thread(ReceiveMsgFromHost); - ReceivingThread.Start(); - NetworkTask connectionTask = new NetworkTask("Player"); - AppManager.Instance.NetworkTasks.Add(connectionTask); - AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Client); - } - catch { } + Init(IpAddress); + socket.Connect(endPoint); + state = "Client"; + Thread.Sleep(10); + Thread ReceivingThread = new Thread(ReceiveMsgFromHost); + ReceivingThread.Start(); + NetworkTask connectionTask = new NetworkTask("Player"); + AppManager.Instance.NetworkTasks.Add(connectionTask); + AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Client); } public void SendMsg(List networkTask, Socket ignoreSocket = null) { @@ -97,65 +77,49 @@ namespace DangerousD.GameCore.Network int count = Data.Length; if (state == "Host") { - try + foreach (Socket socket in clientSockets) { - foreach (Socket socket in clientSockets) + if (!(socket == ignoreSocket)) { - if (!(socket == ignoreSocket)) - { - socket.Send(BitConverter.GetBytes(count)); - socket.Send(Data); - } + socket.Send(BitConverter.GetBytes(count)); + socket.Send(Data); } } - catch { } } else { - try - { - socket.Send(BitConverter.GetBytes(count)); - socket.Send(Data); - } - catch { } + socket.Send(BitConverter.GetBytes(count)); + socket.Send(Data); } } private void ReceiveMsgFromHost() { while (true) { - try - { - byte[] bytesCount = new byte[4]; - socket.Receive(bytesCount); - byte[] Data = new byte[BitConverter.ToInt32(bytesCount)]; - StateObject so = new StateObject(socket, Data); - IAsyncResult count = socket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, AsyncReceiveCallback, so); - } - catch { } + byte[] bytesCount = new byte[4]; + socket.Receive(bytesCount); + byte[] Data = new byte[BitConverter.ToInt32(bytesCount)]; + StateObject so = new StateObject(socket, Data); + IAsyncResult count = socket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, AsyncReceiveCallback, so); } } private void AsyncReceiveCallback(IAsyncResult ar) { - try + StateObject so = ar.AsyncState as StateObject; + Socket clientSocket = so.workSocket; + int readCount = clientSocket.EndReceive(ar); + so.UploadedBytesCount += readCount; + so.sb.Append(Encoding.Unicode.GetString(so.buffer, 0, readCount)); + if (so.UploadedBytesCount < so.bufferSize) { - StateObject so = ar.AsyncState as StateObject; - Socket clientSocket = so.workSocket; - int readCount = clientSocket.EndReceive(ar); - so.UploadedBytesCount += readCount; - so.sb.Append(Encoding.Unicode.GetString(so.buffer, 0, readCount)); - if (so.UploadedBytesCount < so.bufferSize) - { - clientSocket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, new AsyncCallback(AsyncReceiveCallback), so); - } - else - { - List tasks = JsonConvert.DeserializeObject>(so.sb.ToString()); - GetReceivingMessages(tasks); - } + clientSocket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, new AsyncCallback(AsyncReceiveCallback), so); + } + else + { + List tasks = JsonConvert.DeserializeObject>(so.sb.ToString()); + GetReceivingMessages(tasks); } - catch { } } } } From 3b0b3d9b159512a703074d36ca3298b9c785fc11 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 17:48:08 +0300 Subject: [PATCH 03/23] test --- DangerousD/GameCore/Managers/GameManager.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 8d1c7c4..0c23c12 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -30,6 +30,8 @@ namespace DangerousD.GameCore public List otherObjects = new(); public Vector4 CameraBorder; public Player GetPlayer1 { get; private set; } + private int _lastUpdate = 0; + public GameManager() { others = new List(); @@ -132,8 +134,12 @@ namespace DangerousD.GameCore { if (AppManager.Instance.NetworkTasks.Count > 0) { - AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList()); - AppManager.Instance.NetworkTasks.Clear(); + if (gameTime.ElapsedGameTime.Milliseconds - _lastUpdate > 1000) + { + AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList()); + AppManager.Instance.NetworkTasks.Clear(); + _lastUpdate = gameTime.ElapsedGameTime.Milliseconds; + } } foreach (var item in BackgroundObjects) item.Update(gameTime); From 4386e9db8b21bbca3eb93ad7923ae3efe69e8214 Mon Sep 17 00:00:00 2001 From: Timofey06 Date: Fri, 18 Aug 2023 17:48:08 +0300 Subject: [PATCH 04/23] RestartAdded --- DangerousD/GameCore/GUI/DeathGUI.cs | 2 +- .../LivingEntities/Player/AnimationRectangle.cs | 17 +++++++++-------- DangerousD/GameCore/Managers/AppManager.cs | 6 ++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/DangerousD/GameCore/GUI/DeathGUI.cs b/DangerousD/GameCore/GUI/DeathGUI.cs index 31bff02..ce73850 100644 --- a/DangerousD/GameCore/GUI/DeathGUI.cs +++ b/DangerousD/GameCore/GUI/DeathGUI.cs @@ -23,7 +23,7 @@ internal class DeathGUI : AbstractGui Elements.Add(butMenu); butMenu.LeftButtonPressed += () => { - AppManager.Instance.ChangeGameState(GameState.Menu); + AppManager.Instance.Restart("lvl"); }; foreach (var item in Elements) { diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs index 8644b77..e199e4d 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs @@ -25,14 +25,15 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath private void PlayDeath(string deathName) { - if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie") - { - GraphicsComponent.StartAnimation("DeathFromZombie"); - } - if (GraphicsComponent.GetCurrentAnimation != "DeathFromSilasHand") - { - GraphicsComponent.StartAnimation("DeathFromSilasHand"); - } + //if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie") + //{ + // GraphicsComponent.StartAnimation("DeathFromZombie"); + //} + //if (GraphicsComponent.GetCurrentAnimation != "DeathFromSilasHand") + //{ + // GraphicsComponent.StartAnimation("DeathFromSilasHand"); + //} + GraphicsComponent.StartAnimation(deathName); } } diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index aedb493..06c6f79 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -208,7 +208,7 @@ namespace DangerousD.GameCore case GameState.Lobby: break; case GameState.Game: - GameManager.mapManager.LoadLevel("lvl"); + GameManager.mapManager.LoadLevel(currentMap); GameManager.FindBorders(); break; case GameState.Death: @@ -326,7 +326,9 @@ namespace DangerousD.GameCore } public void Restart(string map) { - + GameManager = new(); + ChangeGameState(GameState.Menu); + currentMap = map; } } } From 8c1ab9b12e105a1ee9e351fe9ac57ee5638cf4e3 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 17:49:49 +0300 Subject: [PATCH 05/23] fix bind ip --- DangerousD/GameCore/Managers/AppManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index aedb493..c5f79c4 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -23,7 +23,7 @@ namespace DangerousD.GameCore public class AppManager : Game { public static AppManager Instance { get; private set; } - public string IpAddress { get; private set; } = "127.0.0.1"; + public string IpAddress { get; private set; } = "0.0.0.0"; private GraphicsDeviceManager _graphics; private SpriteBatch _spriteBatch; public GameState gameState { get; private set; } From 6550f1273d60777c03db8e8e457a83b19028435b Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 17:54:00 +0300 Subject: [PATCH 06/23] test --- DangerousD/GameCore/Managers/AppManager.cs | 1 + DangerousD/GameCore/Managers/GameManager.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index c5f79c4..399b866 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -220,6 +220,7 @@ namespace DangerousD.GameCore public void NetworkSync(List networkTasks) { + DebugHUD.Log("networksync"); foreach (NetworkTask networkTask in networkTasks) { switch (networkTask.operation) diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 0c23c12..8608e77 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -134,8 +134,9 @@ namespace DangerousD.GameCore { if (AppManager.Instance.NetworkTasks.Count > 0) { - if (gameTime.ElapsedGameTime.Milliseconds - _lastUpdate > 1000) + if (gameTime.TotalGameTime.Milliseconds - _lastUpdate > 1000) { + AppManager.Instance.DebugHUD.Log("sending"); AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList()); AppManager.Instance.NetworkTasks.Clear(); _lastUpdate = gameTime.ElapsedGameTime.Milliseconds; From 3399cc8f5934e18831f044972617979423a675a6 Mon Sep 17 00:00:00 2001 From: AnloGames <7383an@gmail.com> Date: Fri, 18 Aug 2023 17:54:30 +0300 Subject: [PATCH 07/23] lobbyFix --- DangerousD/GameCore/GUI/LobbyGUI.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/DangerousD/GameCore/GUI/LobbyGUI.cs b/DangerousD/GameCore/GUI/LobbyGUI.cs index 90ba3c9..1d8a2e1 100644 --- a/DangerousD/GameCore/GUI/LobbyGUI.cs +++ b/DangerousD/GameCore/GUI/LobbyGUI.cs @@ -135,6 +135,7 @@ namespace DangerousD.GameCore.GUI }; Elements.Add(joinByIpButton); joinByIpButton.LeftButtonPressed += () => { + AppManager.Instance.ChangeGameState(GameState.Game); AppManager.Instance.NetworkManager.ClientInit(searchBarTextBox.text); }; } From 92f10d4cd0c25a4052d91f59eaff76cad75dcdde Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 17:57:07 +0300 Subject: [PATCH 08/23] test --- DangerousD/GameCore/Managers/GameManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 8608e77..400bd43 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -134,12 +134,12 @@ namespace DangerousD.GameCore { if (AppManager.Instance.NetworkTasks.Count > 0) { - if (gameTime.TotalGameTime.Milliseconds - _lastUpdate > 1000) + if (gameTime.TotalGameTime.Milliseconds - _lastUpdate > 800) { AppManager.Instance.DebugHUD.Log("sending"); AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList()); AppManager.Instance.NetworkTasks.Clear(); - _lastUpdate = gameTime.ElapsedGameTime.Milliseconds; + _lastUpdate = gameTime.TotalGameTime.Milliseconds; } } foreach (var item in BackgroundObjects) From 77aacb86f0497843a9abd3dff298371f95f9dd1c Mon Sep 17 00:00:00 2001 From: AnloGames <7383an@gmail.com> Date: Fri, 18 Aug 2023 18:11:17 +0300 Subject: [PATCH 09/23] nf --- DangerousD/GameCore/Managers/GameManager.cs | 2 +- DangerousD/GameCore/Network/NetworkManager.cs | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 8608e77..49cefee 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -134,7 +134,7 @@ namespace DangerousD.GameCore { if (AppManager.Instance.NetworkTasks.Count > 0) { - if (gameTime.TotalGameTime.Milliseconds - _lastUpdate > 1000) + if (gameTime.TotalGameTime.Milliseconds - _lastUpdate > 800) { AppManager.Instance.DebugHUD.Log("sending"); AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList()); diff --git a/DangerousD/GameCore/Network/NetworkManager.cs b/DangerousD/GameCore/Network/NetworkManager.cs index ed6d2f2..e4618ac 100644 --- a/DangerousD/GameCore/Network/NetworkManager.cs +++ b/DangerousD/GameCore/Network/NetworkManager.cs @@ -44,9 +44,16 @@ namespace DangerousD.GameCore.Network { byte[] bytesCount = new byte[4]; clientSocket.Receive(bytesCount); - byte[] Data = new byte[BitConverter.ToInt32(bytesCount)]; + int length = BitConverter.ToInt32(bytesCount); + byte[] Data = new byte[length]; StateObject so = new StateObject(clientSocket, Data); - IAsyncResult count = clientSocket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, AsyncReceiveCallback, so); + while (so.UploadedBytesCount < length) + { + int count = socket.Receive(so.buffer, so.UploadedBytesCount, length - so.UploadedBytesCount, SocketFlags.None); + so.UploadedBytesCount += count; + } + List tasks = JsonConvert.DeserializeObject>(so.sb.ToString()); + GetReceivingMessages(tasks); } } public void HostInit(string IpAddress) @@ -98,9 +105,16 @@ namespace DangerousD.GameCore.Network { byte[] bytesCount = new byte[4]; socket.Receive(bytesCount); - byte[] Data = new byte[BitConverter.ToInt32(bytesCount)]; + int length = BitConverter.ToInt32(bytesCount); + byte[] Data = new byte[length]; StateObject so = new StateObject(socket, Data); - IAsyncResult count = socket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, AsyncReceiveCallback, so); + while (so.UploadedBytesCount < length) + { + int count = socket.Receive(so.buffer, so.UploadedBytesCount, length-so.UploadedBytesCount, SocketFlags.None); + so.UploadedBytesCount += count; + } + List tasks = JsonConvert.DeserializeObject>(so.sb.ToString()); + GetReceivingMessages(tasks); } } From c108c1899b21efc3c1192be30fb10fd7a1c24451 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 18:16:19 +0300 Subject: [PATCH 10/23] fix --- DangerousD/GameCore/Network/NetworkManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DangerousD/GameCore/Network/NetworkManager.cs b/DangerousD/GameCore/Network/NetworkManager.cs index e4618ac..5b9f1cb 100644 --- a/DangerousD/GameCore/Network/NetworkManager.cs +++ b/DangerousD/GameCore/Network/NetworkManager.cs @@ -49,7 +49,7 @@ namespace DangerousD.GameCore.Network StateObject so = new StateObject(clientSocket, Data); while (so.UploadedBytesCount < length) { - int count = socket.Receive(so.buffer, so.UploadedBytesCount, length - so.UploadedBytesCount, SocketFlags.None); + int count = clientSocket.Receive(so.buffer, so.UploadedBytesCount, length - so.UploadedBytesCount, SocketFlags.None); so.UploadedBytesCount += count; } List tasks = JsonConvert.DeserializeObject>(so.sb.ToString()); From b2ed0bc14cfec2743b2af1fcd98bfd30cff23cc3 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 18:19:31 +0300 Subject: [PATCH 11/23] fox --- DangerousD/GameCore/Network/NetworkManager.cs | 22 ++----------------- DangerousD/GameCore/Network/StateObject.cs | 1 - 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/DangerousD/GameCore/Network/NetworkManager.cs b/DangerousD/GameCore/Network/NetworkManager.cs index 5b9f1cb..41b48f1 100644 --- a/DangerousD/GameCore/Network/NetworkManager.cs +++ b/DangerousD/GameCore/Network/NetworkManager.cs @@ -52,7 +52,7 @@ namespace DangerousD.GameCore.Network int count = clientSocket.Receive(so.buffer, so.UploadedBytesCount, length - so.UploadedBytesCount, SocketFlags.None); so.UploadedBytesCount += count; } - List tasks = JsonConvert.DeserializeObject>(so.sb.ToString()); + List tasks = JsonConvert.DeserializeObject>(Encoding.Unicode.GetString(so.buffer, 0, length)); GetReceivingMessages(tasks); } } @@ -113,25 +113,7 @@ namespace DangerousD.GameCore.Network int count = socket.Receive(so.buffer, so.UploadedBytesCount, length-so.UploadedBytesCount, SocketFlags.None); so.UploadedBytesCount += count; } - List tasks = JsonConvert.DeserializeObject>(so.sb.ToString()); - GetReceivingMessages(tasks); - } - } - - private void AsyncReceiveCallback(IAsyncResult ar) - { - StateObject so = ar.AsyncState as StateObject; - Socket clientSocket = so.workSocket; - int readCount = clientSocket.EndReceive(ar); - so.UploadedBytesCount += readCount; - so.sb.Append(Encoding.Unicode.GetString(so.buffer, 0, readCount)); - if (so.UploadedBytesCount < so.bufferSize) - { - clientSocket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, new AsyncCallback(AsyncReceiveCallback), so); - } - else - { - List tasks = JsonConvert.DeserializeObject>(so.sb.ToString()); + List tasks = JsonConvert.DeserializeObject>(Encoding.Unicode.GetString(so.buffer, 0, length)); GetReceivingMessages(tasks); } } diff --git a/DangerousD/GameCore/Network/StateObject.cs b/DangerousD/GameCore/Network/StateObject.cs index f98170b..3648ad1 100644 --- a/DangerousD/GameCore/Network/StateObject.cs +++ b/DangerousD/GameCore/Network/StateObject.cs @@ -12,7 +12,6 @@ namespace DangerousD.GameCore.Network public Socket workSocket; public int bufferSize; public byte[] buffer; - public StringBuilder sb = new StringBuilder(); public int UploadedBytesCount; public StateObject(Socket socket, byte[] buffer) From 5e4c576a7980e96381ea370cb98ad6c16f12e1ab Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 18:23:12 +0300 Subject: [PATCH 12/23] fix --- DangerousD/GameCore/Managers/GameManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 400bd43..f300634 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -31,6 +31,7 @@ namespace DangerousD.GameCore public Vector4 CameraBorder; public Player GetPlayer1 { get; private set; } private int _lastUpdate = 0; + private int _currTime = 0; public GameManager() { @@ -132,14 +133,15 @@ namespace DangerousD.GameCore public void Update(GameTime gameTime) { + _currTime += gameTime.ElapsedGameTime.Milliseconds; if (AppManager.Instance.NetworkTasks.Count > 0) { - if (gameTime.TotalGameTime.Milliseconds - _lastUpdate > 800) + if (_currTime - _lastUpdate > 800) { AppManager.Instance.DebugHUD.Log("sending"); AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList()); AppManager.Instance.NetworkTasks.Clear(); - _lastUpdate = gameTime.TotalGameTime.Milliseconds; + _lastUpdate = _currTime; } } foreach (var item in BackgroundObjects) From b0a384972fc265e8454ba94197caeb7422aca8b2 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 18:25:04 +0300 Subject: [PATCH 13/23] aaaaaaaaaa --- DangerousD/GameCore/Managers/GameManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index f300634..f4eed81 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -136,7 +136,7 @@ namespace DangerousD.GameCore _currTime += gameTime.ElapsedGameTime.Milliseconds; if (AppManager.Instance.NetworkTasks.Count > 0) { - if (_currTime - _lastUpdate > 800) + if (_currTime - _lastUpdate > 50) { AppManager.Instance.DebugHUD.Log("sending"); AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList()); From dd71483358ec8c437378d7147aa2bc5699f99431 Mon Sep 17 00:00:00 2001 From: polten0 Date: Fri, 18 Aug 2023 17:37:48 +0300 Subject: [PATCH 14/23] AddDeathAnimations --- DangerousD/Content/animations/DeathFromGhost | 1 + DangerousD/Content/animations/DeathFromHunchman | 1 + DangerousD/Content/animations/DeathFromSilasMaster | 1 + DangerousD/Content/animations/DeathFromSlime | 1 + DangerousD/Content/animations/DeathFromSpider | 1 + DangerousD/Content/animations/DeathFromWerewolf | 1 + 6 files changed, 6 insertions(+) create mode 100644 DangerousD/Content/animations/DeathFromGhost create mode 100644 DangerousD/Content/animations/DeathFromHunchman create mode 100644 DangerousD/Content/animations/DeathFromSilasMaster create mode 100644 DangerousD/Content/animations/DeathFromSlime create mode 100644 DangerousD/Content/animations/DeathFromSpider create mode 100644 DangerousD/Content/animations/DeathFromWerewolf diff --git a/DangerousD/Content/animations/DeathFromGhost b/DangerousD/Content/animations/DeathFromGhost new file mode 100644 index 0000000..b4ef48e --- /dev/null +++ b/DangerousD/Content/animations/DeathFromGhost @@ -0,0 +1 @@ +{"id":"DeathFromGhost","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":246,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/DeathFromHunchman b/DangerousD/Content/animations/DeathFromHunchman new file mode 100644 index 0000000..a00ed27 --- /dev/null +++ b/DangerousD/Content/animations/DeathFromHunchman @@ -0,0 +1 @@ +{"id":"DeathFromHunchman","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":1,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/DeathFromSilasMaster b/DangerousD/Content/animations/DeathFromSilasMaster new file mode 100644 index 0000000..3f9a76b --- /dev/null +++ b/DangerousD/Content/animations/DeathFromSilasMaster @@ -0,0 +1 @@ +{"id":"DeathFromSilasMaster","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":295,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/DeathFromSlime b/DangerousD/Content/animations/DeathFromSlime new file mode 100644 index 0000000..5a692f6 --- /dev/null +++ b/DangerousD/Content/animations/DeathFromSlime @@ -0,0 +1 @@ +{"id":"DeathFromSlime","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":50,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/DeathFromSpider b/DangerousD/Content/animations/DeathFromSpider new file mode 100644 index 0000000..98a08a5 --- /dev/null +++ b/DangerousD/Content/animations/DeathFromSpider @@ -0,0 +1 @@ +{"id":"DeathFromSpider","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":148,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/DeathFromWerewolf b/DangerousD/Content/animations/DeathFromWerewolf new file mode 100644 index 0000000..8f0b150 --- /dev/null +++ b/DangerousD/Content/animations/DeathFromWerewolf @@ -0,0 +1 @@ +{"id":"DeathFromWerewolf","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":197,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"} From 665cb6b38b25aece2eb62d11161fa6784dfea094 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 17:38:59 +0300 Subject: [PATCH 15/23] fix texture names --- DangerousD/Content/Content.mgcb | 8 ++++---- DangerousD/Content/{MenuFon2.jpg => menuFon2.jpg} | Bin .../{SmokeAnimation2.png => smokeAnimation2.png} | Bin 3 files changed, 4 insertions(+), 4 deletions(-) rename DangerousD/Content/{MenuFon2.jpg => menuFon2.jpg} (100%) rename DangerousD/Content/{SmokeAnimation2.png => smokeAnimation2.png} (100%) diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index ea7bb60..b3ce6cc 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -140,7 +140,7 @@ /processorParam:TextureFormat=Color /build:menuFon.jpg -#begin MenuFon2.jpg +#begin menuFon2.jpg /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -150,7 +150,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:MenuFon2.jpg +/build:menuFon2.jpg #begin menuFon3.jpg /importer:TextureImporter @@ -255,7 +255,7 @@ /processorParam:Quality=Best /build:sounds/shotgun_shot.mp3 -#begin SmokeAnimation2.png +#begin smokeAnimation2.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -265,7 +265,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:SmokeAnimation2.png +/build:smokeAnimation2.png #begin textboxbackground1-1.png /importer:TextureImporter diff --git a/DangerousD/Content/MenuFon2.jpg b/DangerousD/Content/menuFon2.jpg similarity index 100% rename from DangerousD/Content/MenuFon2.jpg rename to DangerousD/Content/menuFon2.jpg diff --git a/DangerousD/Content/SmokeAnimation2.png b/DangerousD/Content/smokeAnimation2.png similarity index 100% rename from DangerousD/Content/SmokeAnimation2.png rename to DangerousD/Content/smokeAnimation2.png From 12e3101988652d06d0ef0c79fef992a6db608f05 Mon Sep 17 00:00:00 2001 From: bmvolf Date: Fri, 18 Aug 2023 16:52:38 +0300 Subject: [PATCH 16/23] added up shooting --- .../Content/animations/playerShootBoomUpLeft | 1 + .../Content/animations/playerShootBoomUpRight | 24 +++ .../LivingEntities/Monsters/CoreEnemy.cs | 4 +- .../LivingEntities/Monsters/Zombie.cs | 4 +- .../LivingEntities/Player/Player.cs | 147 +++++++++++++----- .../GameCore/GameObjects/LivingEntity.cs | 2 + 6 files changed, 138 insertions(+), 44 deletions(-) create mode 100644 DangerousD/Content/animations/playerShootBoomUpLeft create mode 100644 DangerousD/Content/animations/playerShootBoomUpRight diff --git a/DangerousD/Content/animations/playerShootBoomUpLeft b/DangerousD/Content/animations/playerShootBoomUpLeft new file mode 100644 index 0000000..093eb3c --- /dev/null +++ b/DangerousD/Content/animations/playerShootBoomUpLeft @@ -0,0 +1 @@ +{"id":"playerShootBoomUpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/playerShootBoomUpRight b/DangerousD/Content/animations/playerShootBoomUpRight new file mode 100644 index 0000000..3f70e03 --- /dev/null +++ b/DangerousD/Content/animations/playerShootBoomUpRight @@ -0,0 +1,24 @@ +{ + "id": "playerShootBoomUpRight", + "textureName": "playerAnimation", + "startSpriteRectangle": { + "X": 267, + "Y": 1, + "Width": 24, + "Height": 32 + }, + "frameSecond": [ + { + "Item1": 0, + "Item2": 3 + }, + { + "Item1": 1, + "Item2": 20 + } + ], + "textureFrameInterval": 1, + "framesCount": 2, + "isCycle": false, + "offset": "0, 0" +} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs index 38b1cc0..5f33df9 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs @@ -36,9 +36,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public abstract void Move(GameTime gameTime); - public void TakeDamage(int damage) + public virtual void TakeDamage() { - monster_health -= damage; + monster_health--; if (monster_health <= 0) { Death(); diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index 0451908..bed7ef5 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -32,6 +32,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters rightBorder = (int)position.X + 100; physicsManager = new PhysicsManager(); Random random = new Random(); + monster_health = 2; if(random.Next(0, 2) == 0) { isGoRight = true; @@ -183,10 +184,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Attack(GameTime gameTime) {} - public void TakeDamage() + public override void TakeDamage() { monster_health--; - GraphicsComponent.StartAnimation("ZombieRightAttack"); Particle particle = new Particle(Pos); if (monster_health <= 0) { diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index fc34e25..db940ca 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -10,6 +10,7 @@ using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Graphics; using DangerousD.GameCore.GameObjects.LivingEntities.Monsters; using DangerousD.GameCore.Network; +using DangerousD.GameCore.GameObjects.MapObjects; namespace DangerousD.GameCore.GameObjects.LivingEntities { @@ -65,6 +66,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { bullets++; } + if(a == "playerShootBoomUpRight" || a == "playerShootBoomUpLeft") + { + isShooting = false; + } }; } @@ -73,7 +78,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public bool IsAlive { get { return isAlive; } } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft", - "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft"}, "playerReload"); + "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft", "playerShootBoomUpRight", + "playerShootBoomUpLeft"}, "playerReload"); public void Attack() { @@ -184,41 +190,57 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities bullets--; if (isRight) { - StartCicycleAnimation("playerShootRight"); - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets.Count() > 0) + if (!isUping) { - Zombie targetZombie = (Zombie)targets.First(); - targetZombie.TakeDamage(); - - } - targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets.Count() > 0) - { - SilasHands targetHand = (SilasHands)targets.First(); - targetHand.TakeDamage(); - } - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); - } - else - { - StartCicycleAnimation("playerShootLeft"); - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie)); - if (targets != null) - { - foreach (var target in targets) + StartCicycleAnimation("playerShootRight"); + var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); + if (targets.Count() > 0) { - Zombie targetZombie = (Zombie)target; + Zombie targetZombie = (Zombie)targets.First(); targetZombie.TakeDamage(); } + targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)).OrderBy(x => (x.Pos - Pos).LengthSquared()); + if (targets.Count() > 0) + { + SilasHands targetHand = (SilasHands)targets.First(); + targetHand.TakeDamage(); + } + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); } - targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)); - if (targets.Count() > 0) + else { - SilasHands targetHand = (SilasHands)targets.First(); - targetHand.TakeDamage(); + StartCicycleAnimation("playerShootBoomUpRight"); + Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y)); + bullet.ShootUpRight(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8)); + } + } + else if(!isRight) + { + if (!isUping) + { + StartCicycleAnimation("playerShootLeft"); + var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); + if (targets.Count() > 0) + { + Zombie targetZombie = (Zombie)targets.First(); + targetZombie.TakeDamage(); + } + targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)); + if (targets.Count() > 0) + { + SilasHands targetHand = (SilasHands)targets.First(); + targetHand.TakeDamage(); + } + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7)); + } + else + { + StartCicycleAnimation("playerShootBoomUpLeft"); + Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y)); + bullet.ShootUpLeft(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7)); } - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7)); } } } @@ -282,14 +304,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит { - if(bullets < 5) - { - if (GraphicsComponent.GetCurrentAnimation != "playerReload") - { - GraphicsComponent.StartAnimation("playerReload"); - } - } - else if (isRight) + if (isRight) { if (isUping) { @@ -298,6 +313,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities GraphicsComponent.StartAnimation("playerShootUpRight"); } } + else if (bullets < 5) + { + if (GraphicsComponent.GetCurrentAnimation != "playerReload") + { + GraphicsComponent.StartAnimation("playerReload"); + } + } else { GraphicsComponent.StartAnimation("playerRightStay"); @@ -312,6 +334,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities GraphicsComponent.StartAnimation("playerShootUpLeft"); } } + else if (bullets < 5) + { + if (GraphicsComponent.GetCurrentAnimation != "playerReload") + { + GraphicsComponent.StartAnimation("playerReload"); + } + } else { GraphicsComponent.StartAnimation("playerStayLeft"); @@ -331,13 +360,51 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities isOnGround = false; } - public class Bullet : GameObjects.LivingEntity + public class Bullet : LivingEntity { public Bullet(Vector2 position) : base(position) { + Height = 5; + Width = 5; + } + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft"}, "playerMoveLeft"); + Vector2 direction; + Vector2 maindirection; + public void ShootUpRight() + { + direction = new Vector2(1, -1); + acceleration = Vector2.Zero; + velocity = new Vector2(10, 10) * direction; + maindirection = velocity; + } + public void ShootUpLeft() + { + direction = new Vector2(-1, -1); + acceleration = Vector2.Zero; + velocity = new Vector2(10, 10) * direction; + maindirection = velocity; + } + public override void OnCollision(GameObject gameObject) + { + if (gameObject is not Player) + { + if (gameObject is CoreEnemy) + { + CoreEnemy enemy = (CoreEnemy)gameObject; + enemy.TakeDamage(); + AppManager.Instance.GameManager.Remove(this); + } + base.OnCollision(gameObject); + } + } + public override void Update(GameTime gameTime) + { + if (maindirection!=velocity) + { + AppManager.Instance.GameManager.Remove(this); + } + base.Update(gameTime); } - protected override GraphicsComponent GraphicsComponent { get; } = new("ZombieMoveLeft"); - } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs index 78ea17c..72d61f4 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntity.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs @@ -10,6 +10,8 @@ public abstract class LivingEntity : Entity public Vector2 velocity; public Vector2 acceleration; + public Vector2 Acceleration { get; private set; } + public LivingEntity(Vector2 position) : base(position) { acceleration = new Vector2(0, 30); From fa399951a8ef2e2da6ce28f1ae23faafd062cf49 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 17:45:17 +0300 Subject: [PATCH 17/23] fix network --- DangerousD/GameCore/GUI/LobbyGUI.cs | 1 + DangerousD/GameCore/Managers/AppManager.cs | 3 +- DangerousD/GameCore/Managers/GameManager.cs | 13 +- DangerousD/GameCore/Network/NetworkManager.cs | 140 +++++++----------- DangerousD/GameCore/Network/StateObject.cs | 1 - 5 files changed, 64 insertions(+), 94 deletions(-) diff --git a/DangerousD/GameCore/GUI/LobbyGUI.cs b/DangerousD/GameCore/GUI/LobbyGUI.cs index 90ba3c9..1d8a2e1 100644 --- a/DangerousD/GameCore/GUI/LobbyGUI.cs +++ b/DangerousD/GameCore/GUI/LobbyGUI.cs @@ -135,6 +135,7 @@ namespace DangerousD.GameCore.GUI }; Elements.Add(joinByIpButton); joinByIpButton.LeftButtonPressed += () => { + AppManager.Instance.ChangeGameState(GameState.Game); AppManager.Instance.NetworkManager.ClientInit(searchBarTextBox.text); }; } diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 06c6f79..7689727 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -23,7 +23,7 @@ namespace DangerousD.GameCore public class AppManager : Game { public static AppManager Instance { get; private set; } - public string IpAddress { get; private set; } = "127.0.0.1"; + public string IpAddress { get; private set; } = "0.0.0.0"; private GraphicsDeviceManager _graphics; private SpriteBatch _spriteBatch; public GameState gameState { get; private set; } @@ -220,6 +220,7 @@ namespace DangerousD.GameCore public void NetworkSync(List networkTasks) { + DebugHUD.Log("networksync"); foreach (NetworkTask networkTask in networkTasks) { switch (networkTask.operation) diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 8d1c7c4..f4eed81 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -30,6 +30,9 @@ namespace DangerousD.GameCore public List otherObjects = new(); public Vector4 CameraBorder; public Player GetPlayer1 { get; private set; } + private int _lastUpdate = 0; + private int _currTime = 0; + public GameManager() { others = new List(); @@ -130,10 +133,16 @@ namespace DangerousD.GameCore public void Update(GameTime gameTime) { + _currTime += gameTime.ElapsedGameTime.Milliseconds; if (AppManager.Instance.NetworkTasks.Count > 0) { - AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList()); - AppManager.Instance.NetworkTasks.Clear(); + if (_currTime - _lastUpdate > 50) + { + AppManager.Instance.DebugHUD.Log("sending"); + AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList()); + AppManager.Instance.NetworkTasks.Clear(); + _lastUpdate = _currTime; + } } foreach (var item in BackgroundObjects) item.Update(gameTime); diff --git a/DangerousD/GameCore/Network/NetworkManager.cs b/DangerousD/GameCore/Network/NetworkManager.cs index 56ac3a1..41b48f1 100644 --- a/DangerousD/GameCore/Network/NetworkManager.cs +++ b/DangerousD/GameCore/Network/NetworkManager.cs @@ -21,27 +21,19 @@ namespace DangerousD.GameCore.Network private void Init(string IpAddress) { - try - { - socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - IPAddress address = IPAddress.Parse(IpAddress); - int port = 51873; - endPoint = new IPEndPoint(address, port); - } - catch { } + socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + IPAddress address = IPAddress.Parse(IpAddress); + int port = 51873; + endPoint = new IPEndPoint(address, port); } private void AcceptSockets() { while (true) { - try - { - Socket clientSocket = socket.Accept(); - clientSockets.Add(clientSocket); - Thread receiveThread = new Thread(BeginHostReceive); - receiveThread.Start(clientSocket); - } - catch { } + Socket clientSocket = socket.Accept(); + clientSockets.Add(clientSocket); + Thread receiveThread = new Thread(BeginHostReceive); + receiveThread.Start(clientSocket); } } @@ -50,46 +42,41 @@ namespace DangerousD.GameCore.Network Socket clientSocket = clSocket as Socket; while (clientSocket != null) { - try + byte[] bytesCount = new byte[4]; + clientSocket.Receive(bytesCount); + int length = BitConverter.ToInt32(bytesCount); + byte[] Data = new byte[length]; + StateObject so = new StateObject(clientSocket, Data); + while (so.UploadedBytesCount < length) { - byte[] bytesCount = new byte[4]; - clientSocket.Receive(bytesCount); - byte[] Data = new byte[BitConverter.ToInt32(bytesCount)]; - StateObject so = new StateObject(clientSocket, Data); - IAsyncResult count = clientSocket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, AsyncReceiveCallback, so); + int count = clientSocket.Receive(so.buffer, so.UploadedBytesCount, length - so.UploadedBytesCount, SocketFlags.None); + so.UploadedBytesCount += count; } - catch { } + List tasks = JsonConvert.DeserializeObject>(Encoding.Unicode.GetString(so.buffer, 0, length)); + GetReceivingMessages(tasks); } } public void HostInit(string IpAddress) { - try - { - Init(IpAddress); - socket.Bind(endPoint); - socket.Listen(4); - Thread acceptThread = new Thread(AcceptSockets); - acceptThread.Start(); - state = "Host"; - AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Host); - } - catch { } + Init(IpAddress); + socket.Bind(endPoint); + socket.Listen(4); + Thread acceptThread = new Thread(AcceptSockets); + acceptThread.Start(); + state = "Host"; + AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Host); } public void ClientInit(string IpAddress) { - try - { - Init(IpAddress); - socket.Connect(endPoint); - state = "Client"; - Thread.Sleep(10); - Thread ReceivingThread = new Thread(ReceiveMsgFromHost); - ReceivingThread.Start(); - NetworkTask connectionTask = new NetworkTask("Player"); - AppManager.Instance.NetworkTasks.Add(connectionTask); - AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Client); - } - catch { } + Init(IpAddress); + socket.Connect(endPoint); + state = "Client"; + Thread.Sleep(10); + Thread ReceivingThread = new Thread(ReceiveMsgFromHost); + ReceivingThread.Start(); + NetworkTask connectionTask = new NetworkTask("Player"); + AppManager.Instance.NetworkTasks.Add(connectionTask); + AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Client); } public void SendMsg(List networkTask, Socket ignoreSocket = null) { @@ -97,65 +84,38 @@ namespace DangerousD.GameCore.Network int count = Data.Length; if (state == "Host") { - try + foreach (Socket socket in clientSockets) { - foreach (Socket socket in clientSockets) + if (!(socket == ignoreSocket)) { - if (!(socket == ignoreSocket)) - { - socket.Send(BitConverter.GetBytes(count)); - socket.Send(Data); - } + socket.Send(BitConverter.GetBytes(count)); + socket.Send(Data); } } - catch { } } else { - try - { - socket.Send(BitConverter.GetBytes(count)); - socket.Send(Data); - } - catch { } + socket.Send(BitConverter.GetBytes(count)); + socket.Send(Data); } } private void ReceiveMsgFromHost() { while (true) { - try + byte[] bytesCount = new byte[4]; + socket.Receive(bytesCount); + int length = BitConverter.ToInt32(bytesCount); + byte[] Data = new byte[length]; + StateObject so = new StateObject(socket, Data); + while (so.UploadedBytesCount < length) { - byte[] bytesCount = new byte[4]; - socket.Receive(bytesCount); - byte[] Data = new byte[BitConverter.ToInt32(bytesCount)]; - StateObject so = new StateObject(socket, Data); - IAsyncResult count = socket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, AsyncReceiveCallback, so); + int count = socket.Receive(so.buffer, so.UploadedBytesCount, length-so.UploadedBytesCount, SocketFlags.None); + so.UploadedBytesCount += count; } - catch { } + List tasks = JsonConvert.DeserializeObject>(Encoding.Unicode.GetString(so.buffer, 0, length)); + GetReceivingMessages(tasks); } } - - private void AsyncReceiveCallback(IAsyncResult ar) - { - try - { - StateObject so = ar.AsyncState as StateObject; - Socket clientSocket = so.workSocket; - int readCount = clientSocket.EndReceive(ar); - so.UploadedBytesCount += readCount; - so.sb.Append(Encoding.Unicode.GetString(so.buffer, 0, readCount)); - if (so.UploadedBytesCount < so.bufferSize) - { - clientSocket.BeginReceive(so.buffer, 0, so.bufferSize, SocketFlags.None, new AsyncCallback(AsyncReceiveCallback), so); - } - else - { - List tasks = JsonConvert.DeserializeObject>(so.sb.ToString()); - GetReceivingMessages(tasks); - } - } - catch { } - } } } diff --git a/DangerousD/GameCore/Network/StateObject.cs b/DangerousD/GameCore/Network/StateObject.cs index f98170b..3648ad1 100644 --- a/DangerousD/GameCore/Network/StateObject.cs +++ b/DangerousD/GameCore/Network/StateObject.cs @@ -12,7 +12,6 @@ namespace DangerousD.GameCore.Network public Socket workSocket; public int bufferSize; public byte[] buffer; - public StringBuilder sb = new StringBuilder(); public int UploadedBytesCount; public StateObject(Socket socket, byte[] buffer) From 447b8f0b10e6c96bcb5d502dd099e34e772cb100 Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Fri, 18 Aug 2023 19:06:44 +0300 Subject: [PATCH 18/23] Lvl slime fix --- DangerousD/Content/lvl2.tmx | 652 ++++++++++++++++++ .../LivingEntities/Player/Player.cs | 2 +- 2 files changed, 653 insertions(+), 1 deletion(-) create mode 100644 DangerousD/Content/lvl2.tmx diff --git a/DangerousD/Content/lvl2.tmx b/DangerousD/Content/lvl2.tmx new file mode 100644 index 0000000..2457874 --- /dev/null +++ b/DangerousD/Content/lvl2.tmx @@ -0,0 +1,652 @@ + + + + + + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1157, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1027, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1027, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1027 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157,1157, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1157,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1027,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1027,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1027,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1027, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1027, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1027, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1157, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +1027,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1027,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1027,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1157,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,405 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1239,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +1278,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405, +0,0,0,0,0,1027,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,1027,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,1027,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,1027,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,1027,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,1027,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,0,0,405,405,405,405,405, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,405,405,405,405,405,405,405,405,405,405,405,405,405,405,405 + + +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +405,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +576,577,578,579,580,581,576,577,578,579,580,581,576,577,578,579, +589,590,591,592,593,594,589,590,591,592,593,594,589,590,591,592, +602,603,604,605,606,607,602,603,604,605,606,607,602,603,1453,1454 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +580,581,576,577,578,579,580,581,576,577,578,579,580,581,576,577, +593,594,589,590,591,592,593,594,589,590,591,592,593,594,589,590, +606,607,602,603,604,605,606,607,602,603,604,605,606,607,602,603 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +578,579,580,581,576,577,578,579,580,581,576,577,578,579,580,581, +591,592,593,594,589,590,591,592,593,594,589,590,591,592,593,594, +604,605,606,607,602,603,604,1453,1454,607,602,603,604,605,606,607 + + +615,616,617,618,619,620,615,616,950,951,619,620,615,616,1466,1467, +628,629,630,631,632,633,628,629,963,964,632,633,628,629,1479,1480, +641,642,643,1378,645,646,641,642,976,977,645,646,641,642,643,644, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +576,577,578,579,580,581,576,577,578,579,580,581,576,577,578,579, +589,590,591,592,593,594,589,590,591,1333,1334,594,589,590,591,592, +602,603,604,605,606,607,602,603,604,1346,1347,607,602,603,604,605, +615,616,950,951,619,620,615,616,617,1359,1360,620,615,616,950,951, +628,629,963,964,632,633,628,629,630,631,632,633,628,629,963,964, +641,642,976,977,645,646,641,642,643,1378,645,646,641,642,976,977, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +576,577,578,579,580,581,576,577,578,579,580,581,576,577,578,579, +589,590,591,592,593,594,589,590,591,592,593,594,589,590,591,592, +602,603,604,605,606,607,602,603,604,1325,1326,607,602,603,604,605, +615,616,617,618,619,620,615,616,617,1338,1339,620,615,616,79,80, +628,629,630,631,632,633,628,629,630,631,632,633,628,629,92,93 + + +619,620,615,616,617,618,619,620,615,616,950,951,619,620,615,616, +632,633,628,629,630,631,632,633,628,629,963,964,632,633,628,629, +645,646,641,642,643,644,645,646,641,642,976,977,645,646,641,642, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +580,581,576,577,578,579,580,581,576,577,578,579,1239,581,576,577, +593,594,589,590,591,592,593,594,589,590,591,592,1252,594,589,590, +606,607,602,603,1453,1454,606,607,602,603,604,605,1265,607,602,603, +619,620,615,616,1466,1467,619,620,615,616,617,618,619,620,615,616, +632,633,628,629,1479,1480,632,633,628,629,630,631,632,633,628,629, +645,646,641,642,643,644,645,646,641,642,643,644,645,646,641,642, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +580,581,576,577,578,579,580,581,576,577,578,579,580,581,576,577, +593,594,589,590,591,592,593,594,589,590,591,592,593,594,589,590, +606,607,602,603,604,605,606,607,602,603,604,605,606,607,602,603, +619,620,615,616,617,618,619,620,615,950,951,618,619,620,615,616, +632,633,628,629,630,631,632,633,628,963,964,631,632,633,628,629 + + +617,618,619,620,615,616,617,1466,1467,620,615,616,950,951,619,620, +1397,631,632,633,628,629,630,1479,1480,633,628,629,963,964,632,633, +1410,644,645,646,641,642,643,644,645,646,641,642,976,977,645,646, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +578,579,580,581,576,577,578,579,580,581,576,577,578,579,580,581, +591,1333,1334,594,589,590,591,592,593,594,589,590,591,592,593,594, +604,1346,1347,607,602,603,604,605,606,607,602,603,604,605,606,607, +617,1359,1360,620,615,1325,1326,618,619,620,615,616,950,951,619,620, +1265,631,632,633,628,1338,1339,631,632,633,628,629,963,964,632,633, +1278,644,645,646,641,642,643,644,1378,646,641,642,976,977,645,646, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +578,579,580,581,576,577,578,579,580,581,576,577,578,579,580,581, +1453,1454,593,594,589,590,591,592,593,594,589,590,591,592,593,594, +1466,1467,606,607,602,603,604,605,606,607,602,603,604,605,606,607, +1479,1480,619,620,615,616,950,951,619,620,615,616,617,618,619,620, +630,631,632,633,628,629,963,964,632,633,628,629,630,631,632,633 + + +641,642,643,644,645,646,641,642,643,644,645,646,641,642,105,106, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +576,577,578,579,580,581,576,577,578,579,580,581,576,577,578,579, +589,590,591,592,593,594,589,590,591,592,593,594,589,590,591,592, +602,603,1453,1454,606,607,602,603,604,605,606,607,602,603,604,605, +615,616,1466,1467,619,620,615,616,950,951,619,620,615,616,617,618, +628,629,1479,1480,632,633,628,629,963,964,632,633,628,629,630,631, +641,642,643,644,645,646,641,642,976,977,645,646,641,642,643,644, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +576,577,578,579,580,581,576,577,578,579,580,581,576,577,578,579, +589,590,591,592,593,594,589,590,591,592,593,594,589,590,591,592, +602,603,604,605,606,607,602,603,604,573,574,607,602,603,604,454, +615,950,951,618,619,620,615,616,617,618,619,620,615,616,617,467, +628,963,964,631,632,633,628,629,630,631,632,633,628,629,630,631, +641,976,977,1378,645,646,641,642,643,644,645,646,641,642,643,644, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +645,646,641,642,643,1378,645,646,641,976,977,644,645,646,641,642, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +580,581,576,577,578,579,580,581,576,577,578,579,580,581,576,577, +593,594,589,590,591,592,593,594,589,590,591,592,593,594,589,590, +0,607,602,603,604,605,606,607,602,603,1325,1326,606,607,602,603, +0,620,615,616,617,618,619,620,615,616,1338,1339,619,620,615,616, +0,633,628,0,0,631,632,633,628,629,1397,631,632,633,628,629, +0,646,641,0,0,644,645,646,641,642,1410,644,645,646,641,642, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +580,581,576,577,578,579,580,581,576,577,578,579,580,581,576,577, +593,594,589,590,591,462,463,594,589,590,591,592,593,594,589,590, +455,607,602,603,604,475,476,607,602,603,604,605,606,607,602,603, +468,620,615,616,617,488,489,620,615,616,617,0,0,620,615,616, +632,633,628,629,630,631,632,633,628,629,630,0,0,633,628,629, +645,646,641,642,643,644,645,646,641,642,643,0,0,646,641,642, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +643,644,645,646,641,642,976,977,645,646,641,642,1378,644,645,646, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +578,579,580,581,576,0,578,579,580,581,576,577,578,579,580,581, +591,592,593,594,589,0,591,592,593,594,589,590,591,592,593,594, +604,605,606,607,602,0,604,605,606,607,602,603,604,605,606,607, +950,951,619,620,615,0,617,618,619,620,615,616,950,951,619,620, +963,964,632,633,628,0,630,631,632,633,628,629,963,964,632,633, +976,977,645,646,641,0,643,1378,645,646,641,642,976,977,645,646, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +578,579,580,581,576,577,578,579,580,581,576,577,578,579,580,581, +591,592,593,594,589,590,591,592,593,594,589,590,591,592,593,594, +604,605,606,607,602,603,604,605,606,0,0,603,604,605,606,607, +950,951,619,620,615,616,617,618,619,0,0,616,617,618,619,620, +963,964,632,633,628,629,630,631,0,0,0,0,630,631,632,633, +976,977,645,646,641,642,643,644,0,0,0,0,643,644,645,1378, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,1567,1568,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,1567,1568,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,1580,1581,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,1580,1581,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,1567,1568,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,1580,1581,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,1582,1583,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,1567,1568,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,1580,1581,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,1238,1238,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,1567,1568,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,1580,1581,0,0,0,0,0, +0,0,0,0,0,0,0,0,1567,1568,1567,1568,0,0,0,0, +0,0,0,0,0,0,0,0,1580,1581,1580,1581,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index db940ca..6437e4f 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -226,7 +226,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities Zombie targetZombie = (Zombie)targets.First(); targetZombie.TakeDamage(); } - targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)); + targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)).OrderBy(x => (x.Pos - Pos).LengthSquared()); if (targets.Count() > 0) { SilasHands targetHand = (SilasHands)targets.First(); From d834423b7e12a5b8eb038fd13acfd124b2b41432 Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Fri, 18 Aug 2023 18:31:45 +0300 Subject: [PATCH 19/23] =?UTF-8?q?=D0=94=D0=92=D0=95=D0=A0=D0=98=20=D0=A1?= =?UTF-8?q?=D0=9F=D0=90=D0=92=D0=9D=D0=AF=D0=A2=D0=A1=D0=AF(+=20=D0=B1?= =?UTF-8?q?=D0=B5=D0=BB=D1=8B=20=D0=BA=D0=B2=D0=B0=D0=B4=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D1=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DangerousD/Content/Content.mgcb | 84 ++++++++---------- DangerousD/Content/Door.tsx | 2 +- DangerousD/Content/{doors.png => door.png} | Bin DangerousD/Content/lvl2.tmx | 2 +- .../GameCore/GameObjects/Entities/Door.cs | 2 +- DangerousD/GameCore/Managers/AppManager.cs | 2 +- DangerousD/GameCore/Managers/MapManager.cs | 34 ++++++- 7 files changed, 74 insertions(+), 52 deletions(-) rename DangerousD/Content/{doors.png => door.png} (100%) diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index b3ce6cc..8296497 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -21,18 +21,6 @@ /processorParam:TextureFormat=Compressed /build:ButtonFont.spritefont -#begin checkboxs_off.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:checkboxs_off.png - #begin checkboxs_off-on.png /importer:TextureImporter /processor:TextureProcessor @@ -45,6 +33,18 @@ /processorParam:TextureFormat=Color /build:checkboxs_off-on.png +#begin checkboxs_off.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:checkboxs_off.png + #begin checkboxs_on.png /importer:TextureImporter /processor:TextureProcessor @@ -81,14 +81,7 @@ /processorParam:TextureFormat=Color /build:deathBackground.jpg - -#begin DoomTestSong.mp3 -/importer:Mp3Importer -/processor:SoundEffectProcessor -/processorParam:Quality=Best -/build:sounds/DoomTestSong.mp3 - -#begin doors.png +#begin door.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -98,7 +91,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:doors.png +/build:door.png #begin Font_12.spritefont /importer:FontDescriptionImporter @@ -243,6 +236,19 @@ /processorParam:TextureFormat=Color /build:sliderBackground.png + +#begin SmokeAnimation2.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:smokeAnimation2.png + #begin sounds/DoomTestSong.mp3 /importer:Mp3Importer /processor:SoundEffectProcessor @@ -255,18 +261,6 @@ /processorParam:Quality=Best /build:sounds/shotgun_shot.mp3 -#begin smokeAnimation2.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:smokeAnimation2.png - #begin textboxbackground1-1.png /importer:TextureImporter /processor:TextureProcessor @@ -279,18 +273,6 @@ /processorParam:TextureFormat=Color /build:textboxbackground1-1.png -#begin textboxbackground2,5-1.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:textboxbackground2,5-1.png - #begin textboxbackground2-1.png /importer:TextureImporter /processor:TextureProcessor @@ -303,6 +285,18 @@ /processorParam:TextureFormat=Color /build:textboxbackground2-1.png +#begin textboxbackground2,5-1.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:textboxbackground2,5-1.png + #begin textboxbackground6-1.png /importer:TextureImporter /processor:TextureProcessor diff --git a/DangerousD/Content/Door.tsx b/DangerousD/Content/Door.tsx index 8e5687c..a250dd5 100644 --- a/DangerousD/Content/Door.tsx +++ b/DangerousD/Content/Door.tsx @@ -1,4 +1,4 @@ - + diff --git a/DangerousD/Content/doors.png b/DangerousD/Content/door.png similarity index 100% rename from DangerousD/Content/doors.png rename to DangerousD/Content/door.png diff --git a/DangerousD/Content/lvl2.tmx b/DangerousD/Content/lvl2.tmx index 2457874..d610a6f 100644 --- a/DangerousD/Content/lvl2.tmx +++ b/DangerousD/Content/lvl2.tmx @@ -612,7 +612,7 @@ - + diff --git a/DangerousD/GameCore/GameObjects/Entities/Door.cs b/DangerousD/GameCore/GameObjects/Entities/Door.cs index fe18355..0584251 100644 --- a/DangerousD/GameCore/GameObjects/Entities/Door.cs +++ b/DangerousD/GameCore/GameObjects/Entities/Door.cs @@ -21,7 +21,7 @@ namespace DangerousD.GameCore.GameObjects.Entities Height = (int)size.Y; } - protected override GraphicsComponent GraphicsComponent { get; } = new("doors"); + protected override GraphicsComponent GraphicsComponent { get; } = new("door"); public override void Update(GameTime gameTime) { diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 7689727..1b517a2 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -77,7 +77,7 @@ namespace DangerousD.GameCore DebugHUD = new DebugHUD(); UIManager.resolution = resolution; UIManager.resolutionInGame = inGameResolution; - currentMap = "lvl"; + currentMap = "lvl2"; } protected override void Initialize() diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs index 9087d97..222b897 100644 --- a/DangerousD/GameCore/Managers/MapManager.cs +++ b/DangerousD/GameCore/Managers/MapManager.cs @@ -41,7 +41,7 @@ namespace DangerousD.GameCore.Managers { InstantiateTiles(layer, tileSize); } - + foreach (XmlNode layer in xml.DocumentElement.SelectNodes("objectgroup")) { InstantiateEntities(layer); @@ -91,16 +91,20 @@ namespace DangerousD.GameCore.Managers private void InstantiateEntities(XmlNode group) { - string entityGroup = group.Attributes["class"] is not null ? group.Attributes["class"].Value : ""; + string entityGroup = group.Attributes["class"] is not null ? "." + group.Attributes["class"].Value : ""; + Debug.Write(entityGroup); float offsetX = group.Attributes["offsetx"] is not null ? float.Parse(group.Attributes["offsetx"].Value) : 0; float offsetY = group.Attributes["offsety"] is not null ? float.Parse(group.Attributes["offsety"].Value) : 0; + foreach (XmlNode entity in group.ChildNodes) { string entityType = entity.Attributes["type"] is not null ? "." + entity.Attributes["type"].Value : ""; - Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{entityGroup}{entityType}"); + Type type = Type.GetType($"DangerousD.GameCore.GameObjects{entityGroup}{entityType}"); + Vector2 pos = new Vector2(float.Parse(entity.Attributes["x"].Value, CultureInfo.InvariantCulture) + offsetX, float.Parse(entity.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY) * _scale; + Entity inst; if (type.Equals(typeof(Player))) { @@ -111,6 +115,30 @@ namespace DangerousD.GameCore.Managers int gid = entity.Attributes["gid"] is not null ? int.Parse(entity.Attributes["gid"].Value) : 0; inst = (Entity)Activator.CreateInstance(type, pos, new Vector2(32, 48), new Rectangle((gid - 872)*32, 0, 32, 48)); } + else if (type.Equals(typeof(TeleportingDoor))) + { + int gid = entity.Attributes["gid"] is not null ? int.Parse(entity.Attributes["gid"].Value) : 0; + XmlNode node = entity.SelectSingleNode("properties/property[@name = 'nextLevel']"); + + bool resetLevel = node is not null ? bool.Parse(node.Attributes["value"].Value) : false; + if (resetLevel) + { + inst = (Entity)Activator.CreateInstance(type, pos, new Vector2(32, 48), new Rectangle((gid - 872) * 32, 0, 32, 48), + new Vector2(0,0), + () => { }); + } + else + { + node = entity.SelectSingleNode("properties/property[@name = 'destination']"); + string target = node is not null ? node.Attributes["value"].Value : "0"; + XmlNode dest = group.SelectSingleNode($"object[@id = '{target}']"); + + inst = (Entity)Activator.CreateInstance(type, pos, new Vector2(32, 48), new Rectangle((gid - 872) * 32, 0, 32, 48), + new Vector2(float.Parse(dest.Attributes["x"].Value, CultureInfo.InvariantCulture) + offsetX, + float.Parse(dest.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY) * _scale, + () => { }); + } + } else { inst = (Entity)Activator.CreateInstance(type, pos); From 7783f1dc82aa0ca5b5ea3e5f64b2aac3e8e980dc Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Fri, 18 Aug 2023 19:30:14 +0300 Subject: [PATCH 20/23] Level 1 --- DangerousD/GameCore/Managers/AppManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 1b517a2..7689727 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -77,7 +77,7 @@ namespace DangerousD.GameCore DebugHUD = new DebugHUD(); UIManager.resolution = resolution; UIManager.resolutionInGame = inGameResolution; - currentMap = "lvl2"; + currentMap = "lvl"; } protected override void Initialize() From 8c258f9e5b176f61041f4a364684a44e16ce40a8 Mon Sep 17 00:00:00 2001 From: AnloGames <7383an@gmail.com> Date: Fri, 18 Aug 2023 19:32:20 +0300 Subject: [PATCH 21/23] BulletNetworkSupport --- .../LivingEntities/Player/Player.cs | 199 ++++++++++++------ DangerousD/GameCore/Managers/AppManager.cs | 6 + DangerousD/GameCore/Network/NetworkTask.cs | 3 +- 3 files changed, 147 insertions(+), 61 deletions(-) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index fc34e25..aee2cde 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -10,6 +10,7 @@ using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Graphics; using DangerousD.GameCore.GameObjects.LivingEntities.Monsters; using DangerousD.GameCore.Network; +using DangerousD.GameCore.GameObjects.MapObjects; namespace DangerousD.GameCore.GameObjects.LivingEntities { @@ -55,25 +56,29 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities leftBorder = (int)position.X - 100; bullets = 5; - this.GraphicsComponent.actionOfAnimationEnd += (a) => - { - if (a == "playerShootLeft" || a == "playerShootRight") - { - isShooting = false; - } - if (a == "playerReload") - { - bullets++; - } - }; } - + this.GraphicsComponent.actionOfAnimationEnd += (a) => + { + if (a == "playerShootLeft" || a == "playerShootRight") + { + isShooting = false; + } + if (a == "playerReload") + { + bullets++; + } + if (a == "playerShootBoomUpRight" || a == "playerShootBoomUpLeft") + { + isShooting = false; + } + }; } public bool IsAlive { get { return isAlive; } } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft", - "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft"}, "playerReload"); + "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft", "playerShootBoomUpRight", + "playerShootBoomUpLeft"}, "playerReload"); public void Attack() { @@ -89,10 +94,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } public Rectangle GetShootRectangle(bool isRight) { - if (isRight) + if (isRight) return new Rectangle((int)Pos.X, (int)(Pos.Y) + 10, shootLength + Width, Height / 2); else - return new Rectangle((int)Pos.X-shootLength, (int)(Pos.Y) + 10, shootLength, Height / 2); + return new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y) + 10, shootLength, Height / 2); } public override void Draw(SpriteBatch spriteBatch) { @@ -118,7 +123,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities return; } isAttacked = true; - if(monsterName == "Zombie") + if (monsterName == "Zombie") { AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); deathRectangle.Gr.actionOfAnimationEnd += (a) => @@ -129,7 +134,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } }; } - else if(monsterName == "Spider") + else if (monsterName == "Spider") { AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); deathRectangle.Gr.actionOfAnimationEnd += (a) => @@ -184,41 +189,37 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities bullets--; if (isRight) { - StartCicycleAnimation("playerShootRight"); - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets.Count() > 0) + if (!isUping) { - Zombie targetZombie = (Zombie)targets.First(); - targetZombie.TakeDamage(); - + StartCicycleAnimation("playerShootRight"); + Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y)); + bullet.ShootRight(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8)); } - targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets.Count() > 0) + else { - SilasHands targetHand = (SilasHands)targets.First(); - targetHand.TakeDamage(); + StartCicycleAnimation("playerShootBoomUpRight"); + Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y)); + bullet.ShootUpRight(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8)); } - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); } - else + else if (!isRight) { - StartCicycleAnimation("playerShootLeft"); - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie)); - if (targets != null) + if (!isUping) { - foreach (var target in targets) - { - Zombie targetZombie = (Zombie)target; - targetZombie.TakeDamage(); - } + StartCicycleAnimation("playerShootBoomUpLeft"); + Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y)); + bullet.ShootLeft(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7)); } - targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)); - if (targets.Count() > 0) + else { - SilasHands targetHand = (SilasHands)targets.First(); - targetHand.TakeDamage(); + StartCicycleAnimation("playerShootBoomUpLeft"); + Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y)); + bullet.ShootUpLeft(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7)); } - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7)); } } } @@ -239,7 +240,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities FallingThroughPlatform = false; } GraphicsComponent.SetCameraPosition(Pos); - if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat) + if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat) { if (!isShooting) { @@ -282,14 +283,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит { - if(bullets < 5) - { - if (GraphicsComponent.GetCurrentAnimation != "playerReload") - { - GraphicsComponent.StartAnimation("playerReload"); - } - } - else if (isRight) + if (isRight) { if (isUping) { @@ -298,6 +292,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities GraphicsComponent.StartAnimation("playerShootUpRight"); } } + else if (bullets < 5) + { + if (GraphicsComponent.GetCurrentAnimation != "playerReload") + { + GraphicsComponent.StartAnimation("playerReload"); + } + } else { GraphicsComponent.StartAnimation("playerRightStay"); @@ -312,6 +313,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities GraphicsComponent.StartAnimation("playerShootUpLeft"); } } + else if (bullets < 5) + { + if (GraphicsComponent.GetCurrentAnimation != "playerReload") + { + GraphicsComponent.StartAnimation("playerReload"); + } + } else { GraphicsComponent.StartAnimation("playerStayLeft"); @@ -319,11 +327,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } } } - if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer) - { - NetworkTask task = new NetworkTask(id, Pos); - AppManager.Instance.NetworkTasks.Add(task); - } } public void MoveDown() { @@ -331,13 +334,89 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities isOnGround = false; } - public class Bullet : GameObjects.LivingEntity + public class Bullet : LivingEntity { public Bullet(Vector2 position) : base(position) { + Height = 5; + Width = 5; + } + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft" }, "playerMoveLeft"); + Vector2 direction; + Vector2 maindirection; + public void ShootUpRight() + { + direction = new Vector2(1, -1); + acceleration = Vector2.Zero; + velocity = new Vector2(10, 10) * direction; + maindirection = velocity; + if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Client) + { + NetworkTask task = new NetworkTask(typeof(Bullet), Pos, id, velocity); + AppManager.Instance.NetworkTasks.Add(task); + AppManager.Instance.GameManager.Remove(this); + } + } + public void ShootRight() + { + direction = new Vector2(1, 0); + acceleration = Vector2.Zero; + velocity = new Vector2(10, 10) * direction; + maindirection = velocity; + if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Client) + { + NetworkTask task = new NetworkTask(typeof(Bullet), Pos, id, velocity); + AppManager.Instance.NetworkTasks.Add(task); + AppManager.Instance.GameManager.Remove(this); + } + } + public void ShootLeft() + { + direction = new Vector2(-1, 0); + acceleration = Vector2.Zero; + velocity = new Vector2(10, 10) * direction; + maindirection = velocity; + if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Client) + { + NetworkTask task = new NetworkTask(typeof(Bullet), Pos, id, velocity); + AppManager.Instance.NetworkTasks.Add(task); + AppManager.Instance.GameManager.Remove(this); + } + } + public void ShootUpLeft() + { + direction = new Vector2(-1, -1); + acceleration = Vector2.Zero; + velocity = new Vector2(10, 10) * direction; + maindirection = velocity; + if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Client) + { + NetworkTask task = new NetworkTask(typeof(Bullet), Pos, id, velocity); + AppManager.Instance.NetworkTasks.Add(task); + AppManager.Instance.GameManager.Remove(this); + } + } + public override void OnCollision(GameObject gameObject) + { + if (gameObject is not Player) + { + if (gameObject is CoreEnemy) + { + CoreEnemy enemy = (CoreEnemy)gameObject; + enemy.TakeDamage(1); + AppManager.Instance.GameManager.Remove(this); + } + base.OnCollision(gameObject); + } + } + public override void Update(GameTime gameTime) + { + if (maindirection != velocity) + { + AppManager.Instance.GameManager.Remove(this); + } + base.Update(gameTime); } - protected override GraphicsComponent GraphicsComponent { get; } = new("ZombieMoveLeft"); - } } -} +} \ No newline at end of file diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 399b866..854ec75 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -236,6 +236,12 @@ namespace DangerousD.GameCore SoundManager.StartSound(networkTask.name, networkTask.position, GameManager.GetPlayer1.Pos); break; case NetworkTaskOperationEnum.CreateEntity: + if (networkTask.type == typeof(Player.Bullet)) + { + Player.Bullet bullet = new Player.Bullet(networkTask.position); + bullet.id = networkTask.objId; + bullet.velocity = networkTask.velocity; + } break; case NetworkTaskOperationEnum.SendPosition: if (networkTask.objId != GameManager.GetPlayer1.id ) diff --git a/DangerousD/GameCore/Network/NetworkTask.cs b/DangerousD/GameCore/Network/NetworkTask.cs index f9b6072..17bf92b 100644 --- a/DangerousD/GameCore/Network/NetworkTask.cs +++ b/DangerousD/GameCore/Network/NetworkTask.cs @@ -38,11 +38,12 @@ namespace DangerousD.GameCore.Network /// /// /// - public NetworkTask(Type EntityType, Vector2 EntityPosition, int ParentId) + public NetworkTask(Type EntityType, Vector2 EntityPosition, int ParentId, Vector2 velocity) { operation = NetworkTaskOperationEnum.CreateEntity; type = EntityType; position = EntityPosition; + this.velocity = velocity; objId = ParentId; } From 0a9f39dbb19a7e31c339494c6c52f9c3b47699d0 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Fri, 18 Aug 2023 19:40:06 +0300 Subject: [PATCH 22/23] =?UTF-8?q?=D0=BE=D1=82=D0=BC=D0=B5=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 6cd93bc..afffe9a 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -424,7 +424,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities if (gameObject is CoreEnemy) { CoreEnemy enemy = (CoreEnemy)gameObject; - enemy.TakeDamage(1); + enemy.TakeDamage(); AppManager.Instance.GameManager.Remove(this); } base.OnCollision(gameObject); From b5224f10aa3318b69ed3c2dfa06b5795d13aada0 Mon Sep 17 00:00:00 2001 From: AnloGames <7383an@gmail.com> Date: Fri, 18 Aug 2023 19:41:52 +0300 Subject: [PATCH 23/23] sascsacas --- .../LivingEntities/Player/Player.cs | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index afffe9a..deb8ae4 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -193,19 +193,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities if (!isUping) { StartCicycleAnimation("playerShootRight"); - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets.Count() > 0) - { - Zombie targetZombie = (Zombie)targets.First(); - targetZombie.TakeDamage(); - } - targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets.Count() > 0) - { - SilasHands targetHand = (SilasHands)targets.First(); - targetHand.TakeDamage(); - } - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); + Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y)); + bullet.ShootRight(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8)); } else { @@ -219,20 +209,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { if (!isUping) { - StartCicycleAnimation("playerShootLeft"); - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets.Count() > 0) - { - Zombie targetZombie = (Zombie)targets.First(); - targetZombie.TakeDamage(); - } - targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets.Count() > 0) - { - SilasHands targetHand = (SilasHands)targets.First(); - targetHand.TakeDamage(); - } - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7)); + StartCicycleAnimation("playerShootBoomUpLeft"); + Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y)); + bullet.ShootLeft(); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7)); } else {