Example #1
0
        // ----------------------------------------------------------------------------------------------------------------
        // Predefined method to the create to build the Activity GameMenu.axml executes.
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetContentView(Resource.Layout.GameMenu);

                FullScreen            = FindViewById <LinearLayout>(Resource.Id.FullScreenLinLay);
                txtGameTitle          = FindViewById <TextView>(Resource.Id.txtGameTitle);
                txtDifficulty         = FindViewById <TextView>(Resource.Id.txtDifficulty);
                btnStart              = FindViewById <Button>(Resource.Id.btnStart);
                btnLeaderBoard        = FindViewById <Button>(Resource.Id.btnLeaderBoard);
                btnBack               = FindViewById <Button>(Resource.Id.btnGameSelect);
                imgBtnIn              = FindViewById <ImageButton>(Resource.Id.imgBtnIncrease);
                imgBtnDe              = FindViewById <ImageButton>(Resource.Id.imgBtnDecrease);
                gameDescription       = FindViewById <TextView>(Resource.Id.description);
                descriptionTitle      = FindViewById <TextView>(Resource.Id.desTextView);
                descriptionBackground = FindViewById <LinearLayout>(Resource.Id.descriptionLinLay);

                // get the index of the item the player has chosen.
                gameChoice = Intent.GetIntExtra(GlobalApp.getVariableChoiceName(), 0);

                game = GameInterface.getGameAt(gameChoice);

                if (game == null)
                {
                    throw new Exception();
                }

                difficulty         = game.gMinDifficulty;
                minDifficulty      = game.gMinDifficulty;
                maxDifficulty      = game.gMaxDifficulty;
                txtDifficulty.Text = String.Format("{0}", difficulty);
                txtGameTitle.Text  = game.gTitle;
                FullScreen.SetBackgroundResource(game.gMenuBackground);
                descriptionBackground.SetBackgroundColor(Color.Gray);

                // Event handlers.
                btnStart.Click       += ButtonClickStart;
                btnBack.Click        += ButtonClickSelect;
                btnLeaderBoard.Click += ButtonClickLeaderboard;
                imgBtnIn.Click       += ImageButtonIncrease;
                imgBtnDe.Click       += ImageButtonDecrease;

                // Add the plus and minus pictures to the two image buttons,
                // that can increase or decrease the difficulty level.
                addPlusAndMinus();

                initializeKeyComponents();
            }
            catch
            {
                GlobalApp.Alert(this, 0);
            }
        }
