protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            try
            {
                App.ViewModel.VehicleUnlocksCol.Clear();

                int vtid = Convert.ToInt32(NavigationContext.QueryString["VehicleTypeID"].ToString());
                VehicleType vt = App.ViewModel.BuiltPlayer.VehicleTypes[vtid];

                txt_desc.Text = vt.TypeName;
                BitmapImage bmi = new BitmapImage(new Uri("bf3/" + vt.TypePic, UriKind.Relative));
                img_type.Source = bmi;

                foreach (VehicleUnlock vu in vt.Unlocks)
                {
                    ItemViewModel ivm = new ItemViewModel();
                    ivm.LineOne = vu.UnlockName;
                    if (Convert.ToDouble(vu.Needed) == 0)
                    {
                        ivm.PBValue = 100.00;
                    }
                    else
                    {
                        ivm.PBValue = Convert.ToDouble((Convert.ToDouble(vu.Current) / Convert.ToDouble(vu.Needed)) * 100.00);
                    }
                    ivm.Needed = vu.Needed.ToString();
                    ivm.Current = vu.Current.ToString();
                    ivm.Tag = vu.Description;

                    ivm.ImgSrc = "bf3/" + vu.UnlockPic;
                    App.ViewModel.VehicleUnlocksCol.Add(ivm);
                }

                Kills.Text = vt.Kills.ToString();
                Stars.Text = vt.ServiceStars.ToString();
                starpb.Value = Convert.ToDouble((Convert.ToDouble(vt.SSCurrent) / Convert.ToDouble(vt.SSNeeded)) * 100.00);
                float hrs = Convert.ToSingle(vt.TimeRaw) / 3600;
                string timestr = String.Format("{0:0.##}", hrs);
                Time.Text = timestr + " hrs";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

        }
