示例#1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            inputHelper.Update();
            SoundEffectHelpers soundEffectHelper = new SoundEffectHelpers();


            //Mouse control
            if (Status == status.menu)
            {
                this.IsMouseVisible = true;
            }
            if (Status == status.running || Status == status.winner)
            {
                this.IsMouseVisible = false;
            }
            //Theme song control
            if (inputHelper.IsNewPress(Keys.M))
            {
                if (themeSongLoop.State == SoundState.Playing)
                {
                    themeSongLoop.Pause();
                }
                else
                {
                    themeSongLoop.Play();
                }
            }
            if (Status == status.running)
            {
                //Spawn powerups cheats

                if (inputHelper.IsNewPress(Keys.F9))
                {
                    powerups.Add(new Sprite(cowTexture, type.cow));
                    soundEffectHelper.playSound(cowSoundEffects);
                }
                if (inputHelper.IsNewPress(Keys.F10))
                {
                    powerups.Add(new Sprite(mjod, type.mjod));
                    soundEffectHelper.playSound(beerSoundEffects);
                }
                if (inputHelper.IsNewPress(Keys.F11))
                {
                    powerups.Add(new Sprite(kottbulle, type.kottbulle));
                    soundEffectHelper.playSound(kottbullarSoundEffects);
                }
                if (inputHelper.IsNewPress(Keys.F12))
                {
                    powerups.Add(new Sprite(bomb, type.bomb));
                    soundEffectHelper.playSound(bombSoundEffects);
                }


                //THE ACTUAL GAME UPDATE STUFF

                //Redbeard move
                if (inputHelper.IsCurPress(Keys.W))
                {
                    redbeard.Move(dir.North);
                }
                if (inputHelper.IsCurPress(Keys.A))
                {
                    redbeard.Move(dir.West);
                }
                if (inputHelper.IsCurPress(Keys.S))
                {
                    redbeard.Move(dir.South);
                }
                if (inputHelper.IsCurPress(Keys.D))
                {
                    redbeard.Move(dir.East);
                }

                //Greybeard Move
                if (inputHelper.IsCurPress(Keys.Up))
                {
                    greybeard.Move(dir.North);
                }
                if (inputHelper.IsCurPress(Keys.Left))
                {
                    greybeard.Move(dir.West);
                }
                if (inputHelper.IsCurPress(Keys.Down))
                {
                    greybeard.Move(dir.South);
                }
                if (inputHelper.IsCurPress(Keys.Right))
                {
                    greybeard.Move(dir.East);
                }

                //Attack Buttons
                //redbeard attack


                if (inputHelper.IsNewPress(Keys.V) && redbeard.hitbox.Intersects(greybeard.hitbox))
                {
                    greybeard.Hurt(redbeard.strenght, greybeardHurt);
                    redbeard.DrawAttack();

                    if (hurtSoundEffect.Next(1, 3) == 1)
                    {
                        soundEffectHelper.playSound(hurtSoundEffects);
                    }
                }

                //greybeard attack
                if (inputHelper.IsNewPress(Keys.NumPad2) && greybeard.hitbox.Intersects(redbeard.hitbox))
                {
                    redbeard.Hurt(greybeard.strenght, redbeardHurt);
                    greybeard.DrawAttack();

                    if (hurtSoundEffect.Next(1, 3) == 1)
                    {
                        soundEffectHelper.playSound(hurtSoundEffects);
                    }
                }

                //end Attcks

                //Display winner
                if (redbeard.health < 0)
                {
                    Winner = winner.greybeard; Status = status.winner; soundEffectHelper.playSound(winSoundEffects);
                }
                if (greybeard.health < 0)
                {
                    Winner = winner.redbeard; Status = status.winner; soundEffectHelper.playSound(winSoundEffects);
                }

                // add powerups
                if (powerups == null || powerups.Count < 10)
                {
                    powerup = powerupNumber.Next(0, 1000);

                    if (powerup < 3)
                    {
                        powerups.Add(new Sprite(cowTexture, type.cow));
                        soundEffectHelper.playSound(cowSoundEffects);
                    }
                    if (powerup > 3 && powerup < 9)
                    {
                        powerups.Add(new Sprite(mjod, type.mjod));
                        soundEffectHelper.playSound(beerSoundEffects);
                    }
                    if (powerup > 9 && powerup < 15)
                    {
                        powerups.Add(new Sprite(kottbulle, type.kottbulle));
                        soundEffectHelper.playSound(kottbullarSoundEffects);
                    }
                    if (powerup == 16)
                    {
                        powerups.Add(new Sprite(bomb, type.bomb));
                        soundEffectHelper.playSound(bombSoundEffects);
                    }
                }

                //pick up powerups
                for (int i = 0; i < powerups.Count; ++i)
                {
                    //greybeard

                    if (inputHelper.IsNewPress(Keys.NumPad2) && greybeard.hitbox.Intersects(powerups[i].hitbox))
                    {
                        //check which powerup and apply effect
                        if (powerups[i].type == type.mjod)
                        {
                            greybeard.strenght += 10;
                        }
                        if (powerups[i].type == type.cow)
                        {
                            greybeard.speedBoost     += 3;
                            greybeard.speedBoostTimer = 0;
                        }
                        if (powerups[i].type == type.kottbulle)
                        {
                            greybeard.health += 100;
                        }
                        if (powerups[i].type == type.bomb)
                        {
                            timer = 0;
                        }
                        //remove powerup
                        powerups.Remove(powerups[i]); i = 0;
                    }

                    //redbeard
                    if (inputHelper.IsNewPress(Keys.V) && redbeard.hitbox.Intersects(powerups[i].hitbox))
                    {
                        //check which powerup and apply effect
                        if (powerups[i].type == type.mjod)
                        {
                            redbeard.strenght += 10;
                        }
                        if (powerups[i].type == type.cow)
                        {
                            redbeard.speedBoost     += 3;
                            redbeard.speedBoostTimer = 0;
                        }
                        if (powerups[i].type == type.kottbulle)
                        {
                            redbeard.health += 100;
                        }
                        if (powerups[i].type == type.bomb)
                        {
                            timer = 0;
                        }

                        //remove powerup
                        powerups.Remove(powerups[i]); i = 0;
                    }

                    if (timer < 2001)
                    {
                        timer++;
                    }

                    if (timer == 2000)
                    {
                        kalle.X = powerups[i].hitbox.X - 128;
                        kalle.Y = powerups[i].hitbox.Y - 128;

                        if (greybeard.hitbox.Intersects(kalle))
                        {
                            greybeard.Hurt(100, greybeardHurt);
                        }
                        if (redbeard.hitbox.Intersects(kalle))
                        {
                            redbeard.Hurt(100, redbeardHurt);
                        }

                        kalle.X = -1000;
                        kalle.Y = -1000;
                    }
                }    //end powerups

                // Allows the game to exit
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                {
                    this.Exit();
                }

                if (inputHelper.IsNewPress(Keys.Escape))
                {
                    Status = status.menu;
                }
            }     //End if running

            //menu
            if (Status == status.menu)
            {
                if (MenuSelected == menuSelected.play)
                {
                    if (inputHelper.IsNewPress(Keys.Enter))
                    {
                        Status = status.running;
                    }
                    if (inputHelper.IsNewPress(Keys.Down))
                    {
                        MenuSelected += 1;
                    }

                    if (inputHelper.IsNewPress(Keys.Up))
                    {
                        MenuSelected += 2;
                    }
                }

                else if (MenuSelected == menuSelected.restart)
                {
                    if (inputHelper.IsNewPress(Keys.Enter))
                    {
                        Status = status.running; greybeard.Reset(1052, 300); redbeard.Reset(100, 300); powerups.Clear();
                    }
                    if (inputHelper.IsNewPress(Keys.Up))
                    {
                        MenuSelected -= 1;
                    }
                    if (inputHelper.IsNewPress(Keys.Down))
                    {
                        MenuSelected += 1;
                    }
                }

                else if (MenuSelected == menuSelected.exit)
                {
                    if (inputHelper.IsNewPress(Keys.Enter))
                    {
                        this.Exit();
                    }
                    if (inputHelper.IsNewPress(Keys.Up))
                    {
                        MenuSelected -= 1;
                    }
                    if (inputHelper.IsNewPress(Keys.Down))
                    {
                        MenuSelected -= 2;
                    }
                }

                //Musgrejor
                MouseState mouseState = Mouse.GetState();
                if (mouseState.LeftButton == ButtonState.Pressed && new Rectangle(mouseState.X, mouseState.Y, 10, 10).Intersects(new Rectangle(490, 300, 300, 100)))
                {
                    Status = status.running;
                }
                if (mouseState.LeftButton == ButtonState.Pressed && new Rectangle(mouseState.X, mouseState.Y, 10, 10).Intersects(new Rectangle(490, 400, 300, 100)))
                {
                    Status = status.running; greybeard.Reset(1052, 300); redbeard.Reset(100, 300); greybeard.Retexture(greybeardWest1); redbeard.Retexture(redbeardEast1);
                }
                if (mouseState.LeftButton == ButtonState.Pressed && new Rectangle(mouseState.X, mouseState.Y, 10, 10).Intersects(new Rectangle(490, 500, 300, 100)))
                {
                    this.Exit();
                }
            }     //End menu

            if (Status == status.winner)
            {
                if (inputHelper.IsNewPress(Keys.Enter))
                {
                    Status = status.menu; greybeard.Reset(1052, 300); redbeard.Reset(100, 300); powerups.Clear();
                }
            }

            // TODO: Add your update logic here
            inputHelper.Update();
            base.Update(gameTime);
        }
