Exemple #1
0
        public SelectSponsorViewModel(AddTeamViewModel team, Sponsor sponsor = null)
        {
            this.Team = team;

            this.Title    = "Sponsor";
            this.Sponsors = Constants.AllSponsors;

            this.SelectedSponsor = Sponsors.FirstOrDefault(x => x.name == sponsor?.name) ?? this.Sponsors.First(x => x.name == "None");
        }
        public AddVehicleViewModel(AddTeamViewModel team)
        {
            this.Weapons  = new ObservableCollection <AddWeaponViewModel>();
            this.Upgrades = new ObservableCollection <AddUpgradeViewModel>();
            this.Perks    = new ObservableCollection <AddPerkViewModel>();
            this.Trailers = new ObservableCollection <AddTrailerViewModel>();

            this.Team = team;

            this.Name = $"Vehicle {team.Vehicles.Count + 1}";

            this.VehicleType = new SelectVehicleViewModel(this);

            // add default handgun
            this.Weapons.Add(new AddWeaponViewModel(this, Constants.AllWeapons.First(x => x.wtype == "Handgun")));

            AllowedAddons = new List <string>
            {
                "Weapons",
                "Upgrades"
            };

            if (team.SponsorMode)
            {
                AllowedAddons.Add("Perks");
            }

            this.Id = Guid.NewGuid();

            MessagingCenter.Subscribe <SelectVehicleViewModel>(this, "VEHICLETYPESAVED", OnVehicleTypeSaved);

            MessagingCenter.Subscribe <AddWeaponViewModel>(this, "WEAPONSAVED", OnWeaponSaved);
            MessagingCenter.Subscribe <AddWeaponViewModel>(this, "WEAPONDELETED", (i) => this.ExecuteDeleteWeapon(i));

            MessagingCenter.Subscribe <AddUpgradeViewModel>(this, "UPGRADESAVED", OnUpgradeSaved);
            MessagingCenter.Subscribe <AddUpgradeViewModel>(this, "UPGRADEDELETED", (i) => this.ExecuteDeleteUpgrade(i));

            MessagingCenter.Subscribe <AddPerkViewModel>(this, "PERKSAVED", OnPerkSaved);
            MessagingCenter.Subscribe <AddPerkViewModel>(this, "PERKDELETED", (i) => this.ExecuteDeletePerk(i));

            MessagingCenter.Subscribe <AddTrailerViewModel>(this, "TRAILERSAVED", OnTrailerSaved);
            MessagingCenter.Subscribe <AddTrailerViewModel>(this, "TRAILERDELETED", (i) => this.ExecuteDeleteTrailer(i));

            // trigger vehicle tyep save logic
            this.OnVehicleTypeSaved(this.VehicleType);
        }
Exemple #3
0
        void OnTeamSaved(AddTeamViewModel obj)
        {
            var match = this.Teams.FirstOrDefault(x => x.Id == obj.Id);

            if (match != null)
            {
                var idx = this.Teams.IndexOf(match);

                this.Teams.RemoveAt(idx);
                this.Teams.Insert(idx, obj);
            }
            else
            {
                this.Teams.Add(obj);
            }

            this.RaiseAllPropertiesChanged();
        }
        // restore data
        public AddVehicleViewModel(AddTeamViewModel team, UserVehicle userVehicle) : this(team)
        {
            this.Id   = userVehicle.Id;
            this.Name = userVehicle.VehicleName;

            this.VehicleType = new SelectVehicleViewModel(this, userVehicle.VehicleType);

            //this.SelectedVehicleType = this.VehicleTypes.FirstOrDefault(x => x.vtype == userVehicle.VehicleType?.vtype);

            this.Weapons.Clear();
            foreach (var w in userVehicle.Weaposn)
            {
                var vm = new AddWeaponViewModel(this, w);
                this.Weapons.Add(vm);
            }

            this.Perks.Clear();
            foreach (var p in userVehicle.Perks)
            {
                var vm = new AddPerkViewModel(this, p);
                this.Perks.Add(vm);
            }

            this.Upgrades.Clear();
            foreach (var u in userVehicle.Upgrades)
            {
                var vm = new AddUpgradeViewModel(this, u);
                this.Upgrades.Add(vm);
            }

            this.Trailers.Clear();
            foreach (var t in userVehicle.Trailers)
            {
                var vm = new AddTrailerViewModel(this, t.Trailer, t.Cargo);
                this.Trailers.Add(vm);

                // run trailer support logic
                this.AddTrailerSupport();
            }

            // todo: restore
        }
Exemple #5
0
        async void ExecuteAddTeamAsync(object obj)
        {
            var vm = new AddTeamViewModel();

            await DependencyService.Get <INavigationService>().Navigate(vm);
        }