示例#1
0
        /// <summary>
        /// Starts the create table activity.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void createClick(object sender, EventArgs e)
        {
            _create.Enabled = false;

            string [] names = new string[5];


            names [0] = BTManager.Instance.GetLocalName();
            if (names [0].Length > MainActivity.MAX_NAME_LENGHT)
            {
                names [0] = names [0].Substring(0, MainActivity.MAX_NAME_LENGHT);
            }

            names [1] = Resources.GetText(Resource.String.Default1);
            names [2] = Resources.GetText(Resource.String.Default2);
            names [3] = Resources.GetText(Resource.String.Default3);
            names [4] = Resources.GetText(Resource.String.Default4);

            string [] address = new string[4];
            for (int i = 0; i < 4; ++i)
            {
                address [i] = Resources.GetText(Resource.String.none_add);
            }

            Intent inte = new Intent(this, typeof(CreateTabActivity));

            GameProfile gp = new GameProfile(names, address, 0);

            gp.setIntent(inte);

            StartActivityForResult(inte, 1);
        }
示例#2
0
        /// <summary>
        /// Called on activity creation.
        /// </summary>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            int res = Intent.GetIntExtra("NewGame", 0);

            if (res == 1)
            {
                if (BTManager.Instance.isSlave())
                {
                    Intent serverIntent = new Intent(this, typeof(JoinTableActivity));
                    StartActivityForResult(serverIntent, 1);
                }
                else
                {
                    Intent      inte = new Intent(this, typeof(CreateTabActivity));
                    GameProfile gp   = new GameProfile(Intent);
                    gp.setIntent(inte);

                    StartActivityForResult(inte, 1);
                }
            }
            else
            {
                BTManager.Instance.Reset();
            }

            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Main);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            DisplayMetrics metrics    = Resources.DisplayMetrics;
            int            widthInDp  = metrics.WidthPixels;
            int            heightInDp = metrics.HeightPixels;

            _create       = FindViewById <Button> (Resource.Id.create);
            _join         = FindViewById <Button> (Resource.Id.select);
            _history      = FindViewById <Button> (Resource.Id.history);
            _textLayout   = FindViewById <RelativeLayout> (Resource.Id.TitleLayout);
            _buttonLayout = FindViewById <RelativeLayout> (Resource.Id.ButtonLatout);
            _imageLayout  = FindViewById <RelativeLayout> (Resource.Id.ImageLayout);

            _imageLayout.LayoutParameters.Width  = (int)(widthInDp * _FRACTION_WIDTH);
            _buttonLayout.LayoutParameters.Width = (int)(widthInDp * _FRACTION_WIDTH);

            _imageLayout.LayoutParameters.Height  = (int)(heightInDp * _FRACTION_HEIGH);
            _buttonLayout.LayoutParameters.Height = (int)(heightInDp * _FRACTION_HEIGH);

            _textLayout.LayoutParameters.Height = heightInDp - _buttonLayout.LayoutParameters.Height;

            _create.Enabled  = true;
            _join.Enabled    = true;
            _history.Enabled = true;

            _create.Click  += createClick;
            _join.Click    += joinClick;
            _history.Click += historyClick;
        }
示例#3
0
        /// <summary>
        /// Starts the game.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void Start_Game(object sender, EventArgs e)
        {
            if (getBTNumber() - BTManager.Instance.getNumConnected() == 0)
            {
                SetTitle(Resource.String.starting);

                BTManager.Instance.eventLocalMessageReceived -= handleLocalMessage;
                BTManager.Instance.eventPackageReceived      -= handlePackage;

                string [] names = new string[5];
                for (int i = 0; i < 5; ++i)
                {
                    names [i] = _pl [i].Text;
                }

                int dealer = 0;
                for (int i = 0; i < 5; ++i)
                {
                    if (_radioDealer [i].Checked)
                    {
                        dealer = i;
                        break;
                    }
                }

                Intent      inte = new Intent();
                GameProfile gp   = new GameProfile(names, _addr, dealer);

                gp.setIntent(inte);

                SetResult(Result.Ok, inte);

                BTManager.Instance.StopListen();
                Finish();
            }
            else
            {
                Toast.MakeText(this, "Waiting for missing connection", ToastLength.Short).Show();
            }
        }