public async Task <IActionResult> SinglePlayer()
        {
            var response = await DbContext.Set <UserScore>().FirstOrDefaultAsync(n => n.UserId == User.FindFirstValue(ClaimTypes.NameIdentifier));

            if (response == null)
            {
                var record = new UserScore
                {
                    UserId      = User.FindFirstValue(ClaimTypes.NameIdentifier),
                    TimeStamp   = DateTime.UtcNow,
                    EvaCost     = 10,
                    NewtonCost  = 50,
                    JobsCost    = 100,
                    EvaCount    = 0,
                    NewtonCount = 0,
                    JobsCount   = 0,
                    Score       = 1
                };
                DbContext.Add(record);
                DbContext.SaveChanges();
                response = record;
            }
            var model = new SinglePlayerViewModel
            {
                EvaCost     = response.EvaCost,
                EvaCount    = response.EvaCount,
                JobsCost    = response.JobsCost,
                JobsCount   = response.JobsCount,
                NewtonCost  = response.NewtonCost,
                NewtonCount = response.NewtonCount,
                Score       = response.Score
            };

            return(View(model));
        }
 public SinglePlayerView(string name, string width, string height)
 {
     InitializeComponent();
     this.ViewModel         = new SinglePlayerViewModel();
     ViewModel.NotifFinish += Finish;
     this.DataContext       = ViewModel;
     ViewModel.StartSingle(name, width, height);
 }
Example #3
0
 public MainMenuViewModel(AppManager appManager, 
     SinglePlayerViewModel singlePlayerViewModel,
     CardsCatalogViewModel cardsCatalog)
 {
     _appManager = appManager;
     _singlePlayerViewModel = singlePlayerViewModel;
     _cardsCatalog = cardsCatalog;
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SinglePlayerMenu"/> class.
 /// </summary>
 public SinglePlayerMenu()
 {
     InitializeComponent();
     vm = new SinglePlayerViewModel(new SinglePlayerModel());
     this.DataContext        = vm;
     UserControl.TxtMazeName = Properties.Settings.Default.MazeName;
     UserControl.TxtRows     = Properties.Settings.Default.MazeRows;
     UserControl.TxtCols     = Properties.Settings.Default.MazeCols;
 }
Example #5
0
        public SinglePlayer(SinglePlayerViewModel otherVm)
        {
            if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                return;
            }
            InitializeComponent();

            this.vm          = otherVm;
            this.DataContext = vm;
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SinglePlayer"/> class.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="main">The main.</param>
 public SinglePlayer(ISinglePlayerModel model, Window main)
 {
     InitializeComponent();
     // play the single player music
     this.player = new MusicPlayer("singleplayer.mp3");
     this.player.Play();
     this.mainWindow = main;
     // create a ViewModel for the singleplayer with the given model
     this.vm                   = new SinglePlayerViewModel(model);
     this.DataContext          = this.vm;
     this.mazeCtrl.DataContext = this.vm;
 }
Example #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SinglePlayerWindow"/> class.
        /// </summary>
        public SinglePlayerWindow()
        {
            try
            {
                spVM = new SinglePlayerViewModel();
            }
            catch (Exception)
            {
                NotifyCommunicationProblem();
            }

            this.DataContext = spVM;
            InitializeComponent();
        }
        public SinglePlayerGameWindow(string name, int rows, int cols)
        {
            vm = new SinglePlayerViewModel(new SinglePlayerModel(new SettingsModel()));
            this.DataContext            = this.vm;//check if it should be before initialization.
            vm.ConnectionErrorOccurred += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (MessageBox.Show("There was an error with the connection to the server", "Connection Error", MessageBoxButton.OK) == MessageBoxResult.OK)
                {
                }
            };
            vm.StartNewGame(name, rows, cols);
            if (vm.Is_Enabled)
            {
                InitializeComponent();
            }
            else
            {
                Close();
            }


            // this.DataContext = this.vm;//check if it should be before initialization.
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SingleMaze"/> class.
 /// </summary>
 /// <param name="vm">The vm.</param>
 public SingleMaze(SinglePlayerViewModel vm)
 {
     this.vm          = vm;
     this.DataContext = vm;
     InitializeComponent();
 }
Example #10
0
 public MenuSinglePlayer()
 {
     InitializeComponent();
     vm = new SinglePlayerViewModel();
     this.DataContext = vm;
 }
Example #11
0
 public void setVm(SinglePlayerViewModel otherVm)
 {
     this.vm = otherVm;
 }
Example #12
0
 public SinglePlayerWindow()
 {
     vm = new SinglePlayerViewModel();
     this.DataContext = vm;
     InitializeComponent();
 }