Пример #1
0
        //public static void ShowWinDialog(Context c, Player winner, List<Player> players,  Intent intent,  int leg, int touchCount, int startScore, int numLegs)
        //{
        //    // restart the game
        //    var alert = new Android.Support.V7.App.AlertDialog.Builder(c);
        //    if (winner.legsWon >= (numLegs + 1)/2)
        //    {
        //        alert.SetTitle("Player " + winner.name + " wins the match!");
        //        alert.SetNeutralButton("Start Over", (senderAlert, args) => { c.StartActivity(intent); });
        //    }
        //    else
        //    {
        //        alert.SetTitle("Player " + winner.name + " wins the leg!");
        //        // move to next set/leg or start new game
        //        alert.SetPositiveButton("Move to next leg", (senderAlert, args) => { MoveToNextLeg(leg, players, touchCount, startScore); });
        //        // neutral


        //    }
        //    alert.SetNegativeButton("Back to setup", (senderAlert, args) => { c.StartActivity(typeof(CreateGame)); });
        //    Dialog dialog = alert.Create();
        //    dialog.Show();


        //}

        public static void ShowWinDialog(Context c, Player winner, List <Player> players, Intent intent, int leg, int startScore, int numLegs, Activity activity)
        {
            // restart the game
            var alert = new Android.Support.V7.App.AlertDialog.Builder(c);

            if (winner.legsWon >= (numLegs + 1) / 2)
            {
                alert.SetTitle("Player " + winner.name + " wins the match!");
                alert.SetNeutralButton("New Game", (senderAlert, args) => { MoveToNextLeg(0, players, startScore, activity); });
            }
            else
            {
                alert.SetTitle("Player " + winner.name + " wins the leg!");
                // move to next set/leg or start new game
                alert.SetPositiveButton("Move to next leg", (senderAlert, args) => { MoveToNextLeg(leg, players, startScore, activity); });
            }
            alert.SetNegativeButton("Back to setup", (senderAlert, args) => {
                // Clear the contents of the save file
                HelperFunctions.DeleteSaveFile(Constants.PerviousGameFile);
                c.StartActivity(typeof(CreateGame));
            });
            Dialog dialog = alert.Create();

            dialog.Show();
        }
Пример #2
0
        private void ReturnToMain()
        {
            if (Player1.score != 0 && Player2.score != 0)
            {
                GameLogic.SaveGameData(Player1, Player2, legsPlayed, legsToPlay);
            }
            else
            {
                HelperFunctions.DeleteSaveFile(Constants.PerviousGameFile);
            }
            var alert = new Android.Support.V7.App.AlertDialog.Builder(this);

            alert.SetTitle("Back to Main Menu?");
            alert.SetPositiveButton("Yes", (senderAlert, args) => { Intent intent = new Intent(this, typeof(CreateGame)); this.StartActivity(intent); });
            alert.SetNegativeButton("No", (senderAlert, args) => { alert.Dispose(); });
            Dialog dialog = alert.Create();

            dialog.Show();
        }