diff --git a/.idea/.idea.BaldersGait/.idea/avalonia.xml b/.idea/.idea.BaldersGait/.idea/avalonia.xml
index ab00549..46ceceb 100644
--- a/.idea/.idea.BaldersGait/.idea/avalonia.xml
+++ b/.idea/.idea.BaldersGait/.idea/avalonia.xml
@@ -3,7 +3,17 @@
diff --git a/BaldersGait.UnitTests/Models/State/BarberShopStateTests.cs b/BaldersGait.UnitTests/Models/State/BarberShopStateTests.cs
index ddf8130..5216fb5 100644
--- a/BaldersGait.UnitTests/Models/State/BarberShopStateTests.cs
+++ b/BaldersGait.UnitTests/Models/State/BarberShopStateTests.cs
@@ -4,13 +4,6 @@ namespace BaldersGait.UnitTests.Models.State;
public class BarberShopStateTests
{
- [Fact]
- public void HairGrowth_ShouldCalculateCorrectly()
- {
- BarberShopState state = new();
- state.HairGrowth.Should().Be(0.25);
- }
-
[Fact]
public void TickMe_ShouldNotThrow()
{
diff --git a/BaldersGait/BaldersGait.csproj b/BaldersGait/BaldersGait.csproj
index 590dfc2..5022c61 100644
--- a/BaldersGait/BaldersGait.csproj
+++ b/BaldersGait/BaldersGait.csproj
@@ -7,8 +7,8 @@
app.manifest
true
- true
- true
+ true
+ true
@@ -40,8 +40,13 @@
SidebarView.axaml
Code
-
+
BluePanelView.axaml
+
+
+
+
+
diff --git a/BaldersGait/Consts/BarberShopConsts.cs b/BaldersGait/Consts/BarberShopConsts.cs
deleted file mode 100644
index 9d21820..0000000
--- a/BaldersGait/Consts/BarberShopConsts.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace BaldersGait.Consts;
-
-public static class BarberShopConsts
-{
- public const double MaxHairLength = 100;
-
- public const double BaseHairGrowthRate = 0.25;
-
- public const double BaseReduction = 0.5;
-}
\ No newline at end of file
diff --git a/BaldersGait/Models/State/BarberShop/BarberShopChair.cs b/BaldersGait/Models/State/BarberShop/BarberShopChair.cs
new file mode 100644
index 0000000..fe001ca
--- /dev/null
+++ b/BaldersGait/Models/State/BarberShop/BarberShopChair.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Text.Json.Serialization;
+
+namespace BaldersGait.Models.State.BarberShop;
+
+[Serializable]
+public class BarberShopChair
+{
+ public ChairNumbers ChairNumber { get; set; } = ChairNumbers.Unknown;
+ public bool Unlocked { get; set; } = false;
+ public double HairLength { get; set; } = 0;
+
+ [JsonIgnore]
+ public double HairGrowthScalingFactor => Math.Round(ChairNumber switch
+ {
+ ChairNumbers.One => 1,
+ _ => (double)ChairNumber / Math.Pow(2, (int)ChairNumber)
+ }, 3);
+
+ [JsonIgnore]
+ public bool ReadyToCollect => HairLength >= GetMaxHairLength();
+
+ public double GetHairGrowthWithScalingFactor(double baseHairGrowthPerTick)
+ {
+ return Math.Round(baseHairGrowthPerTick * HairGrowthScalingFactor, 3);
+ }
+
+ public bool IsProductionTooHigh(double baseHairGrowthPerTick)
+ {
+ return GetHairGrowthWithScalingFactor(baseHairGrowthPerTick) > GetMaxHairLength();
+ }
+
+ public double GetMaxHairLength()
+ {
+ // TODO: Add upgrades for this
+ return 10;
+ }
+}
\ No newline at end of file
diff --git a/BaldersGait/Models/State/BarberShop/BarberShopSeat.cs b/BaldersGait/Models/State/BarberShop/BarberShopSeat.cs
deleted file mode 100644
index 3da243b..0000000
--- a/BaldersGait/Models/State/BarberShop/BarberShopSeat.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-
-namespace BaldersGait.Models.State.BarberShop;
-
-[Serializable]
-public class BarberShopSeat
-{
- public SeatNumber SeatNumber { get; set; } = SeatNumber.Unknown;
- public bool Unlocked { get; set; } = false;
-
- public double HairLength { get; set; } = 0;
-}
\ No newline at end of file
diff --git a/BaldersGait/Models/State/BarberShop/SeatNumber.cs b/BaldersGait/Models/State/BarberShop/ChairNumbers.cs
similarity index 76%
rename from BaldersGait/Models/State/BarberShop/SeatNumber.cs
rename to BaldersGait/Models/State/BarberShop/ChairNumbers.cs
index aece74e..4640802 100644
--- a/BaldersGait/Models/State/BarberShop/SeatNumber.cs
+++ b/BaldersGait/Models/State/BarberShop/ChairNumbers.cs
@@ -1,6 +1,9 @@
+using System;
+
namespace BaldersGait.Models.State.BarberShop;
-public enum SeatNumber
+[Serializable]
+public enum ChairNumbers
{
Unknown = -1,
One = 1,
diff --git a/BaldersGait/Models/State/BarberShopState.cs b/BaldersGait/Models/State/BarberShopState.cs
index 3e06cb1..5bffc0a 100644
--- a/BaldersGait/Models/State/BarberShopState.cs
+++ b/BaldersGait/Models/State/BarberShopState.cs
@@ -3,7 +3,6 @@
using System.Linq;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
-using BaldersGait.Consts;
using BaldersGait.Models.State.BarberShop;
namespace BaldersGait.Models.State;
@@ -11,78 +10,94 @@ namespace BaldersGait.Models.State;
[Serializable]
public class BarberShopState
{
- public List Seats { get; set; } =
+ public List Chairs { get; set; } =
[
new()
{
- SeatNumber = SeatNumber.One,
+ ChairNumber = ChairNumbers.One,
Unlocked = true
},
new()
{
- SeatNumber = SeatNumber.Two,
+ ChairNumber = ChairNumbers.Two,
},
new()
{
- SeatNumber = SeatNumber.Three,
+ ChairNumber = ChairNumbers.Three,
},
new()
{
- SeatNumber = SeatNumber.Four,
+ ChairNumber = ChairNumbers.Four,
},
new()
{
- SeatNumber = SeatNumber.Five,
+ ChairNumber = ChairNumbers.Five,
},
new()
{
- SeatNumber = SeatNumber.Six,
+ ChairNumber = ChairNumbers.Six,
},
new()
{
- SeatNumber = SeatNumber.Seven,
+ ChairNumber = ChairNumbers.Seven,
},
new()
{
- SeatNumber = SeatNumber.Eight,
+ ChairNumber = ChairNumbers.Eight,
}
];
public int HairGrowthUpgrades { get; set; } = 0;
- public int ReduceReductionUpgrades { get; set; } = 0;
+ public int ChairScalingFactorUpgrades { get; set; } = 0;
public double HairCollected { get; set; } = 0;
public bool ClippersPurchased { get; set; } = false;
- [JsonIgnore]
- public double HairGrowth => Math.Round(BarberShopConsts.BaseHairGrowthRate * (HairGrowthUpgrades+1), 3);
+
+ [JsonIgnore]
+ public double BaseHairPerTick => Math.Round(0.01 * (HairGrowthUpgrades + 1), 3);
public void TickMe()
{
- Parallel.ForEach(Seats.Where(x => x.Unlocked), seat =>
+ Parallel.ForEach(Chairs.Where(x => x.Unlocked), seat =>
{
- if (seat.HairLength < BarberShopConsts.MaxHairLength)
+ // TODO: Passing in 'this' works but just feels awful
+ double hairGrowth = seat.GetHairGrowthWithScalingFactor(BaseHairPerTick);
+ double maxHairLength = seat.GetMaxHairLength();
+
+ // If we are making more per tick than we can hold
+ if (hairGrowth > maxHairLength)
{
- double growthRate = HairGrowth * (seat.SeatNumber == SeatNumber.One ? 1 : Math.Pow(BarberShopConsts.BaseReduction, (int)seat.SeatNumber));
- double newLength = Math.Round(seat.HairLength + growthRate, 3);
- if (newLength >= BarberShopConsts.MaxHairLength)
+ seat.HairLength = maxHairLength;
+
+ if (ClippersPurchased)
{
- if (ClippersPurchased)
- {
- HairCollected = Math.Round(HairCollected + BarberShopConsts.MaxHairLength, 3);
- newLength = 0;
- }
- else
- {
- newLength = BarberShopConsts.MaxHairLength;
- }
+ HairCollected = Math.Round(HairCollected + seat.HairLength, 3);
}
+
+ return;
+ }
- seat.HairLength = newLength;
+ // If we are full
+ if (seat.HairLength >= maxHairLength)
+ {
+ if (ClippersPurchased)
+ {
+ HairCollected = Math.Round(HairCollected + maxHairLength, 3);
+ seat.HairLength = 0;
+ }
+ else
+ {
+ seat.HairLength = maxHairLength;
+ }
+ return;
}
+
+ // Else we can add it to the seats hair length
+ seat.HairLength = Math.Round(seat.HairLength + hairGrowth, 3);
});
}
}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/MainWindowViewModel.cs b/BaldersGait/ViewModels/MainWindowViewModel.cs
index 34f1b97..cc09fb4 100644
--- a/BaldersGait/ViewModels/MainWindowViewModel.cs
+++ b/BaldersGait/ViewModels/MainWindowViewModel.cs
@@ -32,18 +32,6 @@ public PanelBase CurrentPanel
return;
}
- Parallel.ForEach(_sidebar.Buttons, sidebarButton =>
- {
- if (sidebarButton.ButtonText != value.PanelName)
- {
- sidebarButton.ResetBackground();
- }
- else
- {
- sidebarButton.SetBackgroundSelected();
- }
- });
-
this.RaiseAndSetIfChanged(ref _currentPanel, value);
}
}
@@ -62,8 +50,12 @@ public MainWindowViewModel(SidebarViewModel sidebar, IStateService stateService)
SidebarButtonViewModel button = _sidebar.Buttons.First();
_currentPanel = button.PanelToOpen;
Log.Information($"Starting panel: {_currentPanel.PanelName}");
- button.SetBackgroundSelected();
- RxApp.TaskpoolScheduler.SchedulePeriodic(TimeSpan.FromMilliseconds(100), stateService.TickState);
+ RxApp.TaskpoolScheduler.SchedulePeriodic(TimeSpan.FromMilliseconds(10), stateService.TickState);
+ }
+
+ protected override void RefreshUIFromState()
+ {
+ // Nothing to do
}
}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopBottomViewModel.cs b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopBottomViewModel.cs
index 3b4027d..087b8e9 100644
--- a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopBottomViewModel.cs
+++ b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopBottomViewModel.cs
@@ -1,29 +1,21 @@
-using Avalonia.Media;
using BaldersGait.Models.State.BarberShop;
using BaldersGait.Services.Interface;
namespace BaldersGait.ViewModels.Panels.BarberShop;
-public class BarberShopBottomViewModel : ViewModelBase
+public class BarberShopBottomViewModel(IStateService stateService) : ViewModelBase
{
- public BarberShopChairViewModel SeatOne { get; init; }
- public BarberShopChairViewModel SeatTwo { get; init; }
- public BarberShopChairViewModel SeatThree { get; init; }
- public BarberShopChairViewModel SeatFour { get; init; }
- public BarberShopChairViewModel SeatFive { get; init; }
- public BarberShopChairViewModel SeatSix { get; init; }
- public BarberShopChairViewModel SeatSeven { get; init; }
- public BarberShopChairViewModel SeatEight { get; init; }
-
- public BarberShopBottomViewModel(IStateService stateService)
+ public BarberShopChairViewModel SeatOne { get; init; } = new(stateService, ChairNumbers.One);
+ public BarberShopChairViewModel SeatTwo { get; init; } = new(stateService, ChairNumbers.Two);
+ public BarberShopChairViewModel SeatThree { get; init; } = new(stateService, ChairNumbers.Three);
+ public BarberShopChairViewModel SeatFour { get; init; } = new(stateService, ChairNumbers.Four);
+ public BarberShopChairViewModel SeatFive { get; init; } = new(stateService, ChairNumbers.Five);
+ public BarberShopChairViewModel SeatSix { get; init; } = new(stateService, ChairNumbers.Six);
+ public BarberShopChairViewModel SeatSeven { get; init; } = new(stateService, ChairNumbers.Seven);
+ public BarberShopChairViewModel SeatEight { get; init; } = new(stateService, ChairNumbers.Eight);
+
+ protected override void RefreshUIFromState()
{
- SeatOne = new(stateService, SeatNumber.One);
- SeatTwo = new(stateService, SeatNumber.Two);
- SeatThree = new(stateService, SeatNumber.Three);
- SeatFour = new(stateService, SeatNumber.Four);
- SeatFive = new(stateService, SeatNumber.Five);
- SeatSix = new(stateService, SeatNumber.Six);
- SeatSeven = new(stateService, SeatNumber.Seven);
- SeatEight = new(stateService, SeatNumber.Eight);
+ // Nothing to do
}
}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopChairViewModel.cs b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopChairViewModel.cs
index 44deb6b..c8a215e 100644
--- a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopChairViewModel.cs
+++ b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopChairViewModel.cs
@@ -1,43 +1,57 @@
using System;
using System.Linq;
-using System.Reactive.Concurrency;
using BaldersGait.Models.State.BarberShop;
using BaldersGait.Services.Interface;
using ReactiveUI;
namespace BaldersGait.ViewModels.Panels.BarberShop;
-public class BarberShopChairViewModel : ViewModelBase
+public class BarberShopChairViewModel(IStateService stateService, ChairNumbers chairNumber) : ViewModelBase
{
- public SeatNumber SeatNumber { get; }
+ public ChairNumbers ChairNumber { get; } = chairNumber;
- public string HairLengthLabel =>
- $"{_stateService.GetBarberShopState().Seats.First(s => s.SeatNumber == SeatNumber).HairLength:F3}\"";
+ private BarberShopChair ChairState =>
+ stateService.GetBarberShopState().Chairs.First(s => s.ChairNumber == ChairNumber);
- public bool IsChairUnlocked =>
- _stateService.GetBarberShopState().Seats.First(s => s.SeatNumber == SeatNumber).Unlocked;
-
- private readonly IStateService _stateService;
+ public string ChairNumberLabel => $"Chair {ChairNumber}";
+ public double HairLength => ChairState.HairLength;
+ public double MaxHair => ChairState.GetMaxHairLength();
- public BarberShopChairViewModel(IStateService stateService, SeatNumber seatNumber)
- {
- SeatNumber = seatNumber;
- _stateService = stateService;
-
- RxApp.MainThreadScheduler.SchedulePeriodic(TimeSpan.FromMilliseconds(100), RefreshUIFromState);
- }
+ public string HairGrowthLabel => $"Hair Growth:\n{stateService.GetBarberShopState().BaseHairPerTick * 60:F2}\" / second";
+ public string ScalingFactorLabel => $"Scaling factor:\nx{ChairState.HairGrowthScalingFactor}";
+
+ public string TotalGrowthLabel => $"Total Growth:\n{ChairState.GetHairGrowthWithScalingFactor(stateService.GetBarberShopState().BaseHairPerTick) * 60:F2}\" / second";
+
+ public string CurrentHairLabel => $"Current hair:\n{HairLength:F2}\" / {MaxHair:F2}\"";
+
+ public bool IsChairUnlocked => ChairState.Unlocked;
+
+ public bool ReadyToCollect => ChairState.ReadyToCollect && !ProductionTooHigh;
+
+ public bool ProductionTooHigh => ChairState.IsProductionTooHigh(stateService.GetBarberShopState().BaseHairPerTick);
+
public bool CutHair()
{
- _stateService.GetBarberShopState().HairCollected = Math.Round(_stateService.GetBarberShopState().HairCollected + _stateService.GetBarberShopState().Seats.First(s => s.SeatNumber == SeatNumber).HairLength, 3);
- _stateService.GetBarberShopState().Seats.First(s => s.SeatNumber == SeatNumber).HairLength = 0;
+ stateService.GetBarberShopState().HairCollected = Math.Round(stateService.GetBarberShopState().HairCollected + ChairState.HairLength, 3);
+ ChairState.HairLength = 0;
return true;
}
- private void RefreshUIFromState()
+ protected override void RefreshUIFromState()
{
- this.RaisePropertyChanged(nameof(HairLengthLabel));
this.RaisePropertyChanged(nameof(IsChairUnlocked));
+
+ this.RaisePropertyChanged(nameof(HairLength));
+ this.RaisePropertyChanged(nameof(MaxHair));
+
+ this.RaisePropertyChanged(nameof(HairGrowthLabel));
+ this.RaisePropertyChanged(nameof(ScalingFactorLabel));
+ this.RaisePropertyChanged(nameof(TotalGrowthLabel));
+ this.RaisePropertyChanged(nameof(CurrentHairLabel));
+
+ this.RaisePropertyChanged(nameof(ReadyToCollect));
+ this.RaisePropertyChanged(nameof(ProductionTooHigh));
}
}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopTopViewModel.cs b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopTopViewModel.cs
index 7bd9c23..4ebcd4b 100644
--- a/BaldersGait/ViewModels/Panels/BarberShop/BarberShopTopViewModel.cs
+++ b/BaldersGait/ViewModels/Panels/BarberShop/BarberShopTopViewModel.cs
@@ -1,27 +1,24 @@
using System;
using System.Linq;
-using System.Reactive.Concurrency;
+using BaldersGait.Models.State.BarberShop;
using BaldersGait.Services.Interface;
using ReactiveUI;
namespace BaldersGait.ViewModels.Panels.BarberShop;
-public class BarberShopTopViewModel : ViewModelBase
+public class BarberShopTopViewModel(IStateService stateService) : ViewModelBase
{
- public string HairCollectedLabel => $"{_stateService.GetBarberShopState().HairCollected:F3}";
- public string PurchaseClippersButtonLabel => _stateService.GetBarberShopState().ClippersPurchased ? "Clippers (purchased)" : "Purchase Clippers (500 Hair)" ;
- public string IncreaseGrowthButtonLabel => $"({_stateService.GetBarberShopState().HairGrowthUpgrades}) Increase Growth (100 Hair)";
- public string UnlockSeatButtonLabel => _stateService.GetBarberShopState().Seats.Count(s => s.Unlocked) == 8 ? "All seats unlocked" : $"Unlock seat {_stateService.GetBarberShopState().Seats.Count(s => s.Unlocked)+1} (1000 hair)";
+ public string PurchaseClippersButtonLabel => stateService.GetBarberShopState().ClippersPurchased ? "Clippers (purchased)" : "Purchase Clippers (500 Hair)" ;
- private readonly IStateService _stateService;
+ public string IncreaseScalingFactorButtonLabel => $"[{stateService.GetBarberShopState().ChairScalingFactorUpgrades}] Increase Scaling Factor ({IncreaseScalingFactorCost} Hair)";
+ public string UnlockSeatButtonLabel => ChairsUnlocked == 8 ? "All Chairs Unlocked" : $"Unlock Chair {(ChairNumbers) ChairsUnlocked} ({UnlockChairCost} hair)";
+ public string IncreaseGrowthButtonLabel => $"[{stateService.GetBarberShopState().HairGrowthUpgrades}] Increase Growth ({IncreaseGrowthCost} Hair)";
- public BarberShopTopViewModel(IStateService stateService)
- {
- _stateService = stateService;
-
- RxApp.MainThreadScheduler.SchedulePeriodic(TimeSpan.FromMilliseconds(100), RefreshUIFromState);
- }
+ private int ChairsUnlocked => stateService.GetBarberShopState().Chairs.Count(s => s.Unlocked) + 1;
+ private int IncreaseScalingFactorCost => 500 * (stateService.GetBarberShopState().ChairScalingFactorUpgrades + 1);
+ private int UnlockChairCost => 200 * (ChairsUnlocked - 1);
+ private int IncreaseGrowthCost => 100 * (stateService.GetBarberShopState().HairGrowthUpgrades + 1);
#region Click Events
public bool PurchaseClippers_Click()
@@ -31,35 +28,37 @@ public bool PurchaseClippers_Click()
// return false;
//}
- _stateService.GetBarberShopState().ClippersPurchased = true;
+ stateService.GetBarberShopState().ClippersPurchased = true;
return false;
}
- public bool ReduceReduction_Click()
+ public bool IncreaseScalingFactor_Click()
{
- if (_stateService.GetBarberShopState().HairCollected < 2000)
+ if (stateService.GetBarberShopState().HairCollected < IncreaseScalingFactorCost)
{
return false;
}
-
-
- return false;
+
+ stateService.GetBarberShopState().HairCollected = Math.Round(stateService.GetBarberShopState().HairCollected - IncreaseScalingFactorCost, 3);
+ stateService.GetBarberShopState().ChairScalingFactorUpgrades++;
+
+ return true;
}
public bool UnlockChair_Click()
{
- if (_stateService.GetBarberShopState().HairCollected < 1000)
+ if (stateService.GetBarberShopState().HairCollected < UnlockChairCost)
{
return false;
}
- for (int i = _stateService.GetBarberShopState().Seats.Count(seat => seat.Unlocked); i < _stateService.GetBarberShopState().Seats.Count; i++)
+ for (int i = stateService.GetBarberShopState().Chairs.Count(seat => seat.Unlocked); i < stateService.GetBarberShopState().Chairs.Count; i++)
{
- if (!_stateService.GetBarberShopState().Seats[i].Unlocked)
+ if (!stateService.GetBarberShopState().Chairs[i].Unlocked)
{
- _stateService.GetBarberShopState().HairCollected = Math.Round(_stateService.GetBarberShopState().HairCollected - 1000, 3);
- _stateService.GetBarberShopState().Seats[i].Unlocked = true;
+ stateService.GetBarberShopState().HairCollected = Math.Round(stateService.GetBarberShopState().HairCollected - UnlockChairCost, 3);
+ stateService.GetBarberShopState().Chairs[i].Unlocked = true;
return true;
}
}
@@ -69,26 +68,23 @@ public bool UnlockChair_Click()
public bool IncreaseGrowth_Click()
{
- if (_stateService.GetBarberShopState().HairCollected < 100)
+ if (stateService.GetBarberShopState().HairCollected < IncreaseGrowthCost)
{
return false;
}
- _stateService.GetBarberShopState().HairCollected = Math.Round(_stateService.GetBarberShopState().HairCollected - 100, 3);
- _stateService.GetBarberShopState().HairGrowthUpgrades++;
- this.RaisePropertyChanged(nameof(IncreaseGrowthButtonLabel));
+ stateService.GetBarberShopState().HairCollected = Math.Round(stateService.GetBarberShopState().HairCollected - IncreaseGrowthCost, 3);
+ stateService.GetBarberShopState().HairGrowthUpgrades++;
return true;
}
#endregion
- private void RefreshUIFromState()
+ protected override void RefreshUIFromState()
{
- this.RaisePropertyChanged(nameof(HairCollectedLabel));
-
this.RaisePropertyChanged(nameof(PurchaseClippersButtonLabel));
- //this.RaisePropertyChanged(nameof(ReduceReductionButtonLabel));
+ this.RaisePropertyChanged(nameof(IncreaseScalingFactorButtonLabel));
this.RaisePropertyChanged(nameof(UnlockSeatButtonLabel));
this.RaisePropertyChanged(nameof(IncreaseGrowthButtonLabel));
}
diff --git a/BaldersGait/ViewModels/Panels/BarberShopPanelViewModel.cs b/BaldersGait/ViewModels/Panels/BarberShopPanelViewModel.cs
index 2699d74..0ea93a2 100644
--- a/BaldersGait/ViewModels/Panels/BarberShopPanelViewModel.cs
+++ b/BaldersGait/ViewModels/Panels/BarberShopPanelViewModel.cs
@@ -1,28 +1,21 @@
-using System;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Reactive.Concurrency;
using Avalonia.Media;
-using BaldersGait.Consts;
-using BaldersGait.Models.State.BarberShop;
using BaldersGait.Services.Interface;
using BaldersGait.ViewModels.Panels.BarberShop;
-using ReactiveUI;
namespace BaldersGait.ViewModels.Panels;
-public class BarberShopPanelViewModel : PanelBase
+public class BarberShopPanelViewModel(BarberShopTopViewModel topView, BarberShopBottomViewModel bottomView)
+ : PanelBase
{
public override string PanelName => "Barber Shop";
public override IBrush PanelButtonBackgroundColor { get; } = Brushes.SteelBlue;
- public BarberShopTopViewModel TopView { get; init; }
-
- public BarberShopBottomViewModel BottomView { get; init; }
-
- public BarberShopPanelViewModel(IStateService stateService, BarberShopTopViewModel topView, BarberShopBottomViewModel bottomView)
+ public BarberShopTopViewModel TopView { get; init; } = topView;
+
+ public BarberShopBottomViewModel BottomView { get; init; } = bottomView;
+
+ protected override void RefreshUIFromState()
{
- TopView = topView;
- BottomView = bottomView;
+ // Nothing to do
}
}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Panels/BluePanelViewModel.cs b/BaldersGait/ViewModels/Panels/BluePanelViewModel.cs
deleted file mode 100644
index dd3bd89..0000000
--- a/BaldersGait/ViewModels/Panels/BluePanelViewModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Avalonia.Media;
-
-namespace BaldersGait.ViewModels.Panels;
-
-public class BluePanelViewModel : PanelBase
-{
- public override string PanelName => "Blue";
- public override IBrush PanelButtonBackgroundColor { get; } = Brushes.DodgerBlue;
-}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Panels/GameStatePanelViewModel.cs b/BaldersGait/ViewModels/Panels/GameStatePanelViewModel.cs
index 345e6b8..a3bee3f 100644
--- a/BaldersGait/ViewModels/Panels/GameStatePanelViewModel.cs
+++ b/BaldersGait/ViewModels/Panels/GameStatePanelViewModel.cs
@@ -28,4 +28,9 @@ public bool ResetState_Click()
return true;
}
#endregion
+
+ protected override void RefreshUIFromState()
+ {
+ // Nothing to do
+ }
}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Panels/GreenPanelViewModel.cs b/BaldersGait/ViewModels/Panels/GreenPanelViewModel.cs
deleted file mode 100644
index 617bf2c..0000000
--- a/BaldersGait/ViewModels/Panels/GreenPanelViewModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Avalonia.Media;
-
-namespace BaldersGait.ViewModels.Panels;
-
-public class GreenPanelViewModel : PanelBase
-{
- public override string PanelName => "Green";
- public override IBrush PanelButtonBackgroundColor { get; } = Brushes.ForestGreen;
-}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Panels/KnownIssuesPanelViewModel.cs b/BaldersGait/ViewModels/Panels/KnownIssuesPanelViewModel.cs
new file mode 100644
index 0000000..af3c587
--- /dev/null
+++ b/BaldersGait/ViewModels/Panels/KnownIssuesPanelViewModel.cs
@@ -0,0 +1,14 @@
+using Avalonia.Media;
+
+namespace BaldersGait.ViewModels.Panels;
+
+public class KnownIssuesPanelViewModel : PanelBase
+{
+ public override string PanelName => "Known Issues";
+ public override IBrush PanelButtonBackgroundColor { get; } = Brushes.SlateGray;
+
+ protected override void RefreshUIFromState()
+ {
+ // Nothing to do
+ }
+}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Panels/PlannedChangesPanelViewModel.cs b/BaldersGait/ViewModels/Panels/PlannedChangesPanelViewModel.cs
new file mode 100644
index 0000000..c7aef7d
--- /dev/null
+++ b/BaldersGait/ViewModels/Panels/PlannedChangesPanelViewModel.cs
@@ -0,0 +1,14 @@
+using Avalonia.Media;
+
+namespace BaldersGait.ViewModels.Panels;
+
+public class PlannedChangesPanelViewModel : PanelBase
+{
+ public override string PanelName => "Planned Changes";
+ public override IBrush PanelButtonBackgroundColor { get; } = Brushes.SlateGray;
+
+ protected override void RefreshUIFromState()
+ {
+ // Nothing to do
+ }
+}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Sidebar/SidebarButtonViewModel.cs b/BaldersGait/ViewModels/Sidebar/SidebarButtonViewModel.cs
index 51b39ca..9e70fd8 100644
--- a/BaldersGait/ViewModels/Sidebar/SidebarButtonViewModel.cs
+++ b/BaldersGait/ViewModels/Sidebar/SidebarButtonViewModel.cs
@@ -9,28 +9,10 @@ public class SidebarButtonViewModel(PanelBase panelToOpen) : ViewModelBase
{
public string ButtonText { get; } = panelToOpen.PanelName;
- private IBrush _backgroundColor = panelToOpen.PanelButtonBackgroundColor ?? Brushes.SlateGray;
-
- public IBrush BackgroundColor
- {
- get => _backgroundColor;
- set => this.RaiseAndSetIfChanged(ref _backgroundColor, value);
- }
+ public IBrush BackgroundColor { get; private set; } = panelToOpen.PanelButtonBackgroundColor ?? Brushes.SlateGray;
public PanelBase PanelToOpen { get; } = panelToOpen;
- private IBrush OriginalBackgroundColor { get; } = panelToOpen.PanelButtonBackgroundColor ?? Brushes.SlateGray;
-
- public void SetBackgroundSelected()
- {
- BackgroundColor = Brushes.LightSlateGray;
- }
-
- public void ResetBackground()
- {
- BackgroundColor = OriginalBackgroundColor;
- }
-
public bool OnClick()
{
if (MainWindowViewModel.Current == null)
@@ -42,4 +24,9 @@ public bool OnClick()
Log.Information($"Opened panel: {PanelToOpen.PanelName}");
return true;
}
+
+ protected override void RefreshUIFromState()
+ {
+ this.RaisePropertyChanged(nameof(BackgroundColor));
+ }
}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/Sidebar/SidebarViewModel.cs b/BaldersGait/ViewModels/Sidebar/SidebarViewModel.cs
index c6a3c2f..30b442b 100644
--- a/BaldersGait/ViewModels/Sidebar/SidebarViewModel.cs
+++ b/BaldersGait/ViewModels/Sidebar/SidebarViewModel.cs
@@ -1,16 +1,28 @@
-using System.Collections.ObjectModel;
+using System.Collections.Generic;
+using BaldersGait.Services.Interface;
using BaldersGait.ViewModels.Panels;
+using ReactiveUI;
namespace BaldersGait.ViewModels.Sidebar;
-public class SidebarViewModel(BarberShopPanelViewModel barberShopPanel, GameStatePanelViewModel gameStatePanel, GreenPanelViewModel greenPanel, BluePanelViewModel bluePanel)
+public class SidebarViewModel(BarberShopPanelViewModel barberShopPanel, GameStatePanelViewModel gameStatePanel,
+ PlannedChangesPanelViewModel plannedChangesPanel, KnownIssuesPanelViewModel knownIssuesPanel,
+ IStateService stateService)
: ViewModelBase
{
- public ObservableCollection Buttons { get; } =
+ public string HairCollectedLabel => $"Hair collected:\n{stateService.GetBarberShopState().HairCollected:F2}";
+
+ public List Buttons { get; } =
[
new(barberShopPanel),
new(gameStatePanel),
- new(greenPanel),
- new(bluePanel)
+ new(plannedChangesPanel),
+ new(knownIssuesPanel)
];
+
+ protected override void RefreshUIFromState()
+ {
+ this.RaisePropertyChanged(nameof(HairCollectedLabel));
+ this.RaisePropertyChanged(nameof(Buttons));
+ }
}
\ No newline at end of file
diff --git a/BaldersGait/ViewModels/ViewModelBase.cs b/BaldersGait/ViewModels/ViewModelBase.cs
index 3c0d15e..afded02 100644
--- a/BaldersGait/ViewModels/ViewModelBase.cs
+++ b/BaldersGait/ViewModels/ViewModelBase.cs
@@ -1,8 +1,18 @@
-using ReactiveUI;
+using System;
+using System.Reactive.Concurrency;
+using ReactiveUI;
namespace BaldersGait.ViewModels;
-public class ViewModelBase : ReactiveObject
+public abstract class ViewModelBase : ReactiveObject
{
+ // Roughly 60 frames per second
+ private readonly TimeSpan _uiRefreshTimeSpan = TimeSpan.FromMilliseconds(16.66);
+ protected ViewModelBase()
+ {
+ RxApp.MainThreadScheduler.SchedulePeriodic(_uiRefreshTimeSpan, RefreshUIFromState);
+ }
+
+ protected abstract void RefreshUIFromState();
}
\ No newline at end of file
diff --git a/BaldersGait/Views/MainWindow.axaml b/BaldersGait/Views/MainWindow.axaml
index c87501a..4de6685 100644
--- a/BaldersGait/Views/MainWindow.axaml
+++ b/BaldersGait/Views/MainWindow.axaml
@@ -29,7 +29,7 @@
-
+
diff --git a/BaldersGait/Views/MainWindow.axaml.cs b/BaldersGait/Views/MainWindow.axaml.cs
index 5520652..8e4d263 100644
--- a/BaldersGait/Views/MainWindow.axaml.cs
+++ b/BaldersGait/Views/MainWindow.axaml.cs
@@ -4,8 +4,21 @@ namespace BaldersGait.Views;
public partial class MainWindow : Window
{
+ private const int SetHeight = 750;
+ private const int SetWidth = 1400;
+
public MainWindow()
{
+ Width = SetHeight;
+ Height = SetWidth;
+ CanResize = false;
+ Resized += WindowBase_OnResized;
InitializeComponent();
}
+
+ private void WindowBase_OnResized(object? sender, WindowResizedEventArgs e)
+ {
+ Height = SetHeight;
+ Width = SetWidth;
+ }
}
\ No newline at end of file
diff --git a/BaldersGait/Views/Panels/BarberShop/BarberShopBottomView.axaml b/BaldersGait/Views/Panels/BarberShop/BarberShopBottomView.axaml
index 1ec2c8c..330b045 100644
--- a/BaldersGait/Views/Panels/BarberShop/BarberShopBottomView.axaml
+++ b/BaldersGait/Views/Panels/BarberShop/BarberShopBottomView.axaml
@@ -11,15 +11,13 @@
-
-
diff --git a/BaldersGait/Views/Panels/BarberShop/BarberShopChairView.axaml b/BaldersGait/Views/Panels/BarberShop/BarberShopChairView.axaml
index c4272d8..8e1651a 100644
--- a/BaldersGait/Views/Panels/BarberShop/BarberShopChairView.axaml
+++ b/BaldersGait/Views/Panels/BarberShop/BarberShopChairView.axaml
@@ -11,28 +11,54 @@
-
+
+
+
-
- LOCKED
+ LOCKED
diff --git a/BaldersGait/Views/Panels/BarberShop/BarberShopTopView.axaml b/BaldersGait/Views/Panels/BarberShop/BarberShopTopView.axaml
index 890b18e..3115b04 100644
--- a/BaldersGait/Views/Panels/BarberShop/BarberShopTopView.axaml
+++ b/BaldersGait/Views/Panels/BarberShop/BarberShopTopView.axaml
@@ -11,7 +11,7 @@
-
-
- Hair Collected:
-
+
+
-