Esempio n. 2
0
        public static void BuildPage(Player player)
        {
            int i = 0;

            foreach (Weapon w in player.Weapons)
            {
                ItemViewModel ivm = new ItemViewModel();
                if (w.Shots == "0")
                {
                    ivm.LineTwo = "never used";
                }
                else
                {
                    float per = (Convert.ToSingle(w.Hits) / Convert.ToSingle(w.Shots)) * 100;
                    string hitper = String.Format("{0:0.#}", per);
                    float time = Convert.ToSingle(w.Time) / 3600;
                    string timestr = String.Format("{0:0.##}", time);
                    ivm.LineTwo = w.Kills + " kills @ " + hitper + "% acc in " + timestr + " hrs";
                }

                // this is adjusted now so, for example, 733 current with 800 needed shows 33% rather than 92%
                //ivm.PBValue = Convert.ToDouble((Convert.ToDouble(w.Current) / Convert.ToDouble(w.Needed)) * 100.00);
                double adj_current = Convert.ToDouble(Convert.ToDouble(100) - (Convert.ToDouble(w.Needed) - Convert.ToDouble(w.Current)));
                double adj_needed = Convert.ToDouble(100);
                ivm.PBValue = Convert.ToDouble((adj_current / adj_needed) * 100.00);
                ivm.Current = w.Current.ToString();
                ivm.Needed = w.Needed.ToString();

                ivm.ImgSrc = "bf3/" + w.WeaponPic;
                ivm.LineOne = w.WeaponName;
                ivm.Tag = i.ToString();
                i++;
                App.ViewModel.WeaponsCol.Add(ivm);
            }

            foreach (Vehicle v in player.Vehicles)
            {
                ItemViewModel ivm = new ItemViewModel();
                ivm.ImgSrc = "bf3/" + v.VehiclePic;
                ivm.LineOne = v.VehicleName;
                float time = Convert.ToSingle(v.Time) / 3600;
                string timestr = String.Format("{0:0.##}", time);
                ivm.LineTwo = v.Destroys + " destroys & " + v.Kills + " kills in " + timestr + " hrs";
                ivm.Tag = v.Description;

                App.ViewModel.VehiclesCol.Add(ivm);
            }

            foreach (Ribbon r in player.Ribbons)
            {
                ItemViewModel ivm = new ItemViewModel();
                ivm.ImgSrc = "bf3/" + r.RibbonPic;
                ivm.LineOne = r.RibbonName;
                ivm.LineTwo = "acquired " + r.TimesTaken.ToString() + " times";
                ivm.Tag = r.Description;
                App.ViewModel.RibbonsCol.Add(ivm);
            }

            foreach (Medal m in player.Medals)
            {
                ItemViewModel ivm = new ItemViewModel();
                ivm.ImgSrc = "bf3/" + m.MedalPic;
                ivm.LineOne = m.MedalName;
                ivm.LineTwo = "acquired " + m.TimesTaken.ToString() + " times";
                ivm.Tag = m.Description;
                App.ViewModel.MedalsCol.Add(ivm);
            }

            foreach (Equipment eq in player.Equipments)
            {
                ItemViewModel ivm = new ItemViewModel();
                ivm.ImgSrc = "bf3/" + eq.EquipPic;
                ivm.Img2Src = "bf3/" + eq.KitPic;
                ivm.LineOne = eq.EquipName;
                ivm.LineTwo = eq.LineTwo;
                ivm.Tag = eq.Description;
                App.ViewModel.EquipmentsCol.Add(ivm);
            }

            i = 0;
            foreach (VehicleType vt in player.VehicleTypes)
            {
                ItemViewModel ivm = new ItemViewModel();
                ivm.ImgSrc = "bf3/" + vt.TypePic;
                ivm.LineOne = vt.TypeName;
                ivm.Tag = i.ToString();
                i++;
                App.ViewModel.VehicleTypesCol.Add(ivm);
            }

            ItemViewModel ivm_rank = new ItemViewModel();
            ivm_rank.LineOne = player.PlayerName;
            ivm_rank.LineTwo = "rank " + player.Rank.ToString() + " score " + player.Score.ToString("N0");
            ivm_rank.ImgSrc = "bf3/" + player.RankPic;
            ivm_rank.Tag = "Rank";
            App.ViewModel.UserCol.Add(ivm_rank);

            ItemViewModel ivm_assault = new ItemViewModel();
            ivm_assault.LineOne = "Assault";
            ivm_assault.LineTwo = "score " + player.Assault.Score.ToString("N0");
            ivm_assault.ImgSrc = "bf3/" + player.Assault.KitPic;
            App.ViewModel.UserCol.Add(ivm_assault);

            ItemViewModel ivm_eng = new ItemViewModel();
            ivm_eng.LineOne = "Engineer";
            ivm_eng.LineTwo = "score " + player.Engineer.Score.ToString("N0");
            ivm_eng.ImgSrc = "bf3/" + player.Engineer.KitPic;
            App.ViewModel.UserCol.Add(ivm_eng);

            ItemViewModel ivm_recon = new ItemViewModel();
            ivm_recon.LineOne = "Recon";
            ivm_recon.LineTwo = "score " + player.Recon.Score.ToString("N0");
            ivm_recon.ImgSrc = "bf3/" + player.Recon.KitPic;
            App.ViewModel.UserCol.Add(ivm_recon);

            ItemViewModel ivm_sup = new ItemViewModel();
            ivm_sup.LineOne = "Support";
            ivm_sup.LineTwo = "score " + player.Support.Score.ToString("N0");
            ivm_sup.ImgSrc = "bf3/" + player.Support.KitPic;
            App.ViewModel.UserCol.Add(ivm_sup);

            foreach (NextRank nr in player.NextRanks)
            {
                ItemViewModel ivm = new ItemViewModel();

                int curr = nr.RequiredScore - nr.Left;
                ivm.PBValue = Convert.ToDouble(Convert.ToDouble(curr)/Convert.ToDouble(nr.RequiredScore)) * 100.00;
                ivm.Current = curr.ToString();
                ivm.Needed = nr.RequiredScore.ToString();

                ivm.ImgSrc = "bf3/" + nr.RankPic;
                ivm.LineOne = "Lvl " + nr.Level + " " + nr.RankName;
                i++;
                App.ViewModel.NextRanksCol.Add(ivm);
            }

            App.ViewModel.BuiltPlayer = player;
            PageHandler.SetTile();
        }
