diff --git a/.vs/Bowling/FileContentIndex/01d3d660-139e-451b-9dee-bdb99d4a69f0.vsidx b/.vs/Bowling/FileContentIndex/01d3d660-139e-451b-9dee-bdb99d4a69f0.vsidx deleted file mode 100644 index 5594b6a..0000000 Binary files a/.vs/Bowling/FileContentIndex/01d3d660-139e-451b-9dee-bdb99d4a69f0.vsidx and /dev/null differ diff --git a/.vs/Bowling/FileContentIndex/0d179ef8-e767-4d99-915e-83d9923cfb66.vsidx b/.vs/Bowling/FileContentIndex/0d179ef8-e767-4d99-915e-83d9923cfb66.vsidx new file mode 100644 index 0000000..5aceeda Binary files /dev/null and b/.vs/Bowling/FileContentIndex/0d179ef8-e767-4d99-915e-83d9923cfb66.vsidx differ diff --git a/.vs/Bowling/FileContentIndex/0d902478-9fc7-4a0b-90f3-5a6ddcfc3ce9.vsidx b/.vs/Bowling/FileContentIndex/0d902478-9fc7-4a0b-90f3-5a6ddcfc3ce9.vsidx new file mode 100644 index 0000000..f62aeda Binary files /dev/null and b/.vs/Bowling/FileContentIndex/0d902478-9fc7-4a0b-90f3-5a6ddcfc3ce9.vsidx differ diff --git a/.vs/Bowling/FileContentIndex/530c61b9-9373-4ca4-b74e-a3b57965fa78.vsidx b/.vs/Bowling/FileContentIndex/530c61b9-9373-4ca4-b74e-a3b57965fa78.vsidx deleted file mode 100644 index af98682..0000000 Binary files a/.vs/Bowling/FileContentIndex/530c61b9-9373-4ca4-b74e-a3b57965fa78.vsidx and /dev/null differ diff --git a/.vs/Bowling/FileContentIndex/8df22dbc-80c2-436e-8178-b170871def6a.vsidx b/.vs/Bowling/FileContentIndex/8df22dbc-80c2-436e-8178-b170871def6a.vsidx new file mode 100644 index 0000000..3fe816e Binary files /dev/null and b/.vs/Bowling/FileContentIndex/8df22dbc-80c2-436e-8178-b170871def6a.vsidx differ diff --git a/.vs/Bowling/FileContentIndex/9434741e-9aec-42e0-bfc8-299737c65020.vsidx b/.vs/Bowling/FileContentIndex/9434741e-9aec-42e0-bfc8-299737c65020.vsidx new file mode 100644 index 0000000..9f2300a Binary files /dev/null and b/.vs/Bowling/FileContentIndex/9434741e-9aec-42e0-bfc8-299737c65020.vsidx differ diff --git a/.vs/Bowling/v17/.suo b/.vs/Bowling/v17/.suo index 3c82d61..befc5e7 100644 Binary files a/.vs/Bowling/v17/.suo and b/.vs/Bowling/v17/.suo differ diff --git a/Bowling/Classes/Ball.cs b/Bowling/Classes/Ball.cs index c8b65d4..ef1807e 100644 --- a/Bowling/Classes/Ball.cs +++ b/Bowling/Classes/Ball.cs @@ -43,7 +43,7 @@ namespace Bowling.Classes public void LoadContent(ContentManager manager) { arrow.LoadContent(manager); - texture = manager.Load("ball (2)"); + texture = manager.Load("ball"); radius = texture.Width / 2; } diff --git a/Bowling/Classes/Player.cs b/Bowling/Classes/Player.cs index 75d77e2..41e1fe7 100644 --- a/Bowling/Classes/Player.cs +++ b/Bowling/Classes/Player.cs @@ -3,8 +3,7 @@ using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Sockets; -using Newtonsoft.Json; -using NetLib; +using Newtonsoft.Json; namespace Bowling.Classes { @@ -12,17 +11,11 @@ namespace Bowling.Classes internal class Player { [JsonProperty("name")] - private string name { get; set; } + public string Name { get; set; } [JsonProperty("score")] - private List score { get; set; } + public List Score { get; set; } - - public Player(string name) - { - this.name = name; - score = new List(); - } public string Serialize() { @@ -32,8 +25,8 @@ namespace Bowling.Classes public void Deserialize(string json) { Player player = JsonConvert.DeserializeObject(json); - name = player.name; - score = player.score; + Name = player.Name; + Score = player.Score; } } } diff --git a/Bowling/Classes/UI/Label.cs b/Bowling/Classes/UI/Label.cs index a5ab9dd..9183ae0 100644 --- a/Bowling/Classes/UI/Label.cs +++ b/Bowling/Classes/UI/Label.cs @@ -12,6 +12,9 @@ namespace Bowling.Classes.UI public Vector2 Position { get; set; } public string Text { get; set; } public Color Color { get; set; } + public string fontName = "gameFont"; + + public string FontName { set { fontName = value; } } public Label() { @@ -37,7 +40,7 @@ namespace Bowling.Classes.UI public void LoadContent(ContentManager Content) { - spriteFont = Content.Load("gameFont"); + spriteFont = Content.Load(fontName); } public void Draw(SpriteBatch spriteBatch) diff --git a/Bowling/Content/Content.mgcb b/Bowling/Content/Content.mgcb index 525327c..0f2e981 100644 --- a/Bowling/Content/Content.mgcb +++ b/Bowling/Content/Content.mgcb @@ -44,6 +44,13 @@ /processorParam:TextureFormat=Compressed /build:gameFont.spritefont +#begin gameFont2.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:gameFont2.spritefont + #begin keggle.png /importer:TextureImporter /processor:TextureProcessor diff --git a/Bowling/Content/bin/Windows/Content/gameFont2.xnb b/Bowling/Content/bin/Windows/Content/gameFont2.xnb new file mode 100644 index 0000000..2b1a6dc Binary files /dev/null and b/Bowling/Content/bin/Windows/Content/gameFont2.xnb differ diff --git a/Bowling/Content/bin/Windows/gameFont2.xnb b/Bowling/Content/bin/Windows/gameFont2.xnb new file mode 100644 index 0000000..2b1a6dc Binary files /dev/null and b/Bowling/Content/bin/Windows/gameFont2.xnb differ diff --git a/Bowling/Content/gameFont2.spritefont b/Bowling/Content/gameFont2.spritefont new file mode 100644 index 0000000..4bbf965 --- /dev/null +++ b/Bowling/Content/gameFont2.spritefont @@ -0,0 +1,60 @@ + + + + + + + Impact + + + 36 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + diff --git a/Bowling/Content/obj/Windows/.mgcontent b/Bowling/Content/obj/Windows/.mgcontent index ddaace0..b7acc5d 100644 --- a/Bowling/Content/obj/Windows/.mgcontent +++ b/Bowling/Content/obj/Windows/.mgcontent @@ -4,11 +4,12 @@ Windows - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/arrow.png - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/ball.png - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/gameFont.spritefont - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/keggle.png - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/logo.png + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/arrow.png + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/ball.png + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/gameFont.spritefont + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/gameFont2.spritefont + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/keggle.png + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/logo.png @@ -16,5 +17,6 @@ + \ No newline at end of file diff --git a/Bowling/Content/obj/Windows/.mgstats b/Bowling/Content/obj/Windows/.mgstats index 353d1ea..b3410d8 100644 --- a/Bowling/Content/obj/Windows/.mgstats +++ b/Bowling/Content/obj/Windows/.mgstats @@ -1,6 +1,7 @@ Source File,Dest File,Processor Type,Content Type,Source File Size,Dest File Size,Build Seconds -"C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/arrow.png","C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/arrow.xnb","TextureProcessor","Texture2DContent",365,2725,0,1655622 -"C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/ball.png","C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/ball.xnb","TextureProcessor","Texture2DContent",652,10085,0,0049702 -"C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/gameFont.spritefont","C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/gameFont.xnb","FontDescriptionProcessor","SpriteFontContent",2069,70690,0,1821461 -"C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/keggle.png","C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/keggle.xnb","TextureProcessor","Texture2DContent",276,4181,0,0110304 -"C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/logo.png","C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/logo.xnb","TextureProcessor","Texture2DContent",28661,504373,0,0495372 +"C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/arrow.png","C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/arrow.xnb","TextureProcessor","Texture2DContent",365,2725,0,1815462 +"C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/ball.png","C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/ball.xnb","TextureProcessor","Texture2DContent",652,10085,0,0060204 +"C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/gameFont.spritefont","C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/gameFont.xnb","FontDescriptionProcessor","SpriteFontContent",2069,70690,0,1249094 +"C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/gameFont2.spritefont","C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/gameFont2.xnb","FontDescriptionProcessor","SpriteFontContent",2069,136226,0,0442164 +"C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/keggle.png","C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/keggle.xnb","TextureProcessor","Texture2DContent",276,4181,0,0052916 +"C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/logo.png","C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/logo.xnb","TextureProcessor","Texture2DContent",28661,504373,0,0264658 diff --git a/Bowling/Content/obj/Windows/Content/.mgcontent b/Bowling/Content/obj/Windows/Content/.mgcontent index b0b6f5b..b7acc5d 100644 --- a/Bowling/Content/obj/Windows/Content/.mgcontent +++ b/Bowling/Content/obj/Windows/Content/.mgcontent @@ -7,6 +7,7 @@ C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/arrow.png C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/ball.png C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/gameFont.spritefont + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/gameFont2.spritefont C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/keggle.png C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/logo.png @@ -16,5 +17,6 @@ + \ No newline at end of file diff --git a/Bowling/Content/obj/Windows/Content/gameFont2.mgcontent b/Bowling/Content/obj/Windows/Content/gameFont2.mgcontent new file mode 100644 index 0000000..0e5fe24 --- /dev/null +++ b/Bowling/Content/obj/Windows/Content/gameFont2.mgcontent @@ -0,0 +1,22 @@ + + + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/gameFont2.spritefont + 2022-04-23T14:47:06+03:00 + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/Content/gameFont2.xnb + 2022-04-23T16:59:31.1175145+03:00 + FontDescriptionImporter + 2020-08-10T16:17:54+03:00 + FontDescriptionProcessor + 2020-08-10T16:17:54+03:00 + + PremultiplyAlpha + True + + + TextureFormat + Compressed + + + + + \ No newline at end of file diff --git a/Bowling/Content/obj/Windows/arrow.mgcontent b/Bowling/Content/obj/Windows/arrow.mgcontent index 0401420..f114e11 100644 --- a/Bowling/Content/obj/Windows/arrow.mgcontent +++ b/Bowling/Content/obj/Windows/arrow.mgcontent @@ -1,9 +1,9 @@ - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/arrow.png + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/arrow.png 2022-04-23T00:23:58+03:00 - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/arrow.xnb - 2022-04-23T11:30:46.7563702+03:00 + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/arrow.xnb + 2022-04-23T16:59:29.6382629+03:00 TextureImporter 2020-08-10T16:17:54+03:00 TextureProcessor diff --git a/Bowling/Content/obj/Windows/ball.mgcontent b/Bowling/Content/obj/Windows/ball.mgcontent index 346f51e..3b1606d 100644 --- a/Bowling/Content/obj/Windows/ball.mgcontent +++ b/Bowling/Content/obj/Windows/ball.mgcontent @@ -1,9 +1,9 @@ - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/ball.png + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/ball.png 2021-05-04T12:20:30+03:00 - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/ball.xnb - 2022-04-23T11:30:46.7723273+03:00 + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/ball.xnb + 2022-04-23T16:59:29.6552207+03:00 TextureImporter 2020-08-10T16:17:54+03:00 TextureProcessor diff --git a/Bowling/Content/obj/Windows/gameFont.mgcontent b/Bowling/Content/obj/Windows/gameFont.mgcontent index fea9e16..65fce25 100644 --- a/Bowling/Content/obj/Windows/gameFont.mgcontent +++ b/Bowling/Content/obj/Windows/gameFont.mgcontent @@ -1,9 +1,9 @@ - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/gameFont.spritefont + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/gameFont.spritefont 2011-04-01T09:42:38+04:00 - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/gameFont.xnb - 2022-04-23T11:30:46.9518493+03:00 + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/gameFont.xnb + 2022-04-23T16:59:29.7826428+03:00 FontDescriptionImporter 2020-08-10T16:17:54+03:00 FontDescriptionProcessor diff --git a/Bowling/Content/obj/Windows/gameFont2.mgcontent b/Bowling/Content/obj/Windows/gameFont2.mgcontent new file mode 100644 index 0000000..4836c1f --- /dev/null +++ b/Bowling/Content/obj/Windows/gameFont2.mgcontent @@ -0,0 +1,22 @@ + + + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/gameFont2.spritefont + 2022-04-23T14:47:06+03:00 + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/gameFont2.xnb + 2022-04-23T16:59:29.8289166+03:00 + FontDescriptionImporter + 2020-08-10T16:17:54+03:00 + FontDescriptionProcessor + 2020-08-10T16:17:54+03:00 + + PremultiplyAlpha + True + + + TextureFormat + Compressed + + + + + \ No newline at end of file diff --git a/Bowling/Content/obj/Windows/keggle.mgcontent b/Bowling/Content/obj/Windows/keggle.mgcontent index e5824d7..ce0dd35 100644 --- a/Bowling/Content/obj/Windows/keggle.mgcontent +++ b/Bowling/Content/obj/Windows/keggle.mgcontent @@ -1,9 +1,9 @@ - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/keggle.png + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/keggle.png 2022-04-23T00:12:43.2915834+03:00 - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/keggle.xnb - 2022-04-23T11:30:46.9648137+03:00 + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/keggle.xnb + 2022-04-23T16:59:29.8349009+03:00 TextureImporter 2020-08-10T16:17:54+03:00 TextureProcessor diff --git a/Bowling/Content/obj/Windows/logo.mgcontent b/Bowling/Content/obj/Windows/logo.mgcontent index bdf8572..c88a0f5 100644 --- a/Bowling/Content/obj/Windows/logo.mgcontent +++ b/Bowling/Content/obj/Windows/logo.mgcontent @@ -1,9 +1,9 @@ - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/logo.png + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/logo.png 2022-04-23T11:30:44.0139383+03:00 - C:/Users/Semejkin_AV/source/repos/Bowling/Bowling/Content/bin/Windows/logo.xnb - 2022-04-23T11:30:47.0166746+03:00 + C:/Users/Semejkin_AV/Documents/Github_repos/ProgtimeHack2022_Bowling/Bowling/Content/bin/Windows/logo.xnb + 2022-04-23T16:59:29.8628251+03:00 TextureImporter 2020-08-10T16:17:54+03:00 TextureProcessor diff --git a/Bowling/Game1.cs b/Bowling/Game1.cs index c435f6a..7570074 100644 --- a/Bowling/Game1.cs +++ b/Bowling/Game1.cs @@ -6,12 +6,13 @@ using Bowling.Classes.UI; using System.Collections.Generic; using System.Windows.Forms; using NetLib; +using System.Threading; namespace Bowling { public enum GameState { - Menu, Game, Exit, Connect_to_server + Menu, Game, Exit, Connect_to_server, EndGame } public class Game1 : Game { @@ -35,14 +36,11 @@ namespace Bowling private Classes.UI.Label lblCountP1; private Classes.UI.Label lblCountP2; - private int knockedPins; private List pins = new List(); public static GameState gameState = GameState.Connect_to_server; - Player player; - public static int Gutter_height { get { return gutter_height; } } public static int Gutter_top_y { get { return gutter_top_y; } } public static int Gutter_bottom_y { get { return gutter_bottom_y; } } @@ -95,7 +93,6 @@ namespace Bowling ball.LoadContent(Content); whiteRectangle = new Texture2D(GraphicsDevice, 1, 1); whiteRectangle.SetData(new[] { Color.White }); - menu.LoadContent(Content); } @@ -118,12 +115,17 @@ namespace Bowling if (connect.ShowDialog() == DialogResult.OK) { gameState = GameState.Menu; - player = new Player(connec t.name); // Игрок, потом из него подключение к серверу + gameState = GameState.Menu; + player1 = new Player() { Name = connect.Name, Score = new List() }; NetLib.NetLib.IP = connect.IP; NetLib.NetLib.port = connect.Port; NetLib.NetLib.Connect(); - NetLib.NetLib.Send(player.Serialize()); - System.Console.WriteLine(NetLib.NetLib.Receive()); + SendPlayerData(player1); + Thread thread = new Thread(() => + { + player2.Deserialize(NetLib.NetLib.Receive()); + }); + thread.Start(); } else { gameState = GameState.Exit; } break; @@ -140,6 +142,7 @@ namespace Bowling switch (gameState) { case GameState.Game: + DrawGrid(); _spriteBatch.Draw(whiteRectangle, new Rectangle(0, gutter_top_y - gutter_height, 10000, gutter_height), Color.Aquamarine); _spriteBatch.Draw(whiteRectangle, new Rectangle(0, gutter_bottom_y, 10000, gutter_height), Color.Aquamarine); for (int i = 0; i < pins.Count; i++) @@ -147,7 +150,10 @@ namespace Bowling pins[i].Draw(_spriteBatch); } ball.Draw(_spriteBatch); - base.Draw(gameTime); + foreach (Classes.UI.Label lbl in tableLabels) + { + lbl.Draw(_spriteBatch); + } break; case GameState.Menu: menu.Draw(_spriteBatch); @@ -165,13 +171,127 @@ namespace Bowling foreach (Pin pin in collides_keggles) { pin.IsVisible = false; - knockedPins++; + intermediateScore++; + } + if (ball.State == State.Gone) + { + player1.Score.Add(intermediateScore); + intermediateScore = 0; + ball = new Ball(ballStartPosition, Vector2.Zero, Color.Blue, Gutter_top_y, gutter_bottom_y, gutter_height, _graphics.PreferredBackBufferWidth); + ball.LoadContent(Content); + if (player1.Score.Count <= 20 && player1.Score.Count % 2 == 0) + { + NewMove(); + } + else if (player1.Score.Count == 20) + { + if (player1.Score[18] + player1.Score[19] == 10) NewMove(); + } + if (player1.Score.Count == 20 && player1.Score[18] + player1.Score[19] != 10) + { + gameState = GameState.EndGame; + } + SendPlayerData(player1); } } - private void GetOpponentName() + private void DrawGrid() { - + tableLabels.Clear(); + int currentRow = 0; + int currentColumn = 0; + for (int i = 0; i < 6; i++) + { + _spriteBatch.Draw(whiteRectangle, new Rectangle((i == 0 || i % 2 == 1) ? tableMarginLeft : tableMarginLeft + rowWidth, + currentRow + tableMarginTop, (i == 0 || i % 2 == 1) ? 13 * rowWidth : 12 * rowWidth, 2), Color.Black); + currentRow += (i != 0 && i % 2 == 0) ? 2 * rowHeight : rowHeight; + } + for (int i = 0; i < 13; i++) + { + _spriteBatch.Draw(whiteRectangle, new Rectangle(currentColumn + tableMarginLeft, tableMarginTop, 2, currentRow - rowHeight), + Color.Black); + currentColumn += (i == 10) ? 2 * rowWidth : rowWidth; + } + for (int i = 1; i < 11; i++) + { + int shift = (i == 10) ? tableMarginLeft - 5 + rowWidth * i + rowWidth : tableMarginLeft - 5 + rowWidth * i + rowWidth / 2; + Classes.UI.Label lbl = new Classes.UI.Label(i.ToString(), new Vector2(shift, tableMarginTop + 2), Color.Red); + lbl.LoadContent(Content); + tableLabels.Add(lbl); + } + Classes.UI.Label label = new Classes.UI.Label("TTL", new Vector2(tableMarginLeft + currentColumn - 2 * rowWidth + 10, tableMarginTop + 5), Color.Red); + label.LoadContent(Content); + tableLabels.Add(label); + for (int i = 0; i < player1.Score.Count; i++) + { + string score = (player1.Score[i] == 0) ? "-" : player1.Score[i].ToString(); + if (i != 0 && i % 2 == 1) score = (player1.Score[i] + player1.Score[i - 1] == 10) ? "/" : score; + Classes.UI.Label lbl = new Classes.UI.Label(score, new Vector2(tableMarginLeft + rowWidth + i * (rowWidth / 2) + 10, tableMarginTop + rowHeight + 5), + Color.Fuchsia); + lbl.LoadContent(Content); + tableLabels.Add(lbl); + } + for (int i = 0; i < player1.Score.Count / 2; i++) + { + int score = player1.Score[i * 2] + player1.Score[i * 2 + 1]; + Classes.UI.Label lbl = new Classes.UI.Label(score.ToString(), new Vector2(tableMarginLeft + rowWidth + i * rowWidth + 30, tableMarginTop + 2 * rowHeight + 25) + , Color.Fuchsia); + lbl.FontName = "gameFont2"; + lbl.LoadContent(Content); + tableLabels.Add(lbl); + } + int countRows = 1; + for (int i = 0; i < 4; i++) + { + int score = 0; + if (i % 2 == 0) score = 0; + else if (i == 1) score = Sum(player1.Score); + else score = Sum(player2.Score); + Classes.UI.Label lbl = new Classes.UI.Label(score.ToString(), new Vector2(tableMarginLeft + rowWidth * 12 + rowWidth / 2, tableMarginTop + countRows + rowHeight + 5), + Color.Fuchsia); + lbl.LoadContent(Content); + tableLabels.Add(lbl); + countRows += (i != 0 && i % 2 == 1) ? 2 * rowHeight : rowHeight; + } + for (int i = 0; i < player2.Score.Count; i++) + { + string score = (player2.Score[i] == 0) ? "-" : player2.Score[i].ToString(); + if (i != 0 && i % 2 == 1) score = (player2.Score[i] + player2.Score[i - 1] == 10) ? "/" : score; + Classes.UI.Label lbl = new Classes.UI.Label(score, new Vector2(tableMarginLeft + rowWidth + i * (rowWidth / 2) + 10, tableMarginTop + rowHeight * 4 + 5), + Color.Fuchsia); + lbl.LoadContent(Content); + tableLabels.Add(lbl); + } + for (int i = 0; i < player2.Score.Count / 2; i++) + { + int score = player2.Score[i * 2] + player2.Score[i * 2 + 1]; + Classes.UI.Label lbl = new Classes.UI.Label(score.ToString(), new Vector2(tableMarginLeft + rowWidth + i * rowWidth + 30, tableMarginTop + 5 * rowHeight + 25) + , Color.Fuchsia); + lbl.FontName = "gameFont2"; + lbl.LoadContent(Content); + tableLabels.Add(lbl); + } + } + + private void NewMove() + { + pins.Clear(); + LoadContent(); + } + + private int Sum(List score) + { + int sum = 0; + foreach (int a in score) + { + sum += a; + } + return sum; + } + + private void SendPlayerData(Player player) + { + NetLib.NetLib.Send(player.Serialize()); } } } \ No newline at end of file diff --git a/Bowling/bin/Debug/netcoreapp3.1/Bowling.dll b/Bowling/bin/Debug/netcoreapp3.1/Bowling.dll index 7301553..b46d960 100644 Binary files a/Bowling/bin/Debug/netcoreapp3.1/Bowling.dll and b/Bowling/bin/Debug/netcoreapp3.1/Bowling.dll differ diff --git a/Bowling/bin/Debug/netcoreapp3.1/Bowling.pdb b/Bowling/bin/Debug/netcoreapp3.1/Bowling.pdb index 2d781ee..0100f3f 100644 Binary files a/Bowling/bin/Debug/netcoreapp3.1/Bowling.pdb and b/Bowling/bin/Debug/netcoreapp3.1/Bowling.pdb differ diff --git a/Bowling/bin/Debug/netcoreapp3.1/Content/gameFont2.xnb b/Bowling/bin/Debug/netcoreapp3.1/Content/gameFont2.xnb new file mode 100644 index 0000000..2b1a6dc Binary files /dev/null and b/Bowling/bin/Debug/netcoreapp3.1/Content/gameFont2.xnb differ diff --git a/Bowling/obj/Debug/netcoreapp3.1/Bowling.csproj.AssemblyReference.cache b/Bowling/obj/Debug/netcoreapp3.1/Bowling.csproj.AssemblyReference.cache index e5b950b..5c8fb32 100644 Binary files a/Bowling/obj/Debug/netcoreapp3.1/Bowling.csproj.AssemblyReference.cache and b/Bowling/obj/Debug/netcoreapp3.1/Bowling.csproj.AssemblyReference.cache differ diff --git a/Bowling/obj/Debug/netcoreapp3.1/Bowling.csproj.FileListAbsolute.txt b/Bowling/obj/Debug/netcoreapp3.1/Bowling.csproj.FileListAbsolute.txt index 6eeed7d..dea7701 100644 --- a/Bowling/obj/Debug/netcoreapp3.1/Bowling.csproj.FileListAbsolute.txt +++ b/Bowling/obj/Debug/netcoreapp3.1/Bowling.csproj.FileListAbsolute.txt @@ -92,3 +92,4 @@ C:\Users\Semejkin_AV\Documents\Github_repos\ProgtimeHack2022_Bowling\Bowling\obj C:\Users\Semejkin_AV\Documents\Github_repos\ProgtimeHack2022_Bowling\Bowling\obj\Debug\netcoreapp3.1\Bowling.dll C:\Users\Semejkin_AV\Documents\Github_repos\ProgtimeHack2022_Bowling\Bowling\obj\Debug\netcoreapp3.1\Bowling.pdb C:\Users\Semejkin_AV\Documents\Github_repos\ProgtimeHack2022_Bowling\Bowling\obj\Debug\netcoreapp3.1\Bowling.genruntimeconfig.cache +C:\Users\Semejkin_AV\Documents\Github_repos\ProgtimeHack2022_Bowling\Bowling\bin\Debug\netcoreapp3.1\Content\gameFont2.xnb diff --git a/Bowling/obj/Debug/netcoreapp3.1/Bowling.dll b/Bowling/obj/Debug/netcoreapp3.1/Bowling.dll index 7301553..b46d960 100644 Binary files a/Bowling/obj/Debug/netcoreapp3.1/Bowling.dll and b/Bowling/obj/Debug/netcoreapp3.1/Bowling.dll differ diff --git a/Bowling/obj/Debug/netcoreapp3.1/Bowling.pdb b/Bowling/obj/Debug/netcoreapp3.1/Bowling.pdb index 2d781ee..0100f3f 100644 Binary files a/Bowling/obj/Debug/netcoreapp3.1/Bowling.pdb and b/Bowling/obj/Debug/netcoreapp3.1/Bowling.pdb differ diff --git a/Bowling_Server/Classes/Player.cs b/Bowling_Server/Classes/Player.cs index fe03125..716ce68 100644 --- a/Bowling_Server/Classes/Player.cs +++ b/Bowling_Server/Classes/Player.cs @@ -9,23 +9,14 @@ namespace Bowling_Server.Classes internal class Player { [JsonProperty("name")] - public string name { get; set; } + public string Name { get; set; } [JsonProperty("score")] - public List score { get; set; } + public List Score { get; set; } [NonSerialized] public Socket socket; - - public Player(string name) - { - this.name = name; - score = new List(); - } - public Player() - { - - } + public string Serialize() { @@ -35,8 +26,8 @@ namespace Bowling_Server.Classes public void Deserialize(string json) { Player player = JsonConvert.DeserializeObject(json); - name = player.name; - score = player.score; + Name = player.Name; + Score = player.Score; } } } diff --git a/Bowling_Server/Program.cs b/Bowling_Server/Program.cs index be46911..ada2318 100644 --- a/Bowling_Server/Program.cs +++ b/Bowling_Server/Program.cs @@ -87,6 +87,22 @@ namespace Bowling_Server { Console.WriteLine("OK"); CastOpponents(group); + foreach (var player in group) + { + Thread thread = new Thread(() => + { + byte[] data = new byte[1024]; + while (true) + { + int dataLength = player.socket.Receive(data); + string json = Encoding.ASCII.GetString(data, 0, dataLength); + player.Deserialize(json); + CastOpponents(group); + } + } + ); + thread.Start(); + } } } } diff --git a/Bowling_Server/bin/Debug/net5.0/Bowling_Server.dll b/Bowling_Server/bin/Debug/net5.0/Bowling_Server.dll index 0c8c42a..2d097e8 100644 Binary files a/Bowling_Server/bin/Debug/net5.0/Bowling_Server.dll and b/Bowling_Server/bin/Debug/net5.0/Bowling_Server.dll differ diff --git a/Bowling_Server/bin/Debug/net5.0/Bowling_Server.pdb b/Bowling_Server/bin/Debug/net5.0/Bowling_Server.pdb index c284059..d00add5 100644 Binary files a/Bowling_Server/bin/Debug/net5.0/Bowling_Server.pdb and b/Bowling_Server/bin/Debug/net5.0/Bowling_Server.pdb differ diff --git a/Bowling_Server/obj/Debug/net5.0/Bowling_Server.csproj.AssemblyReference.cache b/Bowling_Server/obj/Debug/net5.0/Bowling_Server.csproj.AssemblyReference.cache index b4172a8..1e2c5fc 100644 Binary files a/Bowling_Server/obj/Debug/net5.0/Bowling_Server.csproj.AssemblyReference.cache and b/Bowling_Server/obj/Debug/net5.0/Bowling_Server.csproj.AssemblyReference.cache differ diff --git a/Bowling_Server/obj/Debug/net5.0/Bowling_Server.dll b/Bowling_Server/obj/Debug/net5.0/Bowling_Server.dll index 0c8c42a..2d097e8 100644 Binary files a/Bowling_Server/obj/Debug/net5.0/Bowling_Server.dll and b/Bowling_Server/obj/Debug/net5.0/Bowling_Server.dll differ diff --git a/Bowling_Server/obj/Debug/net5.0/Bowling_Server.pdb b/Bowling_Server/obj/Debug/net5.0/Bowling_Server.pdb index c284059..d00add5 100644 Binary files a/Bowling_Server/obj/Debug/net5.0/Bowling_Server.pdb and b/Bowling_Server/obj/Debug/net5.0/Bowling_Server.pdb differ diff --git a/Bowling_Server/obj/Debug/net5.0/ref/Bowling_Server.dll b/Bowling_Server/obj/Debug/net5.0/ref/Bowling_Server.dll index 31093e9..ef268a3 100644 Binary files a/Bowling_Server/obj/Debug/net5.0/ref/Bowling_Server.dll and b/Bowling_Server/obj/Debug/net5.0/ref/Bowling_Server.dll differ diff --git a/Bowling_Server/obj/Debug/net5.0/refint/Bowling_Server.dll b/Bowling_Server/obj/Debug/net5.0/refint/Bowling_Server.dll index 31093e9..ef268a3 100644 Binary files a/Bowling_Server/obj/Debug/net5.0/refint/Bowling_Server.dll and b/Bowling_Server/obj/Debug/net5.0/refint/Bowling_Server.dll differ