diff --git a/logic/Client/View/MainPage.xaml.cs b/logic/Client/View/MainPage.xaml.cs index 62e1c995..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, @@ -85,7 +86,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 606efb5f..688a12ab 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 { @@ -845,7 +849,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,46 +944,48 @@ 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; + Playback("E:\\program\\Project\\THUAI7\\logic\\Client\\114514.thuai7.pb", 2.0); + //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", - "8888", - "1", - "0", - "1" - }); - d.Commands.Launched = true; + + //ConnectToServer(new string[]{ + // "localhost", + // "8888", + // "1", + // "0", + // "1" + //}); + //d.Commands.Launched = true; + // 连接Server,comInfo[]的格式:0-ip 1- port 2-playerID (>2023则为观察者模式) //ConnectToServer(new string[]{ @@ -993,7 +999,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 91811094..50956e80 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; @@ -541,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; @@ -568,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; @@ -595,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; @@ -622,12 +633,14 @@ 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: + // case (long)PlayerTeam.Blue: + case 1: MapPatchesList[index].PatchColor = PatchColorDict[MapPatchType.Fort]; MapPatchesList[index].TextColor = Colors.Blue; break;