コード例 #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="game_time">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime game_time)
        {
            // user controller app exit
            // TODO: get this into exit event framework below.
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            ExitGameEvent e = mListener_ExitGameEvent.GetMaxOne();

            if (e != null)
            {
                // elaborate shutdown code goes here.
                Exit();
            }

            // TODO: Add your update logic here
            XTouch.Instance().Update(game_time);
            XKeyInput.Instance().Update();
            XMouse.Instance().Update(game_time);
            XUI.Instance().Update(game_time);
            XRootDebugMenu.Instance().Update();
            XWorld.Instance().Update();

            base.Update(game_time);
        }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: itzikiap/GGJ2020
 public void CallExitGameEvent()
 {
     ExitGameEvent?.Invoke();
 }
コード例 #3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.GameOverView, container, false);

            var restartBtn = view.FindViewById <Button>(Resource.Id.restartBtn);

            restartBtn.Click += (object sender, EventArgs e) =>
            {
                Dismiss();
                RestartGameEvent?.Invoke(this, EventArgs.Empty);
            };
            var restartIcon = VectorDrawableCompat.Create(Resources, Resource.Drawable.ic_replay, view.Context.Theme);

            restartBtn.SetCompoundDrawablesWithIntrinsicBounds(restartIcon, null, null, null);

            var exitButton = view.FindViewById <Button>(Resource.Id.exitBtn);

            exitButton.Click += (object sender, EventArgs e) =>
            {
                Dismiss();
                ExitGameEvent?.Invoke(this, EventArgs.Empty);
            };
            var exitIcon = VectorDrawableCompat.Create(Resources, Resource.Drawable.ic_exit, view.Context.Theme);

            exitButton.SetCompoundDrawablesWithIntrinsicBounds(exitIcon, null, null, null);

            var score        = Arguments.GetInt("Score");
            var highScore    = Arguments.GetInt("HighScore");
            var userName     = Arguments.GetString("UserName");
            var gridSize     = Arguments.GetInt("GridSize");
            var newHighScore = Arguments.GetBoolean("NewHighScore");


            var TitleTextView = view.FindViewById <TextView>(Resource.Id.titleTextView);

            TitleTextView.Text = "Congratulations " + userName + "!";

            if (newHighScore)
            {
                var NewHSTextView = view.FindViewById <TextView>(Resource.Id.newHSTextView);
                NewHSTextView.Visibility = ViewStates.Visible;
                NewHSTextView.Text       = "New High Score!";
                var podiumIcon = VectorDrawableCompat.Create(Resources, Resource.Drawable.ic_podium, view.Context.Theme);
                NewHSTextView.SetCompoundDrawablesWithIntrinsicBounds(null, null, null, podiumIcon);
            }
            var GridSizeTextView = view.FindViewById <TextView>(Resource.Id.gridSizeTextView);

            GridSizeTextView.Text = "Grid Size: " + gridSize.ToString();

            var ScoreTextView = view.FindViewById <TextView>(Resource.Id.scoreTextView);

            ScoreTextView.Text = "Moves: " + score.ToString();

            var HSCTextView = view.FindViewById <TextView>(Resource.Id.highScoreTextView);

            HSCTextView.Text = "High Score: " + highScore.ToString();

            var shareBtn  = view.FindViewById <Button>(Resource.Id.shareBtn);
            var shareIcon = VectorDrawableCompat.Create(Resources, Resource.Drawable.ic_share, view.Context.Theme);

            shareBtn.SetCompoundDrawablesWithIntrinsicBounds(shareIcon, null, null, null);
            shareBtn.Click += (object sender, EventArgs e) =>
            {
                using (var b = BitmapFactory.DecodeResource(Resources, Resource.Drawable.logo))
                {
                    using (var shareIntent = new Intent(Intent.ActionSend))
                    {
                        shareIntent.SetType("text/plain");
                        shareIntent.PutExtra(Intent.ExtraSubject, "Awesome game!");
                        shareIntent.PutExtra(Intent.ExtraText, "Hey, I just finished a match of Clever Sliding Puzzle in " + score.ToString() + " moves.");
                        shareIntent.AddFlags(ActivityFlags.GrantReadUriPermission);
                        StartActivity(Intent.CreateChooser(shareIntent, "Share via"));
                    }
                }
            };
            return(view);
        }