Esempio n. 3
0
        public PlayerDetails()
        {
            InitializeComponent();
            DataContext = App.ViewModel;

            PageTitle.Title = App.ViewModel.BuiltPlayer.PlayerName;

            App.ViewModel.SpecsCol.Clear();

            foreach (Specialization s in App.ViewModel.BuiltPlayer.Specs)
            {
                ItemViewModel ivm = new ItemViewModel();
                ivm.LineOne = s.SpecName;
                ivm.PBValue = Convert.ToDouble((Convert.ToDouble(s.Current) / Convert.ToDouble(s.Needed)) * 100.00);
                ivm.ImgSrc = "bf3/" + s.SpecPic;
                ivm.Tag = s.Description;
                ivm.Current = s.Current.ToString();
                ivm.Needed = s.Needed.ToString();
                App.ViewModel.SpecsCol.Add(ivm);
            }

            double d = ((App.ViewModel.BuiltPlayer.Wins * 1.00) / (App.ViewModel.BuiltPlayer.Losses * 1.00));
            double scaled = 0;
            if (d == 0)
            {
                scaled = 50;
            }
            else if (d > 5)
            {
                scaled = 100;
            }
            else if (d > 0)
            {
                scaled = 50 + (d * 10);
            }
            else if (d < -5)
            {
                scaled = 0;
            }
            else
            {
                scaled = 50 - (d * 10);
            }
            string wl = String.Format("{0:0.##}", d);
            string scaledwl = String.Format("{0:0.##}", scaled);
            string uri = "http://chart.googleapis.com/chart?chs=300x150&cht=gom&chd=t:" + scaled + "&chco=939393,2E86B6&chf=bg%2Cs%2CFFFFFF00";

            BitmapImage bmi = new BitmapImage(new Uri(uri, UriKind.Absolute));
            img_wl.Source = bmi;
            txt_wl.Text = wl;

            double kdratio = ((App.ViewModel.BuiltPlayer.Kills * 1.00) / (App.ViewModel.BuiltPlayer.Deaths * 1.00));
            double scaledkd = 0;

            if (kdratio == 1)
            {
                scaledkd = 50;
            }
            else if (kdratio > 5)
            {
                scaledkd = 100;
            }
            else if (kdratio > 1)
            {
                scaledkd = 50 + (kdratio * 10);
            }
            else
            {
                scaledkd = (kdratio / 2) * 100;
            }
            string scaledkdstr = String.Format("{0:0.##}", scaledkd);
            string kduri = "http://chart.googleapis.com/chart?chs=300x150&cht=gom&chd=t:" + scaledkdstr + "&chco=939393,2E86B6&chf=bg%2Cs%2CFFFFFF00";

            BitmapImage kdbmi = new BitmapImage(new Uri(kduri, UriKind.Absolute));
            img_kd.Source = kdbmi;
            string scaledkdstrval = String.Format("{0:0.##}", kdratio);
            txt_kd.Text = scaledkdstrval;

            double acc = ((App.ViewModel.BuiltPlayer.Hits * 1.00) / (App.ViewModel.BuiltPlayer.Shots * 1.00));
            string str_acc = String.Format("{0:0.##}", (acc*100));
            txt_acc.Text = str_acc + "%";

            BitmapImage timebmi = new BitmapImage(new Uri(App.ViewModel.BuiltPlayer.BackTilePic + "150x120", UriKind.Absolute));
            img_kitstime.Source = timebmi;

            double assaultscore = Convert.ToDouble(App.ViewModel.BuiltPlayer.Assault.Score);
            double reconscore = Convert.ToDouble(App.ViewModel.BuiltPlayer.Recon.Score);
            double supportscore = Convert.ToDouble(App.ViewModel.BuiltPlayer.Support.Score);
            double engscore = Convert.ToDouble(App.ViewModel.BuiltPlayer.Engineer.Score);
            double totalscore = assaultscore + reconscore + supportscore + engscore;
            string assaultpers = String.Format("{0:0.##}", ((assaultscore / totalscore) * 100));
            string reconpers = String.Format("{0:0.##}", ((reconscore / totalscore) * 100));
            string supportpers = String.Format("{0:0.##}", ((supportscore / totalscore) * 100));
            string engpers = String.Format("{0:0.##}", ((engscore / totalscore) * 100));
            string scoreuiri = "https://chart.googleapis.com/chart?&cht=pc&chd=t:100|" + assaultpers + "," + engpers + "," + supportpers + "," + reconpers + "&chco=ffffff,308DBF|C4B469|86AE31|A1562E&chs=150x120";
            BitmapImage scorebmi = new BitmapImage(new Uri(scoreuiri, UriKind.Absolute));
            img_kitsscore.Source = scorebmi;

            double spm = (Convert.ToDouble(App.ViewModel.BuiltPlayer.Score) / (Convert.ToDouble(App.ViewModel.BuiltPlayer.TimeRaw) / 60.00));
            txt_spm.Text = String.Format("{0:0.##}", spm);

            double opm = (Convert.ToDouble(App.ViewModel.BuiltPlayer.Objective) / (Convert.ToDouble(App.ViewModel.BuiltPlayer.TimeRaw) / 60.00));
            txt_opm.Text = String.Format("{0:0.##}", opm);

            txt_elo.Text = App.ViewModel.BuiltPlayer.Skill.ToString();

            double timeplayed = (Convert.ToDouble(App.ViewModel.BuiltPlayer.TimeRaw) / 3600.00);
            txt_time.Text = String.Format("{0:0.#}", timeplayed) + " hrs";
        }
