예제 #1
0
파일: PostGame.cs 프로젝트: nubington/bill
        public PostGame(EventHandler callback)
            : base(callback)
        {
            Game1.Game.IsMouseVisible = true;
            Game1.Game.Window.Title = "Congratulations!";
            startTime = DateTime.Now;

            if (!contentLoaded)
            {
                postGameMusic = Content.Load<Song>("postgamemusic");
                mikeTexture = Content.Load<Texture2D>("mikeglasses");
                mrPeanutTexture = Content.Load<Texture2D>("mrpeanut");
                buttonTexture1 = Content.Load<Texture2D>("titlebutton1");
                buttonTexture2 = Content.Load<Texture2D>("titlebutton2");
                bigFont = Content.Load<SpriteFont>("PostGameFont1");
                mediumFont = Content.Load<SpriteFont>("PostGameFont2");
                smallFont = Content.Load<SpriteFont>("PostGameFont3");
                buttonFont = Content.Load<SpriteFont>("TitleFont2");
            }

            pongo = new Rectangle(Graphics.GraphicsDevice.Viewport.Width / 2 - PONGOWIDTH / 2, Graphics.GraphicsDevice.Viewport.Height / 2 - PONGOHEIGHT / 2, PONGOWIDTH, PONGOHEIGHT);
            mrPeanut = new Rectangle(Graphics.GraphicsDevice.Viewport.Width / 2 - MRPEANUTWIDTH / 2, Graphics.GraphicsDevice.Viewport.Height / 2 - MRPEANUTHEIGHT / 2, MRPEANUTWIDTH, MRPEANUTHEIGHT);

            returnButton = new BaseObject(new Rectangle(pongo.X, Graphics.GraphicsDevice.Viewport.Height - RETURNBUTTONHEIGHT - 1, RETURNBUTTONWIDTH, RETURNBUTTONHEIGHT), new Vector2(0, 0));
            returnButton.CenterPoint = new Vector2(pongo.X + pongo.Width * .25f, Graphics.GraphicsDevice.Viewport.Height - returnButton.Height / 2 - 1);
            exitButton = new BaseObject(new Rectangle(pongo.X + pongo.Width - EXITBUTTONWIDTH, Graphics.GraphicsDevice.Viewport.Height - EXITBUTTONHEIGHT - 1, EXITBUTTONWIDTH, EXITBUTTONHEIGHT), new Vector2(0, 0));
            exitButton.CenterPoint = new Vector2(pongo.X + pongo.Width * .75f, Graphics.GraphicsDevice.Viewport.Height - exitButton.Height / 2 - 1);

            //int pongoRightX = pongo.X + pongo.Width;
            int pongoRightX = mrPeanut.X + mrPeanut.Width;
            mike = new BaseObject(new Rectangle(pongoRightX + (Graphics.GraphicsDevice.Viewport.Width - pongoRightX) / 2 - MIKEWIDTH / 2, Graphics.GraphicsDevice.Viewport.Height / 2 - MIKEHEIGHT / 2, MIKEWIDTH, MIKEHEIGHT));
            mike.Texture = mikeTexture;

            congratsSize = bigFont.MeasureString("Congratulations!");
            congratsX = (int)(Graphics.GraphicsDevice.Viewport.Width / 2 - congratsSize.X / 2);
            congratsY = (int)(pongo.Y / 2 - congratsSize.Y / 2);

            Bullet b = new Bullet(BulletType.Peanut, new Vector2(0, 0));
            b.Width = b.Height = (int)(b.Width * 1.5f);
            b.CenterPoint = new Vector2(congratsX - b.Width, congratsY + congratsSize.Y / 2);
            b = new Bullet(BulletType.Peanut, new Vector2(0, 0));
            b.Width = b.Height = (int)(b.Width * 1.5f);
            b.CenterPoint = new Vector2(congratsX + congratsSize.X + b.Width, congratsY + congratsSize.Y / 2);

            accuracyPercent = (int)Math.Round((Stats.PeanutHits / (float)Stats.PeanutShots) * 100);
            if (Stats.PeanutShots == 0)
                accuracyPercent = 0;
            if (accuracyPercent >= 50)
                accuracyMsg = "Your skills are second to none.";
            else if (accuracyPercent >= 25)
                accuracyMsg = "Don't stop believing";
            else
                accuracyMsg = "Go hit a tree with a stick.";

            if (Stats.CarChasePeanutScore >= 100)
                peanutScoreMsg = "You are the chosen one";
            else if (Stats.CarChasePeanutScore >= 90)
                peanutScoreMsg = "IMPECCABLE";
            else if (Stats.CarChasePeanutScore >= 80)
                peanutScoreMsg = "Over 10-12 years of experience";
            else if (Stats.CarChasePeanutScore >= 70)
                peanutScoreMsg = "Looks can always be deceiving";
            else if (Stats.CarChasePeanutScore >= 60)
                peanutScoreMsg = "You've always been a fast learner";
            else if (Stats.CarChasePeanutScore >= 50)
                peanutScoreMsg = "Competing with 3-4 people from your school";
            else
                peanutScoreMsg = "r u dumb?";

            MediaPlayer.Play(postGameMusic);
            MediaPlayer.Volume = .5f;
            MediaPlayer.IsRepeating = true;
        }
