display Lives on Screen
authorBernhard Lindner <bernhard@Bernhards-MacBook-Pro.local>
Tue, 18 Dec 2018 17:32:14 +0000 (18:32 +0100)
committerBernhard Lindner <bernhard@Bernhards-MacBook-Pro.local>
Tue, 18 Dec 2018 17:32:14 +0000 (18:32 +0100)
src/full_system/ConnectionTest/ConnectionTest/ConnectionTest/App.xaml.cs
src/full_system/ConnectionTest/ConnectionTest/ConnectionTest/InGamePage.cs

index 44a2b3d..eed10ae 100644 (file)
@@ -70,6 +70,7 @@ namespace Bomberman
                             gamePage = new InGamePage(con);
                             Application.Current.MainPage = gamePage;
                             gamePage.CreateInitializePlayground(pkg.Field.Count);
+                            gamePage.UpdateLableLives(pkg);
                             gameStarted = 1;
                             updateCnt = 20;
                         }
@@ -78,6 +79,7 @@ namespace Bomberman
                             if(updateCnt == 0)
                             {
                                 gamePage.UpdatePlayground(pkg);
+                                gamePage.UpdateLableLives(pkg);
                                 updateCnt = 1;
                             }
                             else
index 2bb896b..deebb0f 100644 (file)
@@ -21,6 +21,7 @@ namespace Bomberman
 
         StackLayout fullLayout;
         StackLayout ButtonLayout = new StackLayout();
+        Label labelLives;
 
         Playground playground;
 
@@ -34,7 +35,15 @@ namespace Bomberman
             //con.Connect(IPAddress.Parse("192.168.0.5"));
             //con.Connect(Dns.GetHostEntry(Dns.GetHostName()).AddressList[1]);    //localhost
 
+            labelLives = new Label
+            {
+                Text = "Lives: 3",
+                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
+                VerticalOptions = LayoutOptions.CenterAndExpand,
+                HorizontalOptions = LayoutOptions.CenterAndExpand
+            };
 
+            ButtonLayout.Children.Add(labelLives);
 
 
             for (int i = 0; i < 3; i++)
@@ -145,6 +154,19 @@ namespace Bomberman
 
         }
 
+        public void UpdateLableLives(ServerPackage pkg)
+        {
+            for (int i = 0; i < pkg.Players.Count; i++)
+            {
+                if (pkg.Id == pkg.Players[i].Id)
+                {
+                    labelLives.Text = "Lives: " + pkg.Players[i].Life;
+                    break;
+                }
+            }
+        }
+
+
         public void UpdatePlayground(ServerPackage pkg)
         {
             if (playground == null)