diff --git a/logic/Client/GameStatusBar.xaml.cs b/logic/Client/GameStatusBar.xaml.cs index 974f97cc..9f246eed 100644 --- a/logic/Client/GameStatusBar.xaml.cs +++ b/logic/Client/GameStatusBar.xaml.cs @@ -4,9 +4,11 @@ namespace Client; public partial class GameStatusBar : ContentView { - private readonly int lengthOfHp1Slide; - private readonly int lengthOfHp2Slide; - private readonly int lengthOfHp3Slide; + private bool haveSetSlideLength = false; + double lengthOfWormHole1HpSlide = 80; + double lengthOfWormHole2HpSlide = 80; + double lengthOfWormHole3HpSlide = 80; + private readonly int WormHoleFullHp = 18000; public GameStatusBar(Grid parent, int Row, int Column) { @@ -25,13 +27,13 @@ public void SetWormHoleValue(MessageOfBuilding wormholeMsg) switch (wormholeMsg.BuildingId) { case 0: - WormHole1HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfHp1Slide; + WormHole1HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfWormHole1HpSlide; break; case 1: - WormHole2HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfHp2Slide; + WormHole2HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfWormHole2HpSlide; break; case 2: - WormHole3HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfHp3Slide; + WormHole3HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfWormHole3HpSlide; break; } } @@ -55,4 +57,11 @@ public void SetGameTimeValue(MessageOfAll obj) GameTime.Text += sec.ToString(); } + public void SlideLengthSet() + { + UtilFunctions.SlideLengthSet(WormHole1HpSlide, ref haveSetSlideLength, ref lengthOfWormHole1HpSlide, GameStatusGrid.Width); + UtilFunctions.SlideLengthSet(WormHole2HpSlide, ref haveSetSlideLength, ref lengthOfWormHole2HpSlide, GameStatusGrid.Width); + UtilFunctions.SlideLengthSet(WormHole3HpSlide, ref haveSetSlideLength, ref lengthOfWormHole3HpSlide, GameStatusGrid.Width); + haveSetSlideLength = true; + } } \ No newline at end of file diff --git a/logic/Client/MainPage.xaml b/logic/Client/MainPage.xaml index b9589a7a..e0011a64 100644 --- a/logic/Client/MainPage.xaml +++ b/logic/Client/MainPage.xaml @@ -29,6 +29,7 @@ TargetType="Label"> + diff --git a/logic/Client/MainPage.xaml.cs b/logic/Client/MainPage.xaml.cs index 4cfbdc9a..b1c5c317 100644 --- a/logic/Client/MainPage.xaml.cs +++ b/logic/Client/MainPage.xaml.cs @@ -14,7 +14,7 @@ namespace Client { public partial class MainPage : ContentPage { - + private bool UIinitiated = false; public MainPage() { Console.WriteLine("Hello World"); @@ -27,6 +27,7 @@ public MainPage() SetStatusBars(); InitiateObjects(); Map map = new Map(MainGrid, 0, 2, 2); + UIinitiated = true; } /* Set the StatusBars */ @@ -36,7 +37,6 @@ private void SetStatusBars() bluePlayer = new PlayerStatusBar(MainGrid, 1, 1, 1); gameStatusBar = new GameStatusBar(MainGrid, 0, 4); } - /* initiate the Lists of Objects and CountList */ private void InitiateObjects() { @@ -410,9 +410,18 @@ private void Refresh(object sender, EventArgs e) { lock (drawPicLock) { + if (UIinitiated) + { + redPlayer.SlideLengthSet(); + bluePlayer.SlideLengthSet(); + gameStatusBar.SlideLengthSet(); + } if (!isClientStocked) { - MapGrid.Children.Clear(); + if (MapGrid.Children.Count() > 0) + { + MapGrid.Children.Clear(); + } foreach (var data in listOfAll) { gameStatusBar.SetGameTimeValue(data); diff --git a/logic/Client/PlayerStatusBar.xaml b/logic/Client/PlayerStatusBar.xaml index 42f5246a..adddacec 100644 --- a/logic/Client/PlayerStatusBar.xaml +++ b/logic/Client/PlayerStatusBar.xaml @@ -18,7 +18,7 @@ - + @@ -29,7 +29,7 @@