예제 #2
0
파일: PostGame.cs 프로젝트: nubington/bill
        void createFallingCans(GameTime gameTime)
        {
            timeSinceLastCanSpawn += (int)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (timeSinceLastCanSpawn >= CANSPAWNDELAY)
            {
                Bullet b = new Bullet(BulletType.Cans[rand.Next(BulletType.Cans.Length)], new Vector2(0, FALLINGCANSPEED));
                b.X = rand.Next(Graphics.GraphicsDevice.Viewport.Width - b.Width);
                b.Y = -b.Height;
                timeSinceLastCanSpawn = 0;
            }
        }
예제 #3
0
파일: Battle1.cs 프로젝트: nubington/bill
        static void updatePotentialCollisions(Bullet object1, List<Bullet> objects)
        {
            if (objects.Count == 0)
                return;

            object1.PotentialCollisions.Clear();

            for (int i = 0; i < objects.Count; i++)
            {
                BaseObject object2 = objects[i];

                if (object2.RightBound < object1.LeftBound)
                    continue;

                if (object2.LeftBound > object1.RightBound)
                    break;

                if (object2.TopBound <= object1.BottomBound &&
                    object2.BottomBound >= object1.TopBound)
                    object1.PotentialCollisions.Add(object2);
            }
        }
예제 #4
0
파일: Character.cs 프로젝트: nubington/bill
        public void shootBullet(BulletType bulletType, Vector2 target, int speed, double rotation, float scale)
        {
            float angle = (float)Math.Atan2((double)(target.Y - CenterPoint.Y), (double)(target.X - CenterPoint.X));

            float moveX = speed * (float)Math.Cos(angle);
            float moveY = speed * (float)Math.Sin(angle);

            Bullet b = new Bullet(bulletType, new Vector2(moveX, moveY));

            b.Y = (int)this.CenterPoint.Y;
            b.X = (int)this.CenterPoint.X + b.Width / 4;

            b.Rotation = (float)rotation;
            b.Width = (int)(b.Width * scale);
            b.Height = (int)(b.Height * scale);
        }
