Exemplo n.º 1
0
        public HighscoreUCViewModel(IHighscoreRepository highscoreRepository)
        {
            HighscoreRepository = highscoreRepository;

            TopDiligentPlayers = HighscoreRepository.GetTopDiligentPlayers(10) as Dictionary <string, long>;
            TopHighscores      = HighscoreRepository.GetLeaderboard(null);

            if (ActivePlayer != null)
            {
                TopCurrentPlayerHighscores = HighscoreRepository.GetLeaderboard(ActivePlayer.Id);
            }
        }
Exemplo n.º 2
0
        private void Control_Loaded(object sender, RoutedEventArgs e)
        {
            this.model         = new GameModel();
            this.highscoreRepo = new HighscoreRepository();
            Window win = Window.GetWindow(this);

            if ((win as MainWindow).AutoOrManual)
            {
                this.saveGameRepo = new ManualSaveGameRepository((win as MainWindow).LoadFilePath);
            }
            else
            {
                this.saveGameRepo = new AutoSaveGameRepository();
            }

            this.loadigLogic = new LoadingLogic(this.model, this.saveGameRepo, this.highscoreRepo);
            this.model       = this.loadigLogic.Play();
            this.gameLogic   = new GameLogic(this.model);
            this.renderer    = new GameRenderer(this.model);
            if (win != null)
            {
                win.KeyDown             += this.Win_KeyDown;
                win.MouseLeftButtonDown += this.Left_MouseButtonDown;
                win.MouseMove           += this.Win_MouseMove;
            }

            this.updateTimer           = new System.Timers.Timer();
            this.updateTimer.Elapsed  += new ElapsedEventHandler(this.UpdateScreen);
            this.updateTimer.Interval  = 30;
            this.updateTimer.AutoReset = true;
            this.shootOnce             = new DispatcherTimer();
            this.shootOnce.Interval    = TimeSpan.FromMilliseconds(this.rnd.Next(1000, 2000));
            this.shootOnce.Tick       += this.ShootingEnemies;
            this.moveOnce               = new DispatcherTimer();
            this.moveOnce.Interval      = TimeSpan.FromMilliseconds(this.rnd.Next(200, 500));
            this.moveOnce.Tick         += this.MoveEnemies;
            this.moveBossTimer          = new DispatcherTimer();
            this.moveBossTimer.Interval = TimeSpan.FromMilliseconds(800);
            this.moveBossTimer.Tick    += this.MoveBoss;
            this.levelTimer             = new DispatcherTimer();
            this.levelTimer.Interval    = TimeSpan.FromMilliseconds(200);
            this.levelTimer.Tick       += this.LevelTimer_Tick;

            if (!this.model.GameIsPaused)
            {
                this.updateTimer.Enabled = true;
                this.levelTimer.Start();
            }

            this.InvalidateVisual();
        }
Exemplo n.º 3
0
        public GameEndViewModel(Game game, string word)
        {
            _highscoreRepository = new HighscoreRepository();

            Title      = game.IsWon ? _winTitle : _lossTitle;
            TitleColor = game.IsWon ? "Green" : "Red";

            IncorrectGuesses = $"Antal felgissningar: {game.NumberOfIncorrectTries}";
            TotalTime        = "Tid: " + (game.EndTime - game.StartTime).ToString(@"mm\:ss\.ff");
            Word             = word.ToUpper();

            if (game.Id != 0)
            {
                PlayerStatsBoolToVis = true;
                PlayerStatsViewModel = new PlayerStatsUCViewModel();

                if (game.IsWon)
                {
                    var gameRanking = _highscoreRepository.GetRankOnHighScore(game.Id);
                    GameRankDisplay = $"Du kom på plats: {gameRanking}";
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoadingLogic"/> class.
 /// </summary>
 /// <param name="gameModel">Defines a gamestate.</param>
 /// <param name="saveGameRepository">Defines the repository of the gamesaving.</param>
 /// <param name="highscoreRepository">Defines the repository of the highscore system.</param>
 public LoadingLogic(IGameModel gameModel, ISaveGameRepository saveGameRepository, IHighscoreRepository highscoreRepository)
 {
     this.gameModel           = gameModel;
     this.saveGameRepository  = saveGameRepository;
     this.highscoreRepository = highscoreRepository;
 }