Example #1
0
        /// <summary>
        /// Method for handling common code for playing levels
        /// </summary>
        private void PlayLevels()
        {
            PuzzlePlayer player = new PuzzlePlayer(mPuzzlePanel, sCurrentLvl);

            player.Play(mImage, this);
            mStatus            = "In-Game";
            mBtnPlay.Text      = "Pause";
            mBtnBrowse.Enabled = false;
            FlipCard();
            sIsFixed     = false;
            mCurrentMode = mMode;

            if (mMode == "Competitive")
            {
                mSwaps = 0;
                mTime  = "00:00";
            }
            else
            {
                mSwaps = -1;
                mTime  = "∞";
            }

            if (mMode == "Competitive")
            {
                mMin  = mSec = mTimeInSeconds = 0;
                mTime = "00:00";
            }
            mStatusTimer.Enabled = true;                                  // Start the status timer
            StatusCardFrontFragment.TimeControl(mTime);
            mDrawer.SetDrawerLockMode(DrawerLayout.LockModeLockedClosed); // Lock the navigation drawer
        }
Example #2
0
        /// <summary>
        /// Handles BtnPlay click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MBtnPlay_Click(object sender, EventArgs e)
        {
            PuzzlePlayer player = new PuzzlePlayer(mPuzzlePanel, sCurrentLvl);

            if (mBtnPlay.Text == "Play")
            {
                #region Play button click event
                player.Play(mImage, this);
                if (sCurrentLvl == LVL_1_NUM)
                {
                    mLvl = "Level 1";
                }
                else if (sCurrentLvl == LVL_2_NUM)
                {
                    mLvl = "Level 2";
                }
                else if (sCurrentLvl == LVL_3_NUM)
                {
                    mLvl = "Level 3";
                }
                else
                {
                    mLvl = "Level 4";
                }
                mStatus       = "In-Game";
                mBtnPlay.Text = "Pause";
                Drawable img = ContextCompat.GetDrawable(this, Resource.Drawable.ic_pause_white);
                mBtnPlay.SetCompoundDrawablesWithIntrinsicBounds(img, null, null, null); // Set button icon
                mBtnBrowse.Enabled = false;
                mBtnBrowse.SetBackgroundResource(Resource.Drawable.btn_disabled_style);
                mStatusTimer.Enabled = true; // Start the status timer
                if (mMode == "Competitive")
                {
                    mSwaps = 0;
                    mMin   = mSec = mTimeInSeconds = 0;
                    mTime  = "00:00";
                }
                else
                {
                    mSwaps = -1;
                }
                StatusCardFrontFragment.StatusVisibility(true);
                mDrawer.SetDrawerLockMode(DrawerLayout.LockModeLockedClosed); // Lock the navigation drawer
                #endregion
            }
            else if (mBtnPlay.Text == "Pause")
            {
                #region Pause button click event
                mPuzzlePanel.RemoveAllViews();
                mPuzzlePanel.AddView(mLayoutProgress);
                mPuzzlePanel.AddView(mLayoutMessage);
                mPuzzlePanel.AddView(mPicBoxWhole);
                mStatus       = "Paused";
                mBtnPlay.Text = "Retry";
                Drawable img = ContextCompat.GetDrawable(this, Resource.Drawable.ic_replay_white);
                mBtnPlay.SetCompoundDrawablesWithIntrinsicBounds(img, null, null, null); // Set button icon
                mBtnBrowse.Enabled = true;
                mBtnBrowse.SetBackgroundResource(Resource.Drawable.btn_orange_style);
                if (mShowingBack)
                {
                    FlipCard();
                }
                sIsFixed             = false;
                mStatusTimer.Enabled = false;
                StatusCardFrontFragment.StatusVisibility(false);
                mDrawer.SetDrawerLockMode(DrawerLayout.LockModeUnlocked); // Unlock the navigation drawer
                #endregion
            }
            else if (mBtnPlay.Text == "Retry")
            {
                #region Retry button click event
                player.Play(mImage, this);
                if (sCurrentLvl == LVL_1_NUM)
                {
                    mLvl = "Level 1";
                }
                else if (sCurrentLvl == LVL_2_NUM)
                {
                    mLvl = "Level 2";
                }
                else if (sCurrentLvl == LVL_3_NUM)
                {
                    mLvl = "Level 3";
                }
                else
                {
                    mLvl = "Level 4";
                }
                mStatus       = "In-Game";
                mBtnPlay.Text = "Pause";
                Drawable img = ContextCompat.GetDrawable(this, Resource.Drawable.ic_pause_white);
                mBtnPlay.SetCompoundDrawablesWithIntrinsicBounds(img, null, null, null); // Set button icon
                mBtnBrowse.Enabled = false;
                mBtnBrowse.SetBackgroundResource(Resource.Drawable.btn_disabled_style);
                mStatusTimer.Enabled = true; // Start the status timer
                if (mMode == "Competitive")
                {
                    mSwaps = 0;
                    mMin   = mSec = mTimeInSeconds = 0;
                    mTime  = "00:00";
                }
                else
                {
                    mSwaps = -1;
                }
                StatusCardFrontFragment.StatusVisibility(true);
                mDrawer.SetDrawerLockMode(DrawerLayout.LockModeLockedClosed); // Lock the navigation drawer
                #endregion
            }

            mCurrentMode = mMode;
            StatusCardFrontFragment.StatusControl(mLvl, mCurrentMode, mStatus);
            StatusCardFrontFragment.SwapsControl(mSwaps);
            StatusCardFrontFragment.TimeControl(mTime);
        }