예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.actStoreViewStack);

            string      incUID    = Intent.GetStringExtra("StackUID");
            Data_Local  dLoc      = new Data_Local();
            Data_Server dServ     = new Data_Server();
            Stack       thisStack = dServ.Stack_Get(incUID);

            if (thisStack == null)
            {
                ShowError();
                return;
            }

            this.Title = String.Format("Store: {0}", thisStack.Title);

            ListView lvWords = FindViewById <ListView>(Resource.Id.storeListWordPairs);

            lvWords.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, thisStack.ListPairs());

            Button btnBuyStack = FindViewById <Button>(Resource.Id.storeBuyStack);

            if (dLoc.Stack_Exists(thisStack.UID))
            {
                btnBuyStack.Text = "You already own this stack!";
            }
            else
            {
                btnBuyStack.Click += (object sender, EventArgs e) =>
                {
                    AlertDialog.Builder alertResult = new AlertDialog.Builder(this);


                    if (thisStack.Price_Points > 0)
                    {
                        if (dServ.Player_Points_Get(Intent.GetStringExtra("Username")) > thisStack.Price_Points)
                        {
                            alertResult.SetTitle("Points or Dollars?");
                            alertResult.SetMessage("Would you like to make this purchase with in-game points or real money?");
                            alertResult.SetPositiveButton("Points", delegate { Purchase_Points(thisStack.UID); });
                            alertResult.SetNegativeButton("Money", delegate { Purchase_Money(thisStack.UID); });
                            alertResult.SetCancelable(true);
                            alertResult.Show();
                        }
                        else
                        {
                            Purchase_Money(thisStack.UID);
                        }
                    }
                    else
                    {
                        Purchase_Free(thisStack.UID);
                    }
                };
            }
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Data_Server dServ = new Data_Server();
            List<string> incLang = dServ.Languages_Get();

            ListAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, incLang.ToArray());

            ListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                Intent intAct = new Intent(this, typeof(actStoreListStacks));
                intAct.PutExtra("Language", ListView.GetItemAtPosition(e.Position).ToString());
                intAct.PutExtras(Intent);   // Include existing info- username, etc.
                StartActivity(intAct);
            };
        }
예제 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Data_Server  dServ      = new Data_Server();
            List <Stack> listStacks = dServ.Stack_GetList(Intent.GetStringExtra("Language"));

            ListStackAdapter fragListStackAdapter = new ListStackAdapter(this, listStacks);

            ListView.Adapter = fragListStackAdapter;

            ListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                Intent intAct = new Intent(this, typeof(actStoreViewStack));
                intAct.PutExtra("StackUID", listStacks[e.Position].UID);
                intAct.PutExtras(Intent);       // Include existing info- username, etc.
                StartActivity(intAct);
            };
        }
예제 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.actLogin);

            Button   btnLogin    = FindViewById <Button>(Resource.Id.btnLogin);
            TextView txtUsername = FindViewById <TextView>(Resource.Id.txtfldUsername);
            TextView txtPassword = FindViewById <TextView>(Resource.Id.txtfldPassword);

            Data_Local dLoc = new Data_Local();

            AlertDialog.Builder alertExisting = new AlertDialog.Builder(this);
            Player thisPlayer = dLoc.Player_Default();

            if (thisPlayer == null)
            {
                alertExisting.SetTitle("No user found");
                alertExisting.SetMessage("No user has logged in on this device. Please create a user.");
                alertExisting.SetPositiveButton("OK", delegate { });
                alertExisting.SetCancelable(false);
                alertExisting.Show();
            }
            else
            {
                alertExisting.SetTitle("Local user found!");
                alertExisting.SetMessage(String.Format("Would you like to continue as {0}?", thisPlayer.Username));
                alertExisting.SetPositiveButton("Yes", delegate
                {
                    Intent intAct = new Intent(this, typeof(actMainMenu));
                    intAct.PutExtra("Username", thisPlayer.Username);
                    StartActivity(intAct);
                });
                alertExisting.SetNegativeButton("No", delegate { });
                alertExisting.Show();
            }

            btnLogin.Click += (object sender, EventArgs e) => {
                Data_Server         srvClass   = new Data_Server();
                bool                loginValid = srvClass.Player_Login(txtUsername.Text, txtPassword.Text);
                AlertDialog.Builder alertLogin = new AlertDialog.Builder(this);

                if (loginValid)
                {
                    alertLogin.SetTitle("Success!");
                    alertLogin.SetMessage("You have been logged in.");
                    alertLogin.SetPositiveButton("OK", delegate
                    {
                        dLoc.Player_Add(new Player(txtUsername.Text));
                        Intent intAct = new Intent(this, typeof(actMainMenu));
                        intAct.PutExtra("Username", txtUsername.Text);
                        StartActivity(intAct);
                    });
                }
                else
                {
                    alertLogin.SetTitle("Error");
                    alertLogin.SetMessage("Error logging in. Please check your login information and ensure you are connected to the internet.");
                    alertLogin.SetPositiveButton("OK", delegate { });
                }
                alertLogin.SetCancelable(false);
                alertLogin.Show();
            };
        }