From acee6b82eaf2a8cfbf7d8c90a9cc1a66eb1095a3 Mon Sep 17 00:00:00 2001 From: Grange <2634070476@qq.com> Date: Sat, 13 Apr 2024 21:21:55 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20bullet=20displa?= =?UTF-8?q?y=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/Client/View/MainPage.xaml.cs | 2 +- logic/Client/ViewModel/GeneralViewModel.cs | 66 +++++++++++----------- logic/Client/ViewModel/MapViewModel.cs | 15 +++-- 3 files changed, 44 insertions(+), 39 deletions(-) diff --git a/logic/Client/View/MainPage.xaml.cs b/logic/Client/View/MainPage.xaml.cs index 62e1c995..50313c15 100644 --- a/logic/Client/View/MainPage.xaml.cs +++ b/logic/Client/View/MainPage.xaml.cs @@ -85,7 +85,7 @@ public MainPage() { CircleLabel bulletinfo = new() { - CLDiameter = unitWidth * 1, + CLDiameter = unitWidth * 0.4, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, CLBackgroundColor = Colors.Black, diff --git a/logic/Client/ViewModel/GeneralViewModel.cs b/logic/Client/ViewModel/GeneralViewModel.cs index 377f4ef8..590f0df5 100644 --- a/logic/Client/ViewModel/GeneralViewModel.cs +++ b/logic/Client/ViewModel/GeneralViewModel.cs @@ -845,7 +845,7 @@ Show the error message AttackMsg attackMsg = new AttackMsg(); attackMsg.PlayerId = playerID; attackMsg.TeamId = teamID; - attackMsg.Angle = 0; + attackMsg.Angle = lastMoveAngle; client.Attack(attackMsg); }); @@ -940,37 +940,37 @@ Show the error message // PureDrawMap(GameMap.GameMapArray); //ReactToCommandline(); - installer.Data.ConfigData d = new(); - ip = d.Commands.IP; - port = d.Commands.Port; - playerID = d.Commands.LaunchID; - teamID = Convert.ToInt64(d.Commands.TeamID); - shipTypeID = Convert.ToInt32(d.Commands.ShipType); - playbackFile = d.Commands.PlaybackFile; - playbackSpeed = d.Commands.PlaybackSpeed; - - if (playbackFile == "") - { - try - { - string[] comInfo = new string[5]; - comInfo[0] = ip; - comInfo[1] = port; - comInfo[2] = Convert.ToString(playerID); - comInfo[3] = Convert.ToString(teamID); - comInfo[4] = Convert.ToString(shipTypeID); - ConnectToServer(comInfo); - OnReceive(); - } - catch - { - OnReceive(); - } - } - else - { - Playback(playbackFile, playbackSpeed); - } + //installer.Data.ConfigData d = new(); + //ip = d.Commands.IP; + //port = d.Commands.Port; + //playerID = Convert. ToInt64(d.Commands.PlayerID); + //teamID = Convert.ToInt64(d.Commands.TeamID); + //shipTypeID = Convert.ToInt32(d.Commands.ShipType); + //playbackFile = d.Commands.PlaybackFile; + //playbackSpeed = d.Commands.PlaybackSpeed; + + //if (playbackFile == "") + //{ + // try + // { + // string[] comInfo = new string[5]; + // comInfo[0] = ip; + // comInfo[1] = port; + // comInfo[2] = Convert.ToString(playerID); + // comInfo[3] = Convert.ToString(teamID); + // comInfo[4] = Convert.ToString(shipTypeID); + // ConnectToServer(comInfo); + // OnReceive(); + // } + // catch + // { + // OnReceive(); + // } + //} + //else + //{ + // Playback(playbackFile, playbackSpeed); + //} // 连接Server,comInfo[]的格式:0-ip 1- port 2-playerID 3-teamID 4-ShipType ConnectToServer(new string[]{ "localhost", @@ -979,7 +979,7 @@ Show the error message "0", "1" }); - d.Commands.Launched = true; + //d.Commands.Launched = true; // 连接Server,comInfo[]的格式:0-ip 1- port 2-playerID (>2023则为观察者模式) //ConnectToServer(new string[]{ diff --git a/logic/Client/ViewModel/MapViewModel.cs b/logic/Client/ViewModel/MapViewModel.cs index 2e4be140..eb73e231 100644 --- a/logic/Client/ViewModel/MapViewModel.cs +++ b/logic/Client/ViewModel/MapViewModel.cs @@ -280,12 +280,12 @@ private void DrawShip() long team_id = data.TeamId; switch (team_id) { - case (long)PlayerTeam.Red: + case 0: System.Diagnostics.Debug.WriteLine("shipinfo.color = red"); shipinfo.Color = Colors.DarkRed; break; - case (long)PlayerTeam.Blue: + case 1: System.Diagnostics.Debug.WriteLine("shipinfo.color = blue"); shipinfo.Color = Colors.DarkBlue; @@ -318,7 +318,9 @@ private void DrawBullet() { for (int i = 0; i < BulletCircList.Count; i++) { - BulletCircList[i].Color = Colors.Transparent; + //BulletCircList[i].Color = Colors.Transparent; + BulletCircList[i].X = 51; + BulletCircList[i].Y = 51; BulletCircList[i].Text = ""; } System.Diagnostics.Debug.WriteLine(String.Format("listOfBullet.Count:{0}", listOfBullet.Count)); @@ -331,14 +333,17 @@ private void DrawBullet() bulletinfo.X = point.X; bulletinfo.Y = point.Y; long team_id = data.TeamId; + System.Diagnostics.Debug.WriteLine(String.Format("bulletinfo.X:{0}", bulletinfo.X)); + System.Diagnostics.Debug.WriteLine(String.Format("bulletinfo.Y:{0}", bulletinfo.Y)); + //System.Diagnostics.Debug.WriteLine(String.Format("Bullet{0}.Teamid:{1}", i, data.TeamId)); switch (team_id) { - case (long)PlayerTeam.Red: + case 0: System.Diagnostics.Debug.WriteLine("bulletinfo.color = red"); bulletinfo.Color = Colors.DarkRed; break; - case (long)PlayerTeam.Blue: + case 1: System.Diagnostics.Debug.WriteLine("bulletinfo.color = blue"); bulletinfo.Color = Colors.DarkBlue; break; From f0d5d3f047b0b863c2900e66b51e4749834b2eac Mon Sep 17 00:00:00 2001 From: Grange <2634070476@qq.com> Date: Sat, 13 Apr 2024 22:00:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20map=20coordinat?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/Client/View/MainPage.xaml.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logic/Client/View/MainPage.xaml.cs b/logic/Client/View/MainPage.xaml.cs index 50313c15..3b0cd64b 100644 --- a/logic/Client/View/MainPage.xaml.cs +++ b/logic/Client/View/MainPage.xaml.cs @@ -47,7 +47,8 @@ public MainPage() HeightRequest = unitHeight, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, - Margin = new Thickness(unitWidth * (49 - j), unitHeight * (49 - i), 0, 0), + //Margin = new Thickness(unitWidth * (49 - j), unitHeight * (49 - i), 0, 0), + Margin = new Thickness(unitWidth * (j), unitHeight * (i), 0, 0), HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, Padding = 0, From aae0ad01549537e8448e7e0b240eae154d8d3581 Mon Sep 17 00:00:00 2001 From: Grange <2634070476@qq.com> Date: Sat, 13 Apr 2024 22:00:34 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20teamid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/Client/ViewModel/GeneralViewModel.cs | 30 ++++++++++++---------- logic/Client/ViewModel/MapViewModel.cs | 26 ++++++++++++------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/logic/Client/ViewModel/GeneralViewModel.cs b/logic/Client/ViewModel/GeneralViewModel.cs index 590f0df5..c9629789 100644 --- a/logic/Client/ViewModel/GeneralViewModel.cs +++ b/logic/Client/ViewModel/GeneralViewModel.cs @@ -482,11 +482,13 @@ private void Refresh(object sender, EventArgs e) foreach (var data in listOfHome) { DrawHome(data); - if (data.TeamId == (long)PlayerTeam.Red) + // if (data.TeamId == (long)PlayerTeam.Red) + if (data.TeamId == 0) { RedPlayer.Team = data.TeamId; } - else if (data.TeamId == (long)PlayerTeam.Blue) + // else if (data.TeamId == (long)PlayerTeam.Blue) + else if (data.TeamId == 1) { BluePlayer.Team = data.TeamId; } @@ -499,7 +501,8 @@ private void Refresh(object sender, EventArgs e) for (int i = 0; i < listOfShip.Count; i++) { MessageOfShip data = listOfShip[i]; - if (data.TeamId == (long)PlayerTeam.Red) + // if (data.TeamId == (long)PlayerTeam.Red) + if (data.TeamId == 0) { Ship ship = new Ship { @@ -519,7 +522,8 @@ private void Refresh(object sender, EventArgs e) RedPlayer.Ships[i] = ship; else RedPlayer.Ships.Add(ship); } - else if (data.TeamId == (long)PlayerTeam.Blue) + // else if (data.TeamId == (long)PlayerTeam.Blue) + else if (data.TeamId == 1) { Ship ship = new Ship { @@ -948,7 +952,7 @@ Show the error message //shipTypeID = Convert.ToInt32(d.Commands.ShipType); //playbackFile = d.Commands.PlaybackFile; //playbackSpeed = d.Commands.PlaybackSpeed; - + Playback("E:\\program\\Project\\THUAI7\\logic\\Client\\114514.thuai7.pb", 2.0); //if (playbackFile == "") //{ // try @@ -972,13 +976,13 @@ Show the error message // Playback(playbackFile, playbackSpeed); //} // 连接Server,comInfo[]的格式:0-ip 1- port 2-playerID 3-teamID 4-ShipType - ConnectToServer(new string[]{ - "localhost", - "8888", - "0", - "0", - "1" - }); + //ConnectToServer(new string[]{ + // "localhost", + // "8888", + // "1", + // "0", + // "1" + //}); //d.Commands.Launched = true; // 连接Server,comInfo[]的格式:0-ip 1- port 2-playerID (>2023则为观察者模式) @@ -993,7 +997,7 @@ Show the error message timerViewModel.Tick += new EventHandler(Refresh); timerViewModel.Start(); - OnReceive(); + //OnReceive(); } } } diff --git a/logic/Client/ViewModel/MapViewModel.cs b/logic/Client/ViewModel/MapViewModel.cs index eb73e231..415be44e 100644 --- a/logic/Client/ViewModel/MapViewModel.cs +++ b/logic/Client/ViewModel/MapViewModel.cs @@ -546,12 +546,14 @@ private void DrawHome(MessageOfHome data) MapPatchesList[index].Text = Convert.ToString(hp); switch (team_id) { - case (long)PlayerTeam.Red: + // case (long)PlayerTeam.Red: + case 0: MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.RedHome]; MapPatchesList[index].TextColor = Colors.White; break; - case (long)PlayerTeam.Blue: + // case (long)PlayerTeam.Blue: + case 1: MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.BlueHome]; MapPatchesList[index].TextColor = Colors.White; break; @@ -573,12 +575,14 @@ private void DrawFactory(MessageOfFactory data) MapPatchesList[index].Text = Convert.ToString(hp); switch (team_id) { - case (long)PlayerTeam.Red: + // case (long)PlayerTeam.Red: + case 0: MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Factory]; MapPatchesList[index].TextColor = Colors.Red; break; - case (long)PlayerTeam.Blue: + // case (long)PlayerTeam.Blue: + case 1: MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Factory]; MapPatchesList[index].TextColor = Colors.Blue; break; @@ -600,12 +604,14 @@ private void DrawCommunity(MessageOfCommunity data) MapPatchesList[index].Text = Convert.ToString(hp); switch (team_id) { - case (long)PlayerTeam.Red: + // case (long)PlayerTeam.Red: + case 0: MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Community]; MapPatchesList[index].TextColor = Colors.Red; break; - case (long)PlayerTeam.Blue: + // case (long)PlayerTeam.Blue: + case 1: MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Community]; MapPatchesList[index].TextColor = Colors.Blue; break; @@ -627,13 +633,15 @@ private void DrawFort(MessageOfFort data) MapPatchesList[index].Text = Convert.ToString(hp); switch (team_id) { - case (long)PlayerTeam.Red: + // case (long)PlayerTeam.Red: + case 0: MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Fort]; MapPatchesList[index].TextColor = Colors.Red; break; - case (long)PlayerTeam.Blue: - MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Fort]; + // case (long)PlayerTeam.Blue: + case 1: + MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Fort]; MapPatchesList[index].TextColor = Colors.Blue; break; From 5d5982f5f9e73a166b3153f0be640f72f3d38b2c Mon Sep 17 00:00:00 2001 From: Grange <2634070476@qq.com> Date: Sat, 13 Apr 2024 22:49:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20clang=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/Client/ViewModel/MapViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/Client/ViewModel/MapViewModel.cs b/logic/Client/ViewModel/MapViewModel.cs index 415be44e..80b49969 100644 --- a/logic/Client/ViewModel/MapViewModel.cs +++ b/logic/Client/ViewModel/MapViewModel.cs @@ -641,7 +641,7 @@ private void DrawFort(MessageOfFort data) // case (long)PlayerTeam.Blue: case 1: - MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Fort]; + MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Fort]; MapPatchesList[index].TextColor = Colors.Blue; break;