Ejemplo n.º 1
0
 public bool checkCollideWith(GameObject object2)
 {
     return ObjectRectangle.Intersects(object2.ObjectRectangle);
 }
Ejemplo n.º 2
0
        protected override void LoadContent()
        {
            BGM = Content.Load<Song>("Super Mario World Overworld");
            MediaPlayer.Play(BGM);
            MediaPlayer.IsRepeating = true;
            tornadoSE = Content.Load<SoundEffect>("TornadoSE");
            gunShotSE = Content.Load<SoundEffect>("GunShotSE");
            pumpkinCollideSE = Content.Load<SoundEffect>("pumpkinCollideSE");
            chickenCollideSE = Content.Load<SoundEffect>("chickenCollideSE");
            popSE = Content.Load<SoundEffect>("popSE");
            HomerSE = Content.Load<SoundEffect>("HomerSE");
            PeterSE = Content.Load<SoundEffect>("PeterSE");
            bossDieExplosionSE = Content.Load<SoundEffect>("bossDieExplosion");

            spriteBatch = new SpriteBatch(GraphicsDevice);

            whiteTexture2D = Content.Load<Texture2D>("whitePic");   //used to draw collision rectangle
            greenTexture2D = Content.Load<Texture2D>("greenPic");   //used to draw collision rectangle

            winMessage1 = Content.Load<Texture2D>("WinMessage1");
            winMessage2 = Content.Load<Texture2D>("WinMessage2");
            winMessage3 = Content.Load<Texture2D>("WinMessage3");
            loseMessage = Content.Load<Texture2D>("LoseMessage");

            #region Menu && Screens
            Gamestate = GameState.MAIN;

            Main = new GameObject(Content.Load<Texture2D>("MainMenu"), graphics);
            Main.Scale = 1.0f;
            Main.position = new Vector2(640, 360);
            Main.visible = false;

            Control = new GameObject(Content.Load<Texture2D>("Controls"), graphics);
            Control.Scale = 1.0f;
            Control.position = new Vector2(640, 360);
            Control.visible = false;

            End = new GameObject(Content.Load<Texture2D>("End Screen"), graphics);
            End.Scale = 1.0f;
            End.position = new Vector2(640, 360);
            End.visible = false;

            Upgrade = new GameObject(Content.Load<Texture2D>("UpgradeScreen"), graphics);
            Upgrade.Scale = 0.75f;
            Upgrade.position = new Vector2(640, 350);
            Upgrade.visible = false;
            #endregion
            #region Scrolling
            scrolling1 = new Scrolling(Content.Load<Texture2D>("Springfield1"), new Rectangle(0, 0, 1000, 720));
            scrolling2 = new Scrolling(Content.Load<Texture2D>("Springfield2"), new Rectangle(1000, 0, 1000, 720));
            scrolling3 = new Scrolling(Content.Load<Texture2D>("Springfield3"), new Rectangle(2000, 0, 1000, 720));
            #endregion
            #region Players
            Homer1 = new Player(Content.Load<Texture2D>("Homer"), Content.Load<Texture2D>("Bullet"), Content.Load<SpriteFont>("SpriteFont1"), graphics);
            Homer1.bulletScale = 0.75f;
            Peter1 = new Player2(Content.Load<Texture2D>("PeterSpriteSheetFull"), Content.Load<Texture2D>("Bullet"), Content.Load<SpriteFont>("SpriteFont1"), graphics);
            Peter1.bulletScale = 0.75f;
            #endregion
            #region Enemies
            totalNumOfPumpkins = 10;
            pumpkin = new GameObject[totalNumOfPumpkins];
            for (int i = 0; i < totalNumOfPumpkins; i++)
            {
                pumpkin[i] = new GameObject(Content.Load<Texture2D>("Pumpkin"), graphics);
                pumpkin[i].Scale = 0.35f;
                pumpkin[i].position = new Vector2(nextValue = r.Next(800, 2950), nextValue = r.Next(425, 700));
                pumpkin[i].visible = true;
                pumpkin[i].speed = 2f;
            }

            totalNumOfWhiteChickens = 10;
            whiteChicken = new WhiteChicken[totalNumOfWhiteChickens];
            for (int i = 0; i < totalNumOfWhiteChickens; i++)
            {
                whiteChicken[i] = new WhiteChicken(Content.Load<Texture2D>("WhiteChicken"), Content.Load<Texture2D>("HealthBar2"), graphics);
                whiteChicken[i].Scale = 1f;
                whiteChicken[i].position.X = (r.Next(800, 2950));
                whiteChicken[i].position.Y = (r.Next(275, 550));
                whiteChicken[i].spriteVisible = true;
                //whiteChicken[i].speed = 2f;   //by default speed is 2f in WhiteChicken.cs
            }

            ExplodeSprite = new GameObject(Content.Load<Texture2D>("Explode"), graphics);
            ExplodeSprite.visible = false;
            ExplodeSprite.Scale = 0.75f;
            ExplodeSprite.position = new Vector2();

            totalNumOfEggCrackStages = 3;
            BossEgg = new GameObject[totalNumOfEggCrackStages];
            for (int i = 0; i < totalNumOfEggCrackStages; i++)
            {
                BossEgg[i] = new GameObject(Content.Load<Texture2D>("Egg" + i), graphics);
                BossEgg[i].Scale = 1.5f;
                BossEgg[i].position = new Vector2(2850, 550);
                BossEgg[i].visible = false;
                BossEgg[i].speed = 2f;
            }
            EggCrackStage = 0; //will start at stage 0 and cause BossEgg[0].visible = true;

            loopInt = 0;
            Boss = new GiantChicken(Content.Load<Texture2D>("GiantChicken"), Content.Load<Texture2D>("Tornado"), Content.Load<Texture2D>("HealthBar2"), graphics);
            Boss.position.X = 2850;
            Boss.position.Y = 400;
            Boss.spriteVisible = false;

            #endregion
        }