Beispiel #1
0
        private void btnLogOn_Click(object sender, EventArgs e)
        {
            //Load the list object
            DataSave.LoadObject(ref userData);

            //Ensure The Account Exists
            if (userData.UserExists(txtUsrNamInpt.Text) == true)
            {
                //Get the account
                theUser = userData.GetUser(txtUsrNamInpt.Text);
                if (txtPassInpt.Text == theUser.Password)
                {
                    theUser.Level = 0;
                    theUser.Score = 0;
                    Form Main = new frmMain(ref theUser);
                    Main.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Sorry, " + theUser.Username + ", your password is incorrect, retype it and try again.", "Careful Now!");
                }
            }
            else
            {
                MessageBox.Show("Username is invalid or non-existant, please retype it or create an account.", "(╯°□°)╯ ︵ ┻━┻");
            }
        }
Beispiel #2
0
        private void btnAccCreate_Click(object sender, EventArgs e)
        {
            DataSave.LoadObject(ref userData);
            theUser.Username = txtUsrCreate.Text;
            theUser.Password = txtPassCreate.Text;
            string verifyPass = txtPassVerify.Text;

            //Sets Avatar
            theUser.Avatar = avatarNum;
            //unapropriate password check
            bool hasUpperCase = !theUser.Password.ToLower().Equals(theUser.Password);
            int  passLen      = theUser.Password.Length;

            if (passLen <= 8 || hasUpperCase == false)
            {
                MessageBox.Show("Password is too short or doesn't contain an uppercase letter.");
                theUser.Username = theUser.Password = verifyPass = "";
            }
            else
            {
                //Following checks if passwords match
                if (theUser.Password == verifyPass)
                {
                    if (theUser.Password != "" || verifyPass != "")
                    {
                        //If user exists: add to AllUser and save
                        if (userData.UserExists(theUser.Username) == false)
                        {
                            userData.AddUser(ref theUser);
                            DataSave.SaveObject(userData);
                            Form frmMain = new frmMain(ref theUser);
                            frmMain.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("The User already exists");
                        }
                    }
                    else
                    {
                        MessageBox.Show("You have not entered a password");
                    }
                }
                else
                {
                    MessageBox.Show("The passwords you have entered do not match", "Retype Passwords");
                }
            }
        }
Beispiel #3
0
        private void frmScore_Load(object sender, EventArgs e)
        {
            DataSave.LoadObject(ref users);
            theUser.OverallScore += theUser.Score;
            users.UpdateUser(ref theUser);
            DataSave.SaveObject(users);
            DataSave.LoadObject(ref users);

            string levelOnly = " ";

            if (theUser.Level == 1)
            {
                levelOnly = "(level one)";
                btnLevelChange.Visible = true;
                btnLevelChange.Text    = "Go to Level Two";
            }
            else if (theUser.Level == 2)
            {
                levelOnly = "(level two)";
                btnLevelChange.Visible = true;
                btnLevelChange.Text    = "Go to Level One";
            }
            else
            {
                pnlControls.Location = new Point(620, 380);
            }
            switch (theUser.Avatar)
            {
            case 1: pbbAvatar.Image = ConstantPhysics.Properties.Resources.weirdIssacYankavic; break;

            case 2: pbbAvatar.Image = ConstantPhysics.Properties.Resources.shodinger; break;

            case 3: pbbAvatar.Image = ConstantPhysics.Properties.Resources.billNyeTheFightingGuy; break;

            default: pbbAvatar.Image = ConstantPhysics.Properties.Resources.mainLogo; break;
            }
            lblScore.Text = "Well done, your final Score was: " + theUser.Score + " " + levelOnly;

            //User ranks
            users.SortByScore();
            lsbUsrRank.Items.Insert(0, "Rank \t User \t Overall Score");
            users.userList.Reverse();

            for (int i = 0; i < users.userList.Count; i++)
            {
                lsbUsrRank.Items.Add((i + 1) + "\t" + users.userList[i].Username + "\t" + users.userList[i].OverallScore);
            }
        }