public UnitImportWindowViewModel(BattleInputViewModel battleInputViewModel) { _battleInputViewModel = battleInputViewModel; ResetCommand = new RelayCommand(ResetWindow); SaveCommand = new RelayCommand(SendToBattleInput); CloseCommand = new RelayCommand(() => CloseRequested?.Invoke(this, new DialogCloseRequestedEventArgs(false))); }
public BattleSimulatorViewModel( BattleInputViewModel battleInputViewModel, UnitImportWindowViewModel unitImportWindowViewModel, IDialogService dialogService, IDataManager dataManager) { _battleInputViewModel = battleInputViewModel; _unitImportWindowViewModel = unitImportWindowViewModel; _dialogService = dialogService; _dataManager = dataManager; _settings = dataManager.Settings; ImportUnitCommand = new RelayCommand(SetImportedUnits); SetupBattleResult(); BattleConfig battleConfig = new BattleConfig { AtkUnits = new UnitSet { Archer = 0, AxeFighter = 0, Berserker = 0, Catapult = 0, HeavyCavalry = 0, LightCavalry = 0, MountedArcher = 0, Nobleman = 0, Paladin = 0, Ram = 0, Spearman = 0, Swordsman = 0, Trebuchet = 0, }, DefUnits = new UnitSet { Archer = 0, AxeFighter = 0, Berserker = 0, Catapult = 0, HeavyCavalry = 0, LightCavalry = 0, MountedArcher = 0, Nobleman = 0, Paladin = 0, Ram = 0, Spearman = 0, Swordsman = 0, Trebuchet = 0, }, BattleMeta = new BattleMeta { GrandmasterBonus = true, AtkWeaponLevel = 0, AtkWeapon = GameData.WeaponOptions[0], DefWeaponLevel = 0, DefWeapon = GameData.WeaponOptions[0], AtkChurch = GameData.FaithOptions[1], DefChurch = GameData.FaithOptions[1], Luck = 0, Morale = 100, NightBonus = false, WeaponMastery = 3, WallLevel = 0 } }; _battleInputViewModel.LoadBattleConfig(battleConfig); //Only bind to the property changed after all values have been loaded for the first time to prevent unnecessary recalculations _battleInputViewModel.PropertyChanged += (sender, args) => { RunBattleSimulator(); }; RunBattleSimulator(); }