public GameplayView() { InitializeComponent(); DataContext = new GameplayViewModel(new DialogService { Owner = this }); }
private void CreateViewModels() { FindTargetViewModel = new FindTargetViewModel(); CountdawnViewModel = new CountdawnViewModel(); GameplayViewModel = new GameplayViewModel(); WinViewModel = new WinViewModel(); LoseViewModel = new LoseViewModel(); PauseViewModel = new PauseViewModel(); FindTargetViewModel.Init(); CountdawnViewModel.Init(); GameplayViewModel.Init(); WinViewModel.Init(); LoseViewModel.Init(); PauseViewModel.Init(); FindTargetViewModel.SetupWindow(); CountdawnViewModel.SetupWindow(); GameplayViewModel.SetupWindow(); WinViewModel.SetupWindow(); LoseViewModel.SetupWindow(); PauseViewModel.SetupWindow(); FindTargetViewModel.OpenWindow(); //CountdawnViewModel.OpenWindow(); }
public Gameplay() { ViewModel = new GameplayViewModel(); InitializeComponent(); ApplyEffectFlyout.Closed += ApplyEffectReset; Application.Current.Suspending += SuspendAsync; SaveGames.SelectionChanged += LoadGameAsync; }
internal static async Task SaveAsync(GameplayViewModel viewModel) { var gameSaveFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("SaveGames", CreationCollisionOption.OpenIfExists); var gameSaveFile = await gameSaveFolder.CreateFileAsync(viewModel.Id.ToString(), CreationCollisionOption.ReplaceExisting); await WriteObjectAsync(viewModel, gameSaveFile); }
internal static async Task SuspendAsync(Type pageType, GameplayViewModel viewModel, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); await WriteObjectAsync(pageType, currentPageKey); await WriteObjectAsync(viewModel, currentPageViewModelKey); deferral.Complete(); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { var content = e.Parameter; if (content is GameplayViewModel) { ViewModel = content as GameplayViewModel; } await ViewModel.LoadSaveGamesAsync(); }
private async void LoadGameAsync(object sender, SelectionChangedEventArgs e) { if (SaveGames.SelectedItems.Count != 1) { return; } await ViewModel.SaveAsync(); splitter.IsPaneOpen = false; var newGame = SaveGames.SelectedItems.FirstOrDefault() as GameplayViewModel; await newGame?.LoadSaveGamesAsync(); if (newGame != null) { ViewModel = newGame; } SaveGames.SelectedItems.Clear(); }
void HandleGameSelected(object sender, GameViewModel e) { var gameplayViewController = AppDelegate.GameplayStoryboard.InstantiateViewController("GameplayViewController") as GameplayViewController; var gameplayViewModel = new GameplayViewModel(AppDelegate.Repository, e.Model, this.View.Frame.Height, this.View.Frame.Width); BTProgressHUD.Show("Loading Game Data", -1, ProgressHUD.MaskType.Black); gameplayViewModel.InitializeAsync().ContinueWith(t => { InvokeOnMainThread(() => { if (!t.IsFaulted && t.Result) { gameplayViewController.SetGameplayViewModel(gameplayViewModel); this.TabBarController.TabBar.Hidden = true; this.NavigationController.PushViewController(gameplayViewController, true); } else { // TODO error } BTProgressHUD.Dismiss(); }); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public GameplayView(RectangleF frame, GameplayViewModel viewModel) : base(frame) { this.UserInteractionEnabled = true; this.viewModel = viewModel; this.animationDuration = this.viewModel.TimeRemainingAtStart / 1000.0f; this.popped = this.viewModel.BalloonIsPopped; UIImage backgroundImage, balloonImage; if (this.viewModel.BackgroundImageStream == null || this.viewModel.BalloonImageStream == null) { backgroundImage = UIImage.FromBundle("balloonbackground.jpg"); balloonImage = UIImage.FromBundle("balloon_orange.png"); } else { var backgroundData = NSData.FromStream(this.viewModel.BackgroundImageStream); var balloonData = NSData.FromStream(this.viewModel.BalloonImageStream); backgroundImage = UIImage.LoadFromData(backgroundData); balloonImage = UIImage.LoadFromData(balloonData); } SetImages(backgroundImage, balloonImage); }
public GameplayWindow(GameplayViewModel gameplayViewModel) { DataContext = gameplayViewModel; InitializeComponent(); }
public void SetGameplayViewModel(GameplayViewModel viewModel) { this.viewModel = viewModel; }
public IActionResult Gameplay([FromForm] int questionId, [FromForm] List <GivedAnswer> givedAnswerList) { GameplayViewModel vmodel = new GameplayViewModel(); if (givedAnswerList != null) { if (_questionManager.IsItGoodAnswers(givedAnswerList)) { int?point; point = HttpContext.Session.GetInt32(SessionKeyPoints); point += _questionManager.GetPoint(questionId); HttpContext.Session.SetInt32(SessionKeyPoints, point ?? 0); vmodel.Points = point ?? 0; } else { vmodel.Points = HttpContext.Session.GetInt32(SessionKeyPoints) ?? 0; } foreach (var item in givedAnswerList) { _questionManager.AddGivedAnswer(item); } } else { BadRequest(); } string sessissonKeyIds = HttpContext.Session.GetString(SessionKeyIds); if (sessissonKeyIds == null || sessissonKeyIds.Equals("")) { ViewData["point"] = vmodel.Points; int?sessionsss = HttpContext.Session.GetInt32(SessionKeySession); _questionManager.AddPoint( _questionManager.GetSessionById(HttpContext.Session.GetInt32(SessionKeySession) ?? 0), vmodel.Points ); return(View("EndQuiz")); } string[] splitedIds = sessissonKeyIds.Split(' '); int queryId = Int32.Parse(splitedIds[0]); string ids = ConcatenateIds(splitedIds); HttpContext.Session.SetString(SessionKeyIds, ids); ViewData["theme"] = _questionManager.GetThemeNameByQuestionId(queryId); return(View("Gameplay", new GameplayViewModel() { Question = _questionManager.GetQuestionById(queryId), Ids = ids, SessionId = HttpContext.Session.GetInt32(SessionKeySession) ?? 0, Points = vmodel.Points })); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.GameplayLayout); var gameData = Intent.GetStringExtra(GameModel.GetKey()); GameModel gameModel = GameModel.DeserializeFromJson(gameData); this.balloonOverlayLayer = FindViewById <RelativeLayout> (Resource.Id.balloonOverlay); this.bottomSectionText = balloonOverlayLayer.FindViewById <TextView>(Resource.Id.textView1); this.balloonViewContainer = this.balloonOverlayLayer.FindViewById <RelativeLayout> (Resource.Id.balloonContainerRelativeLayout); this.gameoverOverlayLayer = balloonOverlayLayer.FindViewById <RelativeLayout>(Resource.Id.gameOverOverlay); this.gameoverText = gameoverOverlayLayer.FindViewById <TextView> (Resource.Id.gameoverTextView); this.textureView = gameoverOverlayLayer.FindViewById <TextureView>(Resource.Id.textureView1); this.textureView.SurfaceTextureListener = this; AndHUD.Shared.Show(this, "Loading Game Data", -1, MaskType.Black); ((POPpicApplication)Application).GetGameRepository(this).ContinueWith(r => { viewModel = new GameplayViewModel(r.Result, gameModel, Resources.DisplayMetrics.WidthPixels, Resources.DisplayMetrics.HeightPixels); viewModel.Tick += StopWatchTick; viewModel.InitializeAsync().ContinueWith((t) => { if (!t.IsFaulted) { this.player1TimeText = FindViewById <TextView> (Resource.Id.leftplayerTimeText); this.player1NameText = FindViewById <TextView> (Resource.Id.leftPlayerNameText); this.player1NameText.Text = this.viewModel.PlayerName1; this.player2TimeText = FindViewById <TextView> (Resource.Id.rightplayerTimeText); this.player2NameText = FindViewById <TextView> (Resource.Id.rightPlayerNameText); this.player2NameText.Text = this.viewModel.PlayerName2; this.finishRoundButton = balloonOverlayLayer.FindViewById <Button>(Resource.Id.button1); this.finishRoundButton.Text = this.viewModel.FinishTurnButtonText; this.finishRoundButton.Click += OnNextRoundClicked; // this.balloonImage.Touch += OnBalloonTouched; this.balloonView = new BalloonBackgroundView(this, this.viewModel); this.balloonView.BalloonTouchChanged += this.OnBalloonTouched; // Bitmap background; Bitmap balloon; if (this.viewModel.BackgroundImageStream != null && this.viewModel.BalloonImageStream != null) { background = BitmapFactory.DecodeStream(this.viewModel.BackgroundImageStream); balloon = BitmapFactory.DecodeStream(this.viewModel.BalloonImageStream); } else { background = BitmapFactory.DecodeResource(Resources, Resource.Drawable.balloonbackground); balloon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.balloon); } var pop = BitmapFactory.DecodeResource(Resources, Resource.Drawable.popImage); balloonView.SetImages(background, balloon, pop); this.balloonViewContainer.AddView(this.balloonView); this.SetImage(Resource.Id.leftPlayerImage, this.viewModel.PlayerProfileImage1); this.SetImage(Resource.Id.rightPlayerImage, this.viewModel.PlayerProfileImage2); if (this.viewModel.LoserImgData != null) { Bitmap bmp = BitmapFactory.DecodeByteArray(this.viewModel.LoserImgData, 0, this.viewModel.LoserImgData.Length); SetResultImage(bmp); ShowOverlay(); } this.bottomSectionText.Text = this.viewModel.BottomHintText; UpdateUI(); } else { AndHUD.Shared.ShowError(this, "Error Loading Game", MaskType.Black, TimeSpan.FromSeconds(3)); Finish(); } AndHUD.Shared.Dismiss(); }, TaskScheduler.FromCurrentSynchronizationContext()); }, TaskScheduler.FromCurrentSynchronizationContext()); inflationMediaPlayer = new MediaPlayer(); var fd = Application.Resources.OpenRawResourceFd(Resource.Raw.aria02); inflationMediaPlayer.SetDataSource(fd.FileDescriptor, fd.StartOffset, fd.Length); inflationMediaPlayer.SetAudioStreamType(Android.Media.Stream.System); inflationMediaPlayer.Prepare(); poppingMediaPlayer = new MediaPlayer(); var popFd = Application.Resources.OpenRawResourceFd(Resource.Raw.BalloonPop); poppingMediaPlayer.SetDataSource(popFd.FileDescriptor, popFd.StartOffset, popFd.Length); poppingMediaPlayer.SetAudioStreamType(Android.Media.Stream.System); poppingMediaPlayer.Prepare(); }
public GameplayView(GameplayViewModel viewModel) : base(viewModel) { InitializeComponent(); }
public BalloonBackgroundView(Context context, GameplayViewModel viewModel) : base(context) { this.viewModel = viewModel; Initialize(); }