Ejemplo n.º 1
0
 public HeatmapService(MapService mapService, Demo demo, ComboboxSelector eventSelector, List <ComboboxSelector> selectedSideList, List <PlayerExtended> selectedPlayerList, List <Round> selectedRoundList)
 {
     MapService          = mapService;
     _demo               = demo;
     _eventSelector      = eventSelector;
     _selectedSideList   = selectedSideList;
     _selectedPlayerList = selectedPlayerList;
     _selectedRoundList  = selectedRoundList;
 }
Ejemplo n.º 2
0
 public HeatmapService(MapService mapService, Demo demo, ComboboxSelector eventSelector, ComboboxSelector sideSelector, PlayerExtended selectedPlayer, Round selectedRound)
 {
     MapService      = mapService;
     _demo           = demo;
     _eventSelector  = eventSelector;
     _sideSelector   = sideSelector;
     _selectedPlayer = selectedPlayer;
     _selectedRound  = selectedRound;
 }
		public SettingsViewModel(
			IDialogService dialogService, ICacheService chacheService, IDemosService demosService,
			ISteamService steamService, IAccountStatsService accountStatsService)
		{
			_dialogService = dialogService;
			_cacheService = chacheService;
			_demosService = demosService;
			_steamService = steamService;
			_accountStatsService = accountStatsService;

			Themes = new List<ComboboxSelector>
			{
				new ComboboxSelector("Dark", Properties.Resources.Dark),
				new ComboboxSelector("Light", Properties.Resources.Light)
			};

			if (IsInDesignMode)
			{
				_dateStatsTo = DateTime.Today.AddDays(30);
				_selectedTheme = new ComboboxSelector("Dark", Properties.Resources.Dark);
			}
			else
			{
				SelectedTheme = Themes.First(t => t.Id == Settings.Default.Theme);
			}

			Languages = new List<ComboboxSelector>();
			foreach (Language language in AppSettings.LANGUAGES.Where(l => l.IsEnabled))
			{
				ComboboxSelector newLanguage = new ComboboxSelector(language.Key, language.Name);
				if (language.Key == Settings.Default.Language) SelectedLanguage = newLanguage;
				Languages.Add(newLanguage);
			}

			Application.Current.Dispatcher.Invoke(async () =>
			{
				List<Account> accounts = await _cacheService.GetAccountListAsync();
				Accounts = new ObservableCollection<Account>(accounts);
				StatusList = new List<DemoStatus>(AppSettings.DefaultStatus);
				SelectedStatsAccount = Accounts.FirstOrDefault(a => a.SteamId == Settings.Default.SelectedStatsAccountSteamID.ToString());
				DownloadFolderPath = Settings.Default.DownloadFolder;
				IgnoreLaterBan = Settings.Default.IgnoreLaterBan;
				CacheSize = await _cacheService.GetCacheSizeAsync();
				_cacheService.Filter.From = Settings.Default.DateStatsFrom;
				_cacheService.Filter.To = Settings.Default.DateStatsTo;
				_cacheService.Filter.Folder = Settings.Default.LimitStatsFolder ? Settings.Default.LastFolder : null;
			});

			Messenger.Default.Register<SettingsFlyoutOpenedMessage>(this, HandleSettingsFlyoutOpenedMessage);
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Return PositionPoint for each players determined by selection
        /// </summary>
        /// <param name="demo"></param>
        /// <param name="teamSelector"></param>
        /// <param name="selectedPlayer"></param>
        /// <param name="round"></param>
        /// <returns></returns>
        public async Task <List <List <PositionPoint> > > GetPoints(Demo demo, ComboboxSelector teamSelector, PlayerExtended selectedPlayer, Round round)
        {
            List <List <PositionPoint> > points = new List <List <PositionPoint> >();

            if (teamSelector != null)
            {
                switch (teamSelector.Id)
                {
                case "CT":
                    demo.PositionsPoint.Reverse();

                    foreach (PlayerExtended playerExtended in demo.Players)
                    {
                        List <PositionPoint> playerPoints = new List <PositionPoint>();

                        for (int i = demo.PositionsPoint.Count - 1; i >= 0; i--)
                        {
                            if (demo.PositionsPoint[i].RoundNumber != round.Number)
                            {
                                continue;
                            }

                            // Keep kills from terrorists
                            if (demo.PositionsPoint[i].Event != null &&
                                demo.PositionsPoint[i].Team == Team.Terrorist &&
                                demo.PositionsPoint[i].Event.GetType() == typeof(KillEvent))
                            {
                                KillEvent e = (KillEvent)demo.PositionsPoint[i].Event;
                                if (e.KillerSteamId == playerExtended.SteamId)
                                {
                                    playerPoints.Add(demo.PositionsPoint[i]);
                                    demo.PositionsPoint.RemoveAt(i);
                                    continue;
                                }
                            }

                            if (demo.PositionsPoint[i].Team != Team.CounterTerrorist)
                            {
                                continue;
                            }

                            // Molotov started
                            if (demo.PositionsPoint[i].Event != null &&
                                demo.PositionsPoint[i].Event.GetType() == typeof(MolotovFireStartedEvent))
                            {
                                MolotovFireStartedEvent e = (MolotovFireStartedEvent)demo.PositionsPoint[i].Event;
                                if (e.ThrowerSteamId == playerExtended.SteamId)
                                {
                                    playerPoints.Add(demo.PositionsPoint[i]);
                                    demo.PositionsPoint.RemoveAt(i);
                                    continue;
                                }
                            }

                            // Molotov ended
                            if (demo.PositionsPoint[i].Event != null &&
                                demo.PositionsPoint[i].Event.GetType() == typeof(MolotovFireEndedEvent))
                            {
                                MolotovFireEndedEvent e = (MolotovFireEndedEvent)demo.PositionsPoint[i].Event;
                                if (e.ThrowerSteamId == playerExtended.SteamId)
                                {
                                    playerPoints.Add(demo.PositionsPoint[i]);
                                    demo.PositionsPoint.RemoveAt(i);
                                    continue;
                                }
                            }

                            if (demo.PositionsPoint[i].PlayerSteamId != 0 &&
                                demo.PositionsPoint[i].PlayerSteamId == playerExtended.SteamId)
                            {
                                playerPoints.Add(demo.PositionsPoint[i]);
                                demo.PositionsPoint.RemoveAt(i);
                            }
                        }
                        if (playerPoints.Any())
                        {
                            points.Add(playerPoints);
                        }
                    }
                    break;

                case "T":
                    demo.PositionsPoint.Reverse();

                    foreach (PlayerExtended playerExtended in demo.Players)
                    {
                        List <PositionPoint> playerPoints = new List <PositionPoint>();

                        for (int i = demo.PositionsPoint.Count - 1; i >= 0; i--)
                        {
                            if (demo.PositionsPoint[i].RoundNumber != round.Number)
                            {
                                continue;
                            }

                            // Keep kills from CT
                            if (demo.PositionsPoint[i].Event != null &&
                                demo.PositionsPoint[i].Team == Team.CounterTerrorist &&
                                demo.PositionsPoint[i].Event.GetType() == typeof(KillEvent))
                            {
                                KillEvent e = (KillEvent)demo.PositionsPoint[i].Event;
                                if (e.KilledSteamId == playerExtended.SteamId)
                                {
                                    playerPoints.Add(demo.PositionsPoint[i]);
                                    demo.PositionsPoint.RemoveAt(i);
                                    continue;
                                }
                            }

                            if (demo.PositionsPoint[i].Team != Team.Terrorist)
                            {
                                continue;
                            }

                            // Molotov started
                            if (demo.PositionsPoint[i].Event != null &&
                                demo.PositionsPoint[i].Event.GetType() == typeof(MolotovFireStartedEvent))
                            {
                                MolotovFireStartedEvent e = (MolotovFireStartedEvent)demo.PositionsPoint[i].Event;
                                if (e.ThrowerSteamId == playerExtended.SteamId)
                                {
                                    playerPoints.Add(demo.PositionsPoint[i]);
                                    demo.PositionsPoint.RemoveAt(i);
                                    continue;
                                }
                            }

                            // Molotov ended
                            if (demo.PositionsPoint[i].Event != null &&
                                demo.PositionsPoint[i].Event.GetType() == typeof(MolotovFireEndedEvent))
                            {
                                MolotovFireEndedEvent e = (MolotovFireEndedEvent)demo.PositionsPoint[i].Event;
                                if (e.ThrowerSteamId == playerExtended.SteamId)
                                {
                                    playerPoints.Add(demo.PositionsPoint[i]);
                                    demo.PositionsPoint.RemoveAt(i);
                                    continue;
                                }
                            }

                            if (demo.PositionsPoint[i].PlayerSteamId == playerExtended.SteamId)
                            {
                                playerPoints.Add(demo.PositionsPoint[i]);
                                demo.PositionsPoint.RemoveAt(i);
                            }
                        }
                        if (playerPoints.Any())
                        {
                            points.Add(playerPoints);
                        }
                    }
                    break;

                case "BOTH":
                    points.AddRange(
                        demo.Players.Select(
                            playerExtended => demo.PositionsPoint.Where(
                                point => point.RoundNumber == round.Number &&
                                point.PlayerSteamId == playerExtended.SteamId).ToList())
                        .Where(pts => pts.Any()));
                    break;
                }
            }

            if (selectedPlayer != null)
            {
                await Task.Run(delegate
                {
                    List <PositionPoint> pt = demo.PositionsPoint.ToList().Where(
                        positionPoint => positionPoint.PlayerSteamId == selectedPlayer.SteamId &&
                        positionPoint.RoundNumber == round.Number ||
                        (positionPoint.Event != null &&
                         positionPoint.Event.GetType() == typeof(KillEvent)) &&
                        positionPoint.RoundNumber == round.Number).ToList();
                    if (pt.Any())
                    {
                        points.Add(pt);
                    }
                });
            }

            // Set players color
            await Task.Run(delegate
            {
                int index = 0;
                foreach (List <PositionPoint> positionPoints in points.ToList())
                {
                    foreach (PositionPoint positionPoint in positionPoints)
                    {
                        positionPoint.X     = MapService.CalculatePointToResolutionX(positionPoint.X);
                        positionPoint.Y     = MapService.CalculatePointToResolutionY(positionPoint.Y);
                        positionPoint.Color = ColorToInt(_colors[index]);
                    }
                    index++;
                }
            });

            return(points);
        }