예제 #5
0
파일: Character.cs 프로젝트: nubington/bill
        public void shootBullet(BulletType bulletType, Direction d, int speed, float scale)
        {
            if (!this.hasPowerUp(PowerUpType.DoubleShot))
            {
                Bullet bullet = new Bullet(bulletType, new Vector2());
                bullet.Width = (int)(bullet.Width * scale);
                bullet.Height = (int)(bullet.Height * scale);

                if (d == Direction.North)
                {
                    bullet.X = this.X + this.Width / 2 - bullet.Width / 2;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.South)
                {
                    bullet.X = this.X + this.Width / 2 - bullet.Width / 2;
                    bullet.Y = this.Y + this.Height;
                }
                else if (d == Direction.West)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y + this.Height / 2 - bullet.Height / 2;
                }
                else if (d == Direction.East)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y + this.Height / 2 - bullet.Height / 2;
                }
                else if (d == Direction.NorthEast)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.SouthEast)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y + this.Height;
                }
                else if (d == Direction.NorthWest)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.SouthWest)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y + this.Height;
                }

                bullet.speed.X = speed * d.X;
                bullet.speed.Y = speed * d.Y;
            }
            else
            {
                Bullet bullet1 = new Bullet(bulletType, new Vector2());
                Bullet bullet2 = new Bullet(bulletType, new Vector2());
                bullet1.Width = (int)(bullet1.Width * scale);
                bullet1.Height = (int)(bullet1.Height * scale);
                bullet2.Width = (int)(bullet2.Width * scale);
                bullet2.Height = (int)(bullet2.Height * scale);

                if (d == Direction.North)
                {
                    bullet1.X = this.X + (int)(this.Width * .33f) - bullet1.Width / 2;
                    bullet2.X = this.X + (int)(this.Width * .66f) - bullet2.Width / 2;
                    bullet1.Y = bullet2.Y = this.Y - bullet1.Height;
                }
                else if (d == Direction.South)
                {
                    bullet1.X = this.X + (int)(this.Width * .33f) - bullet1.Width / 2;
                    bullet2.X = this.X + (int)(this.Width * .66f) - bullet2.Width / 2;
                    bullet1.Y = bullet2.Y = this.Y + this.Height;
                }
                else if (d == Direction.West)
                {
                    bullet1.X = bullet2.X = this.X - bullet1.Width;
                    bullet1.Y = this.Y + (int)(this.Height * .33f) - bullet1.Height / 2;
                    bullet2.Y = this.Y + (int)(this.Height * .66f) - bullet1.Height / 2;
                }
                else if (d == Direction.East)
                {
                    bullet1.X = bullet2.X = this.X + this.Width;
                    bullet1.Y = this.Y + (int)(this.Height * .33f) - bullet1.Height / 2;
                    bullet2.Y = this.Y + (int)(this.Height * .66f) - bullet1.Height / 2;
                }
                else if (d == Direction.NorthEast)
                {
                    bullet1.X = this.X + (int)(this.Width * .85f) - bullet1.Width / 2;
                    bullet1.Y = this.Y - bullet1.Height;
                    bullet2.X = this.X + this.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .15f) - bullet2.Height / 2;
                }
                else if (d == Direction.SouthEast)
                {
                    bullet1.X = this.X + (int)(this.Width * .85f) - bullet1.Width / 2;
                    bullet1.Y = this.Y + this.Height;
                    bullet2.X = this.X + this.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .85f) - bullet2.Height / 2;
                }
                else if (d == Direction.NorthWest)
                {
                    bullet1.X = this.X + (int)(this.Width * .15f) - bullet1.Width / 2;
                    bullet1.Y = this.Y - bullet1.Height;
                    bullet2.X = this.X - bullet2.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .15f) - bullet2.Height / 2;
                }
                else if (d == Direction.SouthWest)
                {
                    bullet1.X = this.X + (int)(this.Height * .15f) - bullet1.Width / 2;
                    bullet1.Y = this.Y + this.Height;
                    bullet2.X = this.X - bullet2.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .85f) - bullet2.Height / 2;
                }
                bullet1.speed.X = bullet2.speed.X = speed * d.X;
                bullet1.speed.Y = bullet2.speed.Y = speed * d.Y;
            }
        }