Example #2
0
        // ----------------------------------------------------------------------------------------------------------------
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetContentView(Resource.Layout.Leaderboard);
                Background          = FindViewById <LinearLayout>(Resource.Id.BackgroundLinLay);
                LeaderBoard         = FindViewById <LinearLayout>(Resource.Id.LeaderBoardLinLay);
                LeaderBoardHeader   = FindViewById <LinearLayout>(Resource.Id.linearLayout1);
                LeaderBoardListView = FindViewById <ListView>(Resource.Id.LeaderBoardListView);
                middleLayout        = FindViewById <LinearLayout>(Resource.Id.MiddleLinLay);
                btnBack             = FindViewById <Button>(Resource.Id.btnGameSelect);
                localBtn            = FindViewById <Button>(Resource.Id.btnLocal);
                onlineBtn           = FindViewById <Button>(Resource.Id.btnOnline);

                var metrics = Resources.DisplayMetrics;
                middleLayout.LayoutParameters = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MatchParent,
                    (int)(metrics.HeightPixels * 0.75)
                    );

                LeaderBoardListView.Adapter = new LeaderBoardRowAdapter(this, false);

                setBackgroundColorByClick(Color.DarkGray, Color.Gray, false);

                LeaderBoard.SetBackgroundColor(Color.Gray);
                LeaderBoardHeader.SetBackgroundColor(Color.LightGray);

                gameChoice = Intent.GetIntExtra(GlobalApp.getVariableChoiceName(), 0);

                game = GameInterface.getGameAt(gameChoice);

                if (game == null)
                {
                    throw new Exception();
                }

                Background.SetBackgroundResource(game.gMenuBackground);

                // Event handlers.
                btnBack.Click   += ButtonClickSelect;
                localBtn.Click  += ButtonLocalClick;
                onlineBtn.Click += ButtonOnlineClick;
            }
            catch
            {
                GlobalApp.Alert(this, 0);
            }
        }
        // ----------------------------------------------------------------------------------------------------------------
        // Add the players score, and saves it into the current storage.
        protected void SaveButtonClick(Object sender, EventArgs args)
        {
            try
            {
                string content = Intent.GetStringExtra(GlobalApp.getPlayersScoreVariable());

                if (GlobalApp.isNewPlayer())
                {
                    if (String.Compare(enterNameTxt.Text, DEFAULTENTERNAMEHERE) == 0)
                    {
                        GlobalApp.setName(DEFAULTNAME);
                        content = DEFAULTNAME + content;
                    }
                    else
                    {
                        GlobalApp.setName(enterNameTxt.Text);
                        content = enterNameTxt.Text + content;
                    }
                }
                else
                {
                    if (String.Compare(enterNameTxt.Text, DEFAULTENTERNAMEHERE) == 0)
                    {
                        GlobalApp.setName(DEFAULTNAME);
                        content = DEFAULTNAME + content;
                    }
                    else
                    {
                        GlobalApp.setName(enterNameTxt.Text);
                        content = enterNameTxt.Text + content;
                    }
                }

                // Now we can add the new score into the local leaderboard.
                // Method: addNewScore will also determine if the score can be added into the Online leaderboard.
                LeaderBoardInterface.addNewScore(content);
            }
            catch
            {
                GlobalApp.Alert(this, 0);
            }
            finally
            {
                GlobalApp.BeginActivity(this, typeof(GameMenuActivity), GlobalApp.getVariableChoiceName(), Intent.GetIntExtra(GlobalApp.getVariableChoiceName(), 0));
            }
        }
Example #4
0
 // ----------------------------------------------------------------------------------------------------------------
 // Event handler: Determines which item was selected in the list of games
 // and moves to GameMenuActivity.
 private void listViewItemClick(Object sender, AdapterView.ItemClickEventArgs args)
 {
     GlobalApp.BeginActivity(this, typeof(GameMenuActivity), GlobalApp.getVariableChoiceName(), args.Position);
 }
Example #5
0
 // ----------------------------------------------------------------------------------------------------------------
 // Returns to the Game Menu Activity of the application.
 protected void ButtonClickSelect(Object sender, EventArgs args)
 {
     GlobalApp.BeginActivity(this, typeof(GameMenuActivity), GlobalApp.getVariableChoiceName(), gameChoice);
 }
Example #6
0
 // ----------------------------------------------------------------------------------------------------------------
 // Event Handler: Will direct the player to the Main menu.
 public override void OnBackPressed()
 {
     GlobalApp.BeginActivity(this, typeof(GameMenuActivity), GlobalApp.getVariableChoiceName(), gameChoice);
 }
 // ----------------------------------------------------------------------------------------------------------------
 protected void MenuButtonClick(Object sender, EventArgs args)
 {
     GlobalApp.BeginActivity(this, typeof(GameMenuActivity), GlobalApp.getVariableChoiceName(), Intent.GetIntExtra(GlobalApp.getVariableChoiceName(), 0));
 }
Example #8
0
 // ----------------------------------------------------------------------------------------------------------------
 // Event Handler: Will direct the user to the Leaderboard.
 protected void ButtonClickLeaderboard(Object sender, EventArgs ev)
 {
     GlobalApp.BeginActivity(this, typeof(LeaderBoardActivity), GlobalApp.getVariableChoiceName(), gameChoice);
 }
Example #9
0
 // ---------------------------------------------------------------------------------------------------------------
 // Begins the game selected from the Main menu.
 protected void ButtonClickStart(Object sender, EventArgs args)
 {
     // Begin the game Activity specifed by type
     GlobalApp.BeginActivity(this, game.gType, GlobalApp.getVariableDifficultyName(), difficulty, GlobalApp.getVariableChoiceName(), Intent.GetIntExtra(GlobalApp.getVariableChoiceName(), 0));
 }