public static string GetDescription(Component component) { switch (component.ElementName) { case "gun": return(ComponentVM.GetGunDescription((Gun)component)); case "turret": return(ComponentVM.GetTurretDescription((Turret)component)); case "engine": return(ComponentVM.GetEngineDescription((Engine)component)); case "radio": return(ComponentVM.GetRadioDescription((Radio)component)); case "chassis": return(ComponentVM.GetChassisDescription((Chassis)component)); case "shell": return(ComponentVM.GetShellDescription((Shell)component)); case "consumable": case "equipment": return(ComponentVM.GetAccessoryDescription((Accessory)component)); } return(null); }
private ComponentVM FindSimilarAmmunition(ComponentVM reference) { var isKinetic = ((Shell)reference.Model).IsKinetic; var sameCurrencyType = this.AvailableAmmunition.Where(s => ((Shell)s.Model).Currency == ((Shell)reference.Model).Currency).ToArray(); ComponentVM ammunition; if (sameCurrencyType.Length == 0) { ammunition = this.AvailableAmmunition[0]; } else if (sameCurrencyType.Length == 1) { ammunition = sameCurrencyType[0]; } else { var sameType = sameCurrencyType.Where(s => ((Shell)s.Model).IsKinetic == isKinetic).ToArray(); if (sameType.Length == 0) { ammunition = sameCurrencyType[0]; } else { ammunition = sameType.Last(); } } return(ammunition); }
public TankConfigVM() { _selectedEquipments = new ComponentVM[3]; _selectedConsumables = new ComponentVM[3]; _moduleVmLookup = new Dictionary <ComponentEntity, ComponentVM>(); TankConfiguratorSettings.Default.PropertyChanged += OnTankConfiguratorSettingChanged; }
private static double GetModuleWeight(ComponentVM module) { if (module == null) { return(0.0); } return(((Module)module.Model).Weight); }
private ComponentVM CreateShellVM(Shell shell) { var vm = new ComponentVM(shell, shell.Currency == Currency.Gold); vm.Icon = shell.GetIcon(this.Repository); _moduleVmLookup[shell] = vm; return(vm); }
private ComponentVM CreateConsumableVM(Consumable consumable) { var vm = new ComponentVM(consumable, consumable.Currency == Currency.Gold); vm.Icon = consumable.GetIcon(this.Repository); _moduleVmLookup[consumable] = vm; return(vm); }
private ComponentVM CreateEquipmentVM(Equipment equipment) { var vm = new ComponentVM(equipment, equipment.Currency == Currency.Gold); vm.Icon = equipment.GetIcon(this.Repository); _moduleVmLookup[equipment] = vm; return(vm); }
public static string GetTurretDescription(Turret turret) { if (!turret.IsPrimaryArmorDefined) { return(null); } return(Localization.Instance.L("tank_configurator", "turret_description", ComponentVM.BuildArmorString(turret))); }
private bool IsAvailableForCurrentChassis(ComponentVM module) { if (module.Model is Chassis) { return(this.HasSufficientLoad(module)); } var newWeight = this.TotalWeight - TankConfigVM.GetModuleWeight(this.GetSelectedModule(module.Model.ElementName)) + TankConfigVM.GetModuleWeight(module); return(this.MaxLoad - newWeight >= 0); }
private void SetConsumable(int index, ComponentVM Consumable) { switch (index) { case 0: this.SelectedConsumable1 = Consumable; break; case 1: this.SelectedConsumable2 = Consumable; break; case 2: this.SelectedConsumable3 = Consumable; break; } }
private void SetEquipment(int index, ComponentVM equipment) { switch (index) { case 0: this.SelectedEquipment1 = equipment; break; case 1: this.SelectedEquipment2 = equipment; break; case 2: this.SelectedEquipment3 = equipment; break; } }
private void UpdateAvailableGuns() { var maxTier = this.Configuration.Tank.Guns.Max(g => g.Tier); var eliteGun = this.Configuration.Tank.Guns.Last(g => g.Tier == maxTier); _eliteGunVM = new ComponentVM(eliteGun, true); this.AvailableGuns = this.Configuration.Tank.Guns.Select(g => g == eliteGun ? _eliteGunVM : new ComponentVM(g, false)) .ToArray(); foreach (var gun in this.AvailableGuns) { _moduleVmLookup[gun.Model] = gun; } var selectedGun = this.AvailableGuns.FirstOrDefault( g => g.Model.KeyEquals(_configuration.Gun)); this.SelectedGun = selectedGun ?? this.AvailableGuns[0]; this.UpdateModuleAvailabilities(); }
private bool HasSufficientLoad(ComponentVM chassis) { var newWeight = this.TotalWeight - TankConfigVM.GetModuleWeight(this.SelectedChassis) + TankConfigVM.GetModuleWeight(chassis); return(((Chassis)chassis.Model).MaximumLoad >= newWeight); }
private bool IsCompatible(ComponentVM turret, ComponentVM gun) { return(IsCompatible((Turret)turret.Model, (Gun)gun.Model)); }