예제 #6
0
파일: Character.cs 프로젝트: nubington/bill
        public void shootBullet(BulletType bulletType, Direction d, int speed, float scale)
        {
            if (!this.hasPowerUp(PowerUpType.DoubleShot))
            {
                Bullet bullet = new Bullet(bulletType, new Vector2());
                bullet.Width  = (int)(bullet.Width * scale);
                bullet.Height = (int)(bullet.Height * scale);

                if (d == Direction.North)
                {
                    bullet.X = this.X + this.Width / 2 - bullet.Width / 2;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.South)
                {
                    bullet.X = this.X + this.Width / 2 - bullet.Width / 2;
                    bullet.Y = this.Y + this.Height;
                }
                else if (d == Direction.West)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y + this.Height / 2 - bullet.Height / 2;
                }
                else if (d == Direction.East)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y + this.Height / 2 - bullet.Height / 2;
                }
                else if (d == Direction.NorthEast)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.SouthEast)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y + this.Height;
                }
                else if (d == Direction.NorthWest)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.SouthWest)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y + this.Height;
                }

                bullet.speed.X = speed * d.X;
                bullet.speed.Y = speed * d.Y;
            }
            else
            {
                Bullet bullet1 = new Bullet(bulletType, new Vector2());
                Bullet bullet2 = new Bullet(bulletType, new Vector2());
                bullet1.Width  = (int)(bullet1.Width * scale);
                bullet1.Height = (int)(bullet1.Height * scale);
                bullet2.Width  = (int)(bullet2.Width * scale);
                bullet2.Height = (int)(bullet2.Height * scale);

                if (d == Direction.North)
                {
                    bullet1.X = this.X + (int)(this.Width * .33f) - bullet1.Width / 2;
                    bullet2.X = this.X + (int)(this.Width * .66f) - bullet2.Width / 2;
                    bullet1.Y = bullet2.Y = this.Y - bullet1.Height;
                }
                else if (d == Direction.South)
                {
                    bullet1.X = this.X + (int)(this.Width * .33f) - bullet1.Width / 2;
                    bullet2.X = this.X + (int)(this.Width * .66f) - bullet2.Width / 2;
                    bullet1.Y = bullet2.Y = this.Y + this.Height;
                }
                else if (d == Direction.West)
                {
                    bullet1.X = bullet2.X = this.X - bullet1.Width;
                    bullet1.Y = this.Y + (int)(this.Height * .33f) - bullet1.Height / 2;
                    bullet2.Y = this.Y + (int)(this.Height * .66f) - bullet1.Height / 2;
                }
                else if (d == Direction.East)
                {
                    bullet1.X = bullet2.X = this.X + this.Width;
                    bullet1.Y = this.Y + (int)(this.Height * .33f) - bullet1.Height / 2;
                    bullet2.Y = this.Y + (int)(this.Height * .66f) - bullet1.Height / 2;
                }
                else if (d == Direction.NorthEast)
                {
                    bullet1.X = this.X + (int)(this.Width * .85f) - bullet1.Width / 2;
                    bullet1.Y = this.Y - bullet1.Height;
                    bullet2.X = this.X + this.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .15f) - bullet2.Height / 2;
                }
                else if (d == Direction.SouthEast)
                {
                    bullet1.X = this.X + (int)(this.Width * .85f) - bullet1.Width / 2;
                    bullet1.Y = this.Y + this.Height;
                    bullet2.X = this.X + this.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .85f) - bullet2.Height / 2;
                }
                else if (d == Direction.NorthWest)
                {
                    bullet1.X = this.X + (int)(this.Width * .15f) - bullet1.Width / 2;
                    bullet1.Y = this.Y - bullet1.Height;
                    bullet2.X = this.X - bullet2.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .15f) - bullet2.Height / 2;
                }
                else if (d == Direction.SouthWest)
                {
                    bullet1.X = this.X + (int)(this.Height * .15f) - bullet1.Width / 2;
                    bullet1.Y = this.Y + this.Height;
                    bullet2.X = this.X - bullet2.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .85f) - bullet2.Height / 2;
                }
                bullet1.speed.X = bullet2.speed.X = speed * d.X;
                bullet1.speed.Y = bullet2.speed.Y = speed * d.Y;
            }
        }