Esempio n. 4
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            App.ViewModel.UnlocksCol.Clear();

            int wid = Convert.ToInt32(NavigationContext.QueryString["WeaponID"].ToString());
            Weapon w = App.ViewModel.BuiltPlayer.Weapons[wid];

            weaponmain.Header = w.WeaponName;
            txt_desc.Text = w.Description;

            BitmapImage bmi = new BitmapImage(new Uri("bf3/" + w.WeaponPic, UriKind.Relative));
            img_weapon.Source = bmi;

            if (w.HasHeatMap)
            {
                heatmap.Visibility = Visibility.Visible;
                BitmapImage heatbmi = w.HeatMap;
                img_heat.Source = heatbmi;
            }
            else
            {
                //heatmap.Visibility = Visibility.Collapsed;
                pivotroot.Items.Remove(heatmap);
            }

            if (w.Unlocks.Count > 0)
            {
                unlocks.Visibility = Visibility.Visible;
                foreach (WeaponUnlock wu in w.Unlocks)
                {
                    ItemViewModel ivm = new ItemViewModel();
                    ivm.LineOne = wu.UnlockName;
                    ivm.PBValue = Convert.ToDouble((Convert.ToDouble(wu.Current) / Convert.ToDouble(wu.Needed)) * 100.00);
                    ivm.Current = wu.Current.ToString();
                    ivm.Needed = wu.Needed.ToString();

                    ivm.ImgSrc = "bf3/" + wu.UnlockPic;
                    ivm.LineOne = wu.UnlockName;
                    ivm.Tag = wu.Description;
                    App.ViewModel.UnlocksCol.Add(ivm);
                }
            }
            else
            {
                //unlocks.Visibility = Visibility.Collapsed;
                pivotroot.Items.Remove(unlocks);
            }

            WeaponStats ws = App.ViewModel.WS;
            if (ws.Stats.ContainsKey(w.WeaponName))
            {
                DmgMax.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.dmgMax] + "%";
                DmgMin.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.dmgMin] + "%";
                Reload.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.rld] + "sec";
                ReloadEmpty.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.rldem] + "sec";
                ReloadThresh.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.rldtrs] + "sec";
                Suppression.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.supp];
                Speed.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.speed] + "m/s";
                Distance.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.maxdist] + "m";
                Horz.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.recoil_l] + "/" + ws.Stats[w.WeaponName][(int)WeaponStats.Types.recoil_r];
                Vert.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.recoil_u];
                BTK.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.btk_10] + " / " + ws.Stats[w.WeaponName][(int)WeaponStats.Types.btk_50];
                TTK.Text = ws.Stats[w.WeaponName][(int)WeaponStats.Types.ttk_10] + " / " + ws.Stats[w.WeaponName][(int)WeaponStats.Types.ttk_50];
            }
            else
            {
                pivotroot.Items.Remove(fire);
            }

            float hrs = Convert.ToSingle(w.Time) / 3600;
            string timestr = String.Format("{0:0.##}", hrs);
            Time.Text = timestr + " hrs";
            Stars.Text = w.Stars.ToString();
            Hits.Text = w.Hits;
            Shots.Text = w.Shots;
            Kills.Text = w.Kills;
            Headshots.Text = w.Headshots;
            double adj_current = Convert.ToDouble(Convert.ToDouble(100) - (Convert.ToDouble(w.NextStarNeeded) - Convert.ToDouble(w.NextStarCurrent)));
            double adj_needed = Convert.ToDouble(100);
            //starpb.Value = Convert.ToDouble((Convert.ToDouble(w.NextStarCurrent) / Convert.ToDouble(w.NextStarNeeded)) * 100.00);
            starpb.Value = Convert.ToDouble((adj_current / adj_needed) * 100.00);

            Kit.Text = w.InKit.ToString();
            Range.Text = w.Range.ToString();
            ROF.Text = w.ROF.ToString();
            Ammo.Text = w.Ammo.ToString();

            List<string> mode = new List<string>();
            if (w.FireModeAuto) { mode.Add("Auto"); }
            if (w.FireModeBurst) { mode.Add("Burst"); }
            if (w.FireModeSingle) { mode.Add("Single"); }
            Modes.Text = string.Join(", ", mode);
            
        }