Ejemplo n.º 1
0
 // ----------------------------------------------------------------------------------------------------------------
 // Begins the Activity specified by @param type.
 // @param type must be a type exisiting in Scar Arcade application.
 // @param valueTwo must be greater than or equal to 0.
 // Overrided method.
 public static void BeginActivity(Context c, Type type, string variableName, int value, string variableTwoName, int valueTwo)
 {
     try
     {
         if (valueTwo >= 0)
         {
             Intent intent = new Intent(c, type);
             if (type != typeof(MainActivity))
             {
                 intent.PutExtra(variableTwoName, valueTwo);
                 intent.PutExtra(variableName, value);
             }
             c.StartActivity(intent);
         }
         else
         {
             throw new Exception();
         }
     }
     catch
     {
         // because an error has happend at the Application level
         // We delegate the responsibility to the GlobalApp class.
         GlobalApp.Alert(c, 2);
     }
 }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetContentView(Resource.Layout.UserInput);

                saveBtn          = FindViewById <Button>(Resource.Id.saveBtn);
                menuBtn          = FindViewById <Button>(Resource.Id.menuBtn);
                enterNameTxt     = FindViewById <EditText>(Resource.Id.enterNameETxt);
                scoreTxtView     = FindViewById <TextView>(Resource.Id.scoreTxtView);
                timeTxtView      = FindViewById <TextView>(Resource.Id.timeTxtView);
                highScoreTxtView = FindViewById <TextView>(Resource.Id.highScoreTxtView);
                congratTxtView   = FindViewById <TextView>(Resource.Id.congratulationsTxtView);
                chkBoxName       = FindViewById <CheckBox>(Resource.Id.chkBoxPreviousName);
                // Event handlers:
                enterNameTxt.Click += EditTextClick;
                menuBtn.Click      += MenuButtonClick;
                chkBoxName.Click   += CheckBoxClick;
                saveBtn.Click      += SaveButtonClick;

                // Initializing data for the User input.
                enterNameTxt.Text = DEFAULTENTERNAMEHERE;

                string content = Intent.GetStringExtra(GlobalApp.getPlayersScoreVariable());


                // Why starting at index 1? Because the Name will come before the score data.
                string score = GlobalApp.splitString(content, 1, '-');
                string dif   = GlobalApp.splitString(content, 2, '-');
                string time  = GlobalApp.splitString(content, 3, '-');
                scoreTxtView.Text += " " + score;
                timeTxtView.Text  += " " + time;

                chkBoxName.Enabled = !GlobalApp.isNewPlayer();

                // We don't want the checkbox to be auto checked.
                if (chkBoxName.Enabled)
                {
                    chkBoxName.Checked = false;
                }

                checkForNewPositionToLocalAndOnline(score, time, dif);
            }
            catch
            {
                GlobalApp.Alert(this, 0);
            }
        }
Ejemplo n.º 5
0
 // ----------------------------------------------------------------------------------------------------------------
 // Predefined method to the create to build the Activity Main.axml executes.
 protected override void OnCreate(Bundle bundle)
 {
     try
     {
         // Bind, and create all Views, and data for the Main.axml
         base.OnCreate(bundle);
         SetContentView(Resource.Layout.Main);
         lvGameList            = FindViewById <ListView>(Resource.Id.lvGameList);
         lvGameList.Adapter    = new MainRowAdapter(this);
         lvGameList.ItemClick += listViewItemClick;
     }
     catch
     {
         GlobalApp.Alert(this, 0);
     }
 }
Ejemplo n.º 6
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));
            }
        }
Ejemplo n.º 7
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     try
     {
         base.OnCreate(savedInstanceState);
         base.
         SetContentView(Resource.Layout.Start);
         appLogoImgView = FindViewById <ImageView>(Resource.Id.ApplicationLogoImgView);
         progress       = FindViewById <ProgressBar>(Resource.Id.startProgress);
         Bitmap appLogo = BitmapFactory.DecodeResource(Resources, Resource.Drawable.SCaRARCADE);
         appLogoImgView.SetImageBitmap(appLogo);
         delay = 3;      // Arbitrary number (3 seconds).
         CountDown();
     }
     catch
     {
         GlobalApp.Alert(this, 1);
     }
 }
Ejemplo n.º 8
0
 // ----------------------------------------------------------------------------------------------------------------
 // Initializes the data for the Leaderboard Local, and Online.
 // @param isOnline, must be either true, or false.
 private void initializeLeaderboardData(bool isOnline)
 {
     try
     {
         if (isOnline)
         {
             setBackgroundColorByClick(Color.DarkGray, Color.Gray, isOnline);
             if (LeaderBoardInterface.hasInternetConnection())
             {
                 // Delete the current Adpater
                 LeaderBoardListView.Adapter = null;
                 // And store a new one.
                 LeaderBoardListView.Adapter = new LeaderBoardRowAdapter(this, isOnline);
             }
             else
             {
                 // Delete the current Adpater
                 LeaderBoardListView.Adapter = null;
                 // And store a new one.
                 LeaderBoardListView.Adapter = new LeaderBoardRowAdapter(this);
             }
         }
         else
         {
             setBackgroundColorByClick(Color.DarkGray, Color.Gray, isOnline);
             // Delete the current Adpater
             LeaderBoardListView.Adapter = null;
             // And store a new one.
             LeaderBoardListView.Adapter = new LeaderBoardRowAdapter(this, isOnline);
         }
     }
     catch
     {
         GlobalApp.Alert(this, 0);
     }
 }