示例#2
0
        private void btnpro_Click(object sender, EventArgs e)
        {
            Utilities winner = new Utilities();

            if (!(winner.Getgpacount(this.employeeID) == 1))
            {
                if (!(winner.Getsemgpacount(this.employeeID) == 1))
                {
                    if (!(winner.Getstatuscount(this.employeeID) == 1))
                    {
                        if (!(winner.Getgendercount(this.employeeID) == 1))
                        {
                            DBConnect    payrollReportConn = new DBConnect();
                            MySqlCommand payrollReportCmd  = new MySqlCommand(@"SELECT studentID, firstname, lastname, emailaddress FROM dbo.registrar_office_db
                                                               where status='Junior' AND  semgpa = (SELECT MAX(semgpa) from registrar_office_db where gpa= (select max(gpa) from registrar_office_db  where studentID IN(SELECT studentID from applicant_data_store where stat ='elegible')))order by dateofbirth desc 
                                                                limit 0,1");

                            // connect to database
                            DBConnect UserProfileConn = new DBConnect();

                            //Create a data reader and Execute the command
                            MySqlDataReader dataReader = UserProfileConn.ExecuteReader(payrollReportCmd);

                            //Read the data and store them in the list
                            while (dataReader.Read())
                            {
                                email     = dataReader["emailaddress"].ToString();
                                studentID = Convert.ToInt32(dataReader["studentID"]);
                                name      = dataReader["firstname"].ToString() + " " + dataReader["lastname"].ToString();
                            }

                            //close Data Reader

                            dataReader.Close();
                            MySqlCommand cmd = new MySqlCommand(@"INSERT INTO dbo.vote_participants (name, studentID, email) VALUES  (@name, @studentID, @email);");
                            cmd.Parameters.Add("@name", MySqlDbType.VarChar, 45).Value  = name;
                            cmd.Parameters.Add("@email", MySqlDbType.VarChar, 45).Value = email;
                            cmd.Parameters.Add("@studentID", MySqlDbType.Int32).Value   = studentID;

                            // connect to database
                            DBConnect userCreationConn = new DBConnect();

                            // execute statement
                            if (userCreationConn.NonQuery(cmd) > 0)
                            {
                            }
                            else
                            {
                                lblerror.Text = "Error creating account";
                            }
                            winner studentwin = new winner
                            {
                                note       = " Get elected for interviewe",
                                namew      = name,
                                studentIDw = studentID,
                                emailw     = email
                            };
                            DBConnect    secondConn = new DBConnect();
                            MySqlCommand secondCmd  = new MySqlCommand(@"
                                                                                    SELECT studentID, firstname, lastname, emailaddress FROM dbo.registrar_office_db
                                                               where status='Junior' AND  semgpa = (SELECT MAX(semgpa) from registrar_office_db where gpa= (select max(gpa) from registrar_office_db  where studentID IN(SELECT studentID from applicant_data_store where stat ='elegible')))order by dateofbirth desc 
                                                                limit 1,1");

                            // connect to database
                            DBConnect secondConn2 = new DBConnect();

                            //Create a data reader and Execute the command
                            MySqlDataReader dataReader2 = secondConn.ExecuteReader(secondCmd);

                            //Read the data and store them in the list
                            while (dataReader2.Read())
                            {
                                note2      = " Get elected for interviewe";
                                email2     = dataReader2["emailaddress"].ToString();
                                studentID2 = Convert.ToInt32(dataReader2["studentID"]);
                                name2      = dataReader2["firstname"].ToString() + " " + dataReader2["lastname"].ToString();
                            }

                            dataReader.Close();
                            MySqlCommand cmd2 = new MySqlCommand(@"INSERT INTO dbo.vote_participants (name, studentID, email) VALUES (@name, @studentID, @email);");
                            cmd2.Parameters.Add("@name", MySqlDbType.VarChar, 45).Value  = name2;
                            cmd2.Parameters.Add("@email", MySqlDbType.VarChar, 45).Value = email2;
                            cmd2.Parameters.Add("@studentID", MySqlDbType.Int32).Value   = studentID2;

                            DBConnect userCreationConn2 = new DBConnect();

                            // execute statement
                            if (userCreationConn2.NonQuery(cmd2) > 0)
                            {
                            }
                            else
                            {
                                lblerror.Text = "Error creating account";
                            }

                            studentwin.note2       = " Get elected for interviewe";
                            studentwin.namew2      = name2;
                            studentwin.studentIDw2 = studentID2;
                            studentwin.emailw2     = email2;

                            string    JsonOutput = JsonConvert.SerializeObject(studentwin);
                            Utilities create     = new Utilities();
                            create.writeFile2(JsonOutput);
                            create.writexmlFile2();
                            DataSet xmlfile = new DataSet();
                            xmlfile.ReadXml("C://Users//husse//Downloads//xmlfile2.xml");
                            topic = "Scholarship Interviewe";
                            body  = name + " you was selected for scholarship interviewe in January 02, 2021" + "\n" +
                                    "Thank You";
                            body2 = name2 + " you was selected for scholarship interviewe in January 02, 2021" + "\n" +
                                    "Thank You";
                            datagrilview.DataSource = xmlfile.Tables[0];
                            create.sendemail(email, name, topic, body);
                            create.sendemail(email2, name2, topic, body2);
                        }
                        else
                        {
                            DBConnect    payrollReportConn = new DBConnect();
                            MySqlCommand payrollReportCmd  = new MySqlCommand(@"SELECT studentID, firstname, lastname, emailaddress FROM dbo.registrar_office_db
                                                               where status='Junior' AND gender='Female' AND semgpa = (SELECT MAX(semgpa) from registrar_office_db where gpa= (select max(gpa) from registrar_office_db  where studentID IN(SELECT studentID from applicant_data_store where stat ='elegible')))");

                            // connect to database
                            DBConnect UserProfileConn = new DBConnect();

                            //Create a data reader and Execute the command
                            MySqlDataReader dataReader = UserProfileConn.ExecuteReader(payrollReportCmd);

                            //Read the data and store them in the list
                            while (dataReader.Read())
                            {
                                email     = dataReader["emailaddress"].ToString();
                                studentID = Convert.ToInt32(dataReader["studentID"]);
                                name      = dataReader["firstname"].ToString() + " " + dataReader["lastname"].ToString();
                            }

                            //close Data Reader

                            dataReader.Close();
                            winner studentwin = new winner
                            {
                                note       = "The winner is: \n",
                                namew      = name,
                                studentIDw = studentID,
                                emailw     = email
                            };
                            string    JsonOutput = JsonConvert.SerializeObject(studentwin);
                            Utilities create     = new Utilities();
                            create.writeFile(JsonOutput);
                            create.writexmlFile();
                            DataSet xmlfile = new DataSet();
                            xmlfile.ReadXml("C://Users//husse//Downloads//xmlfile2.xml");
                            topic = "Scholarship Result";
                            body  = name + " You are the winner for 2020-2021 scholarship" + "\n" +
                                    "Thank You";
                            datagrilview.DataSource = xmlfile.Tables[0];
                            create.sendemail(email, name, topic, body);
                        }
                    }
                    else
                    {
                        DBConnect    payrollReportConn = new DBConnect();
                        MySqlCommand payrollReportCmd  = new MySqlCommand(@"SELECT studentID, firstname, lastname, emailaddress FROM dbo.registrar_office_db
                                                               where status='Junior' AND semgpa = (SELECT MAX(semgpa) from registrar_office_db where gpa= (select max(gpa) from registrar_office_db  where studentID IN(SELECT studentID from applicant_data_store where stat ='elegible')))");

                        // connect to database
                        DBConnect UserProfileConn = new DBConnect();

                        //Create a data reader and Execute the command
                        MySqlDataReader dataReader = UserProfileConn.ExecuteReader(payrollReportCmd);

                        //Read the data and store them in the list
                        while (dataReader.Read())
                        {
                            email     = dataReader["emailaddress"].ToString();
                            studentID = Convert.ToInt32(dataReader["studentID"]);
                            name      = dataReader["firstname"].ToString() + " " + dataReader["lastname"].ToString();
                        }

                        //close Data Reader

                        dataReader.Close();
                        winner studentwin = new winner
                        {
                            note       = "The winner is: \n",
                            namew      = name,
                            studentIDw = studentID,
                            emailw     = email
                        };
                        string    JsonOutput = JsonConvert.SerializeObject(studentwin);
                        Utilities create     = new Utilities();
                        create.writeFile(JsonOutput);
                        create.writexmlFile();
                        DataSet xmlfile = new DataSet();
                        xmlfile.ReadXml("C://Users//husse//Downloads//xmlfile2.xml");
                        topic = "Scholarship Result";
                        body  = name + " You are the winner for 2020-2021 scholarship" + "\n" +
                                "Thank You";
                        datagrilview.DataSource = xmlfile.Tables[0];
                        create.sendemail(email, name, topic, body);
                    }
                }
                else
                {
                    DBConnect    payrollReportConn = new DBConnect();
                    MySqlCommand payrollReportCmd  = new MySqlCommand(@"SELECT studentID, firstname, lastname, emailaddress FROM dbo.registrar_office_db
                                                                               where  semgpa = (SELECT MAX(semgpa) from registrar_office_db where gpa= (select max(gpa) from registrar_office_db  where studentID IN(SELECT studentID from applicant_data_store where stat ='elegible')))");

                    // connect to database
                    DBConnect UserProfileConn = new DBConnect();

                    //Create a data reader and Execute the command
                    MySqlDataReader dataReader = UserProfileConn.ExecuteReader(payrollReportCmd);

                    //Read the data and store them in the list
                    while (dataReader.Read())
                    {
                        email     = dataReader["emailaddress"].ToString();
                        studentID = Convert.ToInt32(dataReader["studentID"]);
                        name      = dataReader["firstname"].ToString() + " " + dataReader["lastname"].ToString();
                    }

                    //close Data Reader

                    dataReader.Close();
                    winner studentwin = new winner
                    {
                        note       = "The winner is: \n",
                        namew      = name,
                        studentIDw = studentID,
                        emailw     = email
                    };
                    string    JsonOutput = JsonConvert.SerializeObject(studentwin);
                    Utilities create     = new Utilities();
                    create.writeFile(JsonOutput);
                    create.writexmlFile();
                    DataSet xmlfile = new DataSet();
                    xmlfile.ReadXml("C://Users//husse//Downloads//xmlfile2.xml");
                    topic = "Scholarship Result";
                    body  = name + " You are the winner for 2020-2021 scholarship" + "\n" +
                            "Thank You";
                    datagrilview.DataSource = xmlfile.Tables[0];
                    create.sendemail(email, name, topic, body);
                }
            }
            else
            {
                DBConnect    payrollReportConn = new DBConnect();
                MySqlCommand payrollReportCmd  = new MySqlCommand(@"SELECT studentID, firstname, lastname, emailaddress FROM dbo.registrar_office_db
                                                               where gpa= (select max(gpa) from registrar_office_db where studentID IN(SELECT studentID from applicant_data_store where stat ='elegible'))");

                // connect to database
                DBConnect UserProfileConn = new DBConnect();

                //Create a data reader and Execute the command
                MySqlDataReader dataReader = UserProfileConn.ExecuteReader(payrollReportCmd);

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    email     = dataReader["emailaddress"].ToString();
                    studentID = Convert.ToInt32(dataReader["studentID"]);
                    name      = dataReader["firstname"].ToString() + " " + dataReader["lastname"].ToString();
                }

                //close Data Reader

                dataReader.Close();
                winner studentwin = new winner
                {
                    note       = "The winner is: \n",
                    namew      = name,
                    studentIDw = studentID,
                    emailw     = email
                };
                string    JsonOutput = JsonConvert.SerializeObject(studentwin);
                Utilities create     = new Utilities();
                create.writeFile(JsonOutput);
                create.writexmlFile();
                DataSet xmlfile = new DataSet();
                xmlfile.ReadXml("C://Users//husse//Downloads//xmlfile2.xml");
                topic = "Scholarship Result";
                body  = name + " You are the winner for 2020-2021 scholarship" + "\n" +
                        "Thank You";
                datagrilview.DataSource = xmlfile.Tables[0];
                create.sendemail(email, name, topic, body);
            }
        }
示例#3
0
    private void DetermineWinner()
    {
        finalPointsChar = new List <PlayerManager>();
        finalPointsChar.Add(GameManager.self.vampireManager);
        finalPointsChar.Add(GameManager.self.frankManager);
        finalPointsChar.Add(GameManager.self.coboltManager);
        finalPointsChar.Add(GameManager.self.princessManager);

        //float minPoints = Mathf.Min(finalPointsChar[0], Mathf.Min(finalPointsChar[1], Mathf.Min(finalPointsChar[2], finalPointsChar[3])));

        //first
        float minPoints = finalPointsChar[0].points;

        first = finalPointsChar[0];
        for (int i = 0; i < finalPointsChar.Count; i++)
        {
            if (minPoints <= finalPointsChar[i].points)
            {
                minPoints = finalPointsChar[i].points;
                first     = finalPointsChar[i];
            }
        }
        finalPointsChar.Remove(first);

        //second
        minPoints = finalPointsChar[0].points;
        second    = finalPointsChar[0];
        for (int i = 0; i < finalPointsChar.Count; i++)
        {
            if (minPoints <= finalPointsChar[i].points)
            {
                minPoints = finalPointsChar[i].points;
                second    = finalPointsChar[i];
            }
        }
        finalPointsChar.Remove(second);

        //third
        minPoints = finalPointsChar[0].points;
        third     = finalPointsChar[0];
        for (int i = 0; i < finalPointsChar.Count; i++)
        {
            if (minPoints <= finalPointsChar[i].points)
            {
                minPoints = finalPointsChar[i].points;
                third     = finalPointsChar[i];
            }
        }
        finalPointsChar.Remove(third);

        //
        forth = finalPointsChar[0];

        if (first == GameManager.self.vampireManager)
        {
            firstWinner = winner.VAMP;//characters[0].position = podestPositions[0].position;
        }
        else if (first == GameManager.self.princessManager)
        {
            firstWinner = winner.PRINCESS;//characters[1].position = podestPositions[0].position;
        }
        else if (first == GameManager.self.frankManager)
        {
            firstWinner = winner.FRANK;//characters[2].position = podestPositions[0].position;
        }
        else if (first == GameManager.self.coboltManager)
        {
            firstWinner = winner.COBOLT;//characters[3].position = podestPositions[0].position;
        }
        if (second == GameManager.self.vampireManager)
        {
            secondWinner = winner.VAMP;//coboltManagercharacters[0].position = podestPositions[1].position;
        }
        else if (second == GameManager.self.princessManager)
        {
            secondWinner = winner.PRINCESS;//characters[1].position = podestPositions[1].position;
        }
        else if (second == GameManager.self.frankManager)
        {
            secondWinner = winner.FRANK;//characters[2].position = podestPositions[1].position;
        }
        else if (second == GameManager.self.coboltManager)
        {
            secondWinner = winner.COBOLT;//characters[3].position = podestPositions[1].position;
        }
        if (third == GameManager.self.vampireManager)
        {
            thirdWinner = winner.VAMP;//characters[0].position = podestPositions[2].position;
        }
        else if (third == GameManager.self.princessManager)
        {
            thirdWinner = winner.PRINCESS;//characters[1].position = podestPositions[2].position;
        }
        else if (third == GameManager.self.frankManager)
        {
            thirdWinner = winner.FRANK;//characters[2].position = podestPositions[2].position;
        }
        else if (third == GameManager.self.coboltManager)
        {
            thirdWinner = winner.COBOLT;//characters[3].position = podestPositions[2].position;
        }
        if (forth == GameManager.self.vampireManager)
        {
            forthWinner = winner.VAMP;//characters[0].position = podestPositions[3].position;
        }
        else if (forth == GameManager.self.princessManager)
        {
            forthWinner = winner.PRINCESS;//characters[1].position = podestPositions[3].position;
        }
        else if (forth == GameManager.self.frankManager)
        {
            forthWinner = winner.FRANK;//characters[2].position = podestPositions[3].position;
        }
        else if (forth == GameManager.self.coboltManager)
        {
            forthWinner = winner.COBOLT;//characters[3].position = podestPositions[3].position;
        }
        SceneManager.LoadScene(3);
    }
示例#4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            inputHelper.Update();

            //Mouse control
            if (Status == status.menu)
            {
                this.IsMouseVisible = true;
            }
            if (Status == status.running || Status == status.winner)
            {
                this.IsMouseVisible = false;
            }

            if (Status == status.running)
            {
                //THE ACTUAL GAME UPDATE STUFF

                //Redbeard move
                if (inputHelper.IsCurPress(Keys.W))
                {
                    redbeard.Move(dir.North);
                }
                if (inputHelper.IsCurPress(Keys.A))
                {
                    redbeard.Move(dir.West); redbeard.Retexture(redbeardWest1);
                }
                if (inputHelper.IsCurPress(Keys.S))
                {
                    redbeard.Move(dir.South);
                }
                if (inputHelper.IsCurPress(Keys.D))
                {
                    redbeard.Move(dir.East); redbeard.Retexture(redbeardEast1);
                }

                //Greybeard Move
                if (inputHelper.IsCurPress(Keys.Up))
                {
                    greybeard.Move(dir.North);
                }
                if (inputHelper.IsCurPress(Keys.Left))
                {
                    greybeard.Move(dir.West); greybeard.Retexture(greybeardWest1);
                }
                if (inputHelper.IsCurPress(Keys.Down))
                {
                    greybeard.Move(dir.South);
                }
                if (inputHelper.IsCurPress(Keys.Right))
                {
                    greybeard.Move(dir.East); greybeard.Retexture(greybeardEast1);
                }

                //Attack Buttons
                //redbeard attack
                if (inputHelper.IsNewPress(Keys.V) && redbeard.hitbox.Intersects(greybeard.hitbox))
                {
                    greybeard.Hurt(redbeard.strenght, hurt);
                    redbeard.DrawAttack();
                }

                //greybeard attack
                if (inputHelper.IsNewPress(Keys.NumPad2) && greybeard.hitbox.Intersects(redbeard.hitbox))
                {
                    redbeard.Hurt(greybeard.strenght, hurt);
                    greybeard.DrawAttack();
                }

                //end Attcks

                //Display winner
                if (redbeard.health < 0)
                {
                    Winner = winner.greybeard; Status = status.winner;
                }
                if (greybeard.health < 0)
                {
                    Winner = winner.redbeard; Status = status.winner;
                }

                // add powerups
                if (powerups == null || powerups.Count < 10)
                {
                    powerup = powerupNumber.Next(0, 5);

                    if (powerup == 0)
                    {
                        powerups.Add(new Sprite(cowTexture, type.cow));
                    }
                    if (powerup == 1)
                    {
                        powerups.Add(new Sprite(mjod, type.mjod));
                    }
                    if (powerup == 2)
                    {
                        powerups.Add(new Sprite(kottbulle, type.kottbulle));
                    }
                }

                //pick up powerups
                for (int i = 0; i < powerups.Count; ++i)
                {
                    //greybeard
                    if (inputHelper.IsNewPress(Keys.NumPad2) && greybeard.hitbox.Intersects(powerups[i].hitbox))
                    {
                        //check which powerup and apply effect
                        if (powerups[i].type == type.mjod)
                        {
                            greybeard.strenght += 60;
                        }
                        if (powerups[i].type == type.cow)
                        {
                            greybeard.speed += 2;
                        }
                        if (powerups[i].type == type.kottbulle)
                        {
                            greybeard.health += 60;
                        }
                        //remove powerup
                        powerups.Remove(powerups[i]); i = 0;
                    }

                    //redbeard
                    if (inputHelper.IsNewPress(Keys.V) && redbeard.hitbox.Intersects(powerups[i].hitbox))
                    {
                        //check which powerup and apply effect
                        if (powerups[i].type == type.mjod)
                        {
                            redbeard.strenght += 60;
                        }
                        if (powerups[i].type == type.cow)
                        {
                            redbeard.speed += 2;
                        }
                        if (powerups[i].type == type.kottbulle)
                        {
                            redbeard.strenght += 60;
                        }

                        //remove powerup
                        powerups.Remove(powerups[i]); i = 0;
                    }
                }//end powerups

                // Allows the game to exit
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                {
                    this.Exit();
                }

                if (inputHelper.IsNewPress(Keys.Escape))
                {
                    Status = status.menu;
                }
            } //End if running

            //menu
            if (Status == status.menu)
            {
                if (MenuSelected == menuSelected.play)
                {
                    if (inputHelper.IsNewPress(Keys.Enter))
                    {
                        Status = status.running;
                    }
                    if (inputHelper.IsNewPress(Keys.Down))
                    {
                        MenuSelected += 1;
                    }

                    if (inputHelper.IsNewPress(Keys.Up))
                    {
                        MenuSelected += 2;
                    }
                }

                else if (MenuSelected == menuSelected.restart)
                {
                    if (inputHelper.IsNewPress(Keys.Enter))
                    {
                        Status = status.running; greybeard.Reset(1052, 300); redbeard.Reset(100, 300); powerups.Clear();
                    }
                    if (inputHelper.IsNewPress(Keys.Up))
                    {
                        MenuSelected -= 1;
                    }
                    if (inputHelper.IsNewPress(Keys.Down))
                    {
                        MenuSelected += 1;
                    }
                }

                else if (MenuSelected == menuSelected.exit)
                {
                    if (inputHelper.IsNewPress(Keys.Enter))
                    {
                        this.Exit();
                    }
                    if (inputHelper.IsNewPress(Keys.Up))
                    {
                        MenuSelected -= 1;
                    }
                    if (inputHelper.IsNewPress(Keys.Down))
                    {
                        MenuSelected -= 2;
                    }
                }

                //Musgrejor
                MouseState mouseState = Mouse.GetState();
                if (mouseState.LeftButton == ButtonState.Pressed && new Rectangle(mouseState.X, mouseState.Y, 10, 10).Intersects(new Rectangle(490, 300, 300, 100)))
                {
                    Status = status.running;
                }
                if (mouseState.LeftButton == ButtonState.Pressed && new Rectangle(mouseState.X, mouseState.Y, 10, 10).Intersects(new Rectangle(490, 400, 300, 100)))
                {
                    Status = status.running; greybeard.Reset(1052, 300); redbeard.Reset(100, 300); greybeard.Retexture(greybeardWest1); redbeard.Retexture(redbeardEast1);
                }
                if (mouseState.LeftButton == ButtonState.Pressed && new Rectangle(mouseState.X, mouseState.Y, 10, 10).Intersects(new Rectangle(490, 500, 300, 100)))
                {
                    this.Exit();
                }
            } //End menu

            if (Status == status.winner)
            {
                if (inputHelper.IsNewPress(Keys.Enter))
                {
                    Status = status.menu; greybeard.Reset(1052, 300); redbeard.Reset(100, 300); powerups.Clear();
                }
            }

            // TODO: Add your update logic here
            inputHelper.Update();
            base.Update(gameTime);
        }
示例#5
0
文件: Elo.cs 项目: smacken/EloSwiss
 => Score(ratingA, ratingB, winner == Winner.Player1 ? 1 : 0, winner == Winner.Player2 ? 1 : 0, kFactor: kFactor);