public AddTrailerViewModel(AddVehicleViewModel vehicle, Trailer defaultTrailer = null, Cargo defaultCargo = null) { this.Vehicle = vehicle; this.Trailers = Constants.AllTrailers; this.Cargos = Constants.AllCargo; this.Title = "Trailer"; if (vehicle.SelectedVehicleType.vtype == "War Rig") { this.Trailers.Add(new Trailer { ttype = "War Rig", cost = 0, slots = 0 }); this.SelectedTrailer = this.Trailers.Last(); } else { this.SelectedTrailer = this.Trailers.FirstOrDefault(x => x.ttype == defaultTrailer?.ttype) ?? Trailers[0]; } // default to none this.SelectedCargo = this.Cargos.FirstOrDefault(x => x.ctype == defaultCargo?.ctype) ?? Cargos[0]; this.CanSelectTrailer = this.SelectedTrailer?.ttype != "War Rig"; this.Id = Guid.NewGuid(); }
public AddWeaponViewModel(AddVehicleViewModel vehicle, UserWeapon userWeapon) : this(vehicle, userWeapon?.Weapon) { this.Id = userWeapon?.Id ?? Guid.NewGuid(); this.Facing = userWeapon?.Facing; this.Location = userWeapon?.Location; }
public SelectVehicleViewModel(AddVehicleViewModel parent, VehicleType vehicle = null) { this.Vehicle = parent; this.Title = "Vehicle Type"; this.VehicleTypes = Constants.AllVehicletypes.Where(v => { if (parent.Team.SponsorMode == false) { return(true); } else if (parent.Team.SelectedSponsor.name == "Rutherford") { return(v.weight != "Light"); } else if (parent.Team.SelectedSponsor.name != "Rutherford" && new string[] { "Tank", "Helicopter" }.Contains(v.vtype)) { return(false); } else if (parent.Team.SelectedSponsor.name == "Miyazaki") { return(v.handling > 2); } else if (parent.Team.SelectedSponsor.name == "Idris") { return !new string[] { "Gryrocopter" } } .Contains(v.vtype);
async void ExecuteAddVehicleAsync(object obj) { var nav = DependencyService.Get <INavigationService>(); var vm = new AddVehicleViewModel(this); await nav.Navigate(vm); }
public AddWeaponViewModel(AddVehicleViewModel vehicle, Weapon defaultWeapon = null) { this.Vehicle = vehicle; vehicle.PropertyChanged += Vehicle_PropertyChanged; CanSelect = defaultWeapon != null && defaultWeapon.always ? false : true; this.RefreshOptions(defaultWeapon); this.Id = Guid.NewGuid(); }
public AddUpgradeViewModel(AddVehicleViewModel vehicle, Upgrade defaultUpgrade = null) { this.Vehicle = vehicle; if (this.Vehicle.SelectedVehicleType.vtype == "Buggy" && defaultUpgrade?.utype == "Roll Cage") { CanSelect = false; } else { CanSelect = true; } this.Upgrades = Constants.AllUpgrades.Where(u => { if (!vehicle.Team.SponsorMode) { return(true); } bool allowed = u.allowedSponsors == null || u.allowedSponsors.Length == 0 || u.allowedSponsors.Contains(this.Vehicle.Team.SelectedSponsor.name); if (allowed) { allowed = u.allowedVehicles == null || u.allowedVehicles.Length == 0 || u.allowedVehicles.Contains(this.Vehicle.SelectedVehicleType.vtype); } // allow up to double of the original crew amount if (u.utype == "Extra Crewmember") { var crew = vehicle.SelectedVehicleType?.crew ?? 0; var extraCrewCount = vehicle.Upgrades.Where(x => x.SelectedUpgrade?.utype == "Extra Crewmember").Count(); if (extraCrewCount < crew) { return(true); } } return(allowed); }).ToList(); this.SelectedUpgrade = this.Upgrades.FirstOrDefault(x => x.utype == defaultUpgrade?.utype) ?? this.Upgrades.FirstOrDefault(); this.Id = Guid.NewGuid(); }
public AddTeamViewModel(UserTeam userTeamToRestore) : this() { this.Id = userTeamToRestore.Id; this.TeamName = userTeamToRestore.TeamName; this.TotalCans = userTeamToRestore.Cans; this.Sponsor = new SelectSponsorViewModel(this, userTeamToRestore.Sponsor); foreach (var v in userTeamToRestore.Vehicles) { var vm = new AddVehicleViewModel(this, v); this.Vehicles.Add(vm); } }
void OnVehicleSaved(AddVehicleViewModel obj) { var match = this.Vehicles.FirstOrDefault(x => x.Id == obj.Id); if (match != null) { var idx = this.Vehicles.IndexOf(match); this.Vehicles.RemoveAt(idx); this.Vehicles.Insert(idx, obj); } else if (obj.Team == this) { this.Vehicles.Add(obj); } this.RaiseAllPropertiesChanged(); }
public AddPerkViewModel(AddVehicleViewModel vehicle, Perk defaultPerk = null) { this.Vehicle = vehicle; this.Perks = Constants.AllPerks.Where(p => { if (vehicle.Team.SelectedSponsor == null) { return(false); } return(vehicle.Team.SelectedSponsor.perkClasses.Contains(p.@class)); }).ToList(); this.SelectedPerk = this.Perks.FirstOrDefault(x => x.ptype == defaultPerk?.ptype) ?? this.Perks.FirstOrDefault(); this.Id = Guid.NewGuid(); }
public AddUpgradeViewModel(AddVehicleViewModel vehicle, UserUpgrade defaultUpgrade) : this(vehicle, defaultUpgrade?.Upgrade) { this.Id = defaultUpgrade?.Id ?? Guid.NewGuid(); }
public AddTrailerViewModel(AddVehicleViewModel vehicle, UserTrailer defaultTrailer) : this(vehicle, defaultTrailer?.Trailer, defaultTrailer?.Cargo) { this.Id = defaultTrailer?.Id ?? Guid.NewGuid(); }
void OnSponsorSaved(AddVehicleViewModel obj) { this.RaiseAllPropertiesChanged(); (this.AddVehicle as Command).ChangeCanExecute(); }
public AddPerkViewModel(AddVehicleViewModel vehicle, UserPerk defaultPerk) : this(vehicle, defaultPerk?.Perk) { this.Id = defaultPerk?.Id ?? Guid.NewGuid(); }