Exemplo n.º 1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load sprite font
            MenuFont = Content.Load<SpriteFont>("MenuFont");
            MenuTitleFont = Content.Load<SpriteFont>("MenuTitleFont");
            SpriteFont DialogFont = Content.Load<SpriteFont>("DialogFont");

            // Load MenuBackground
            MenuBackground = Content.Load<Texture2D>("MenuBackground");

            // Load sound effects
            HelloKittyTheme = Content.Load<SoundEffect>("HelloKittyTheme");
            HellMarch = Content.Load<SoundEffect>("HellMarch");

            // Initialize the different levels used
            Island1 = new Level(Content.Load<Texture2D>("bg1"), Content.Load<Texture2D>("bg1_collision"), new Vector2(1200, 370), 1);
            Island1House = new Level(Content.Load<Texture2D>("mamahouse"), Content.Load<Texture2D>("mamahouse_collision"), new Vector2(590, 500), 3);

            Island2 = new Level(Content.Load<Texture2D>("bg2"), Content.Load<Texture2D>("bg2_collision"), new Vector2(50, 330), 2);
            Island2House = new Level(Content.Load<Texture2D>("papahouse"), Content.Load<Texture2D>("papahouse_collision"), new Vector2(550, 500), 3);

            Island3 = new Level(Content.Load<Texture2D>("bg3"), Content.Load<Texture2D>("bg3_collision"), new Vector2(378, 150), 0);
            Island3House = new Level(Content.Load<Texture2D>("mimmihouse"), Content.Load<Texture2D>("mimmihouse_collision"), new Vector2(575, 530), 3);

            ActiveLevel = Island1;

            // Load the sprite and player
            Sprite playerSprite = new Sprite(Content.Load<Texture2D>("charsheet"), 58, 73, 1f);

            Player = new Player(playerSprite);

            // Load the NPCs
            Mama = new Npc(Content.Load<Texture2D>("Mama"), new Vector2(590, 225));
            Papa = new Npc(Content.Load<Texture2D>("Papa"), new Vector2(400, 230));
            Mimmy = new Npc(Content.Load<Texture2D>("Mimmy"), new Vector2(420, 260));

            // DialogTexture
            Texture2D DialogBoxTexture = Content.Load<Texture2D>("blank");

            // Give NPCs Dialog text
            Mama.Dialog(DialogBoxTexture, DialogFont, "I dont know where Mimmy is, cross the bridge and ask Papa.", new Vector2(570, 65));
            Papa.Dialog(DialogBoxTexture, DialogFont, "Mimmy is in the house south of Mama.", new Vector2(380, 70));
            Mimmy.Dialog(DialogBoxTexture, DialogFont, "I am your Mimmy!", new Vector2(400, 110));
        }
Exemplo n.º 2
0
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (ExitGame)
                this.Exit();

            float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            InputHandler.Instance.Update();

            SoundEffectInstance HellMarchInstance = HellMarch.CreateInstance();
            SoundEffectInstance HelloKittyThemeInstance = HelloKittyTheme.CreateInstance();

            if (gamestate == GameStates.Running)
            {
                HelloKittyThemeInstance.Stop();
                IsMenuMusicPlaying = false;

                // Play gameplay music
                if (!IsGameplayMusicPlaying)
                {
                    HellMarchInstance.IsLooped = true;
                    HellMarchInstance.Play();
                    IsGameplayMusicPlaying = true;
                }

                // Pauses game if abort key is pressed, runs the pauseMenu update
                if (InputHandler.Instance.IsAbortPressed())
                    IsPaused = true;

                if (IsPaused)
                    pauseMenu.Update();

                else
                {
                    // Runs the Player Update method
                    Player.Update(deltaTime, ActiveLevel.Collision);

                    // Runs NPC update if there is an active NPC
                    if (ActiveNpc != null)
                        ActiveNpc.Update(Player);

                    if (ActiveLevel == Island1)
                    {
                        // If the player is on the bridge, go to next level
                        if (IslandOneBridge.Contains((int)Player.Position.X, (int)Player.Position.Y))
                        {
                            ActiveLevel = Island2;
                            Player.Position = ActiveLevel.StartPosition;
                            Player.Sprite.AnimationId = ActiveLevel.StartAnimation;
                        }
                        if (IslandOneSouth.Contains((int)Player.Position.X, (int)Player.Position.Y))
                        {
                            ActiveLevel = Island3;
                            Player.Position = ActiveLevel.StartPosition;
                            Player.Sprite.AnimationId = ActiveLevel.StartAnimation;
                        }
                        if (IslandOneHouse.Contains((int)Player.Position.X, (int)Player.Position.Y))
                        {
                            ActiveLevel = Island1House;
                            Player.Position = ActiveLevel.StartPosition;
                            Player.Sprite.AnimationId = ActiveLevel.StartAnimation;
                        }
                    }

                    if (ActiveLevel == Island1House)
                    {
                        ActiveNpc = Mama;
                        if (Mama.IsDialogActive)
                            HasEnteredHouseOne = true;

                        if (HouseOne.Contains((int)Player.Position.X, (int)Player.Position.Y))
                        {
                            ActiveLevel = Island1;
                            Player.Position = new Vector2(145, 500);
                            Player.Sprite.AnimationId = 0;
                            ActiveNpc = null;
                        }
                    }

                    if (ActiveLevel == Island2)
                    {
                        if (IslandTwoBridge.Contains((int)Player.Position.X, (int)Player.Position.Y))
                        {
                            ActiveLevel = Island1;
                            Player.Position = ActiveLevel.StartPosition;
                            Player.Sprite.AnimationId = ActiveLevel.StartAnimation;
                        }
                        if (IslandTwoHouse.Contains((int)Player.Position.X, (int)Player.Position.Y)
                            && HasEnteredHouseOne)
                        {
                            ActiveLevel = Island2House;
                            Player.Position = ActiveLevel.StartPosition;
                            Player.Sprite.AnimationId = ActiveLevel.StartAnimation;
                        }
                    }

                    if (ActiveLevel == Island2House)
                    {
                        ActiveNpc = Papa;
                        if (Papa.IsDialogActive)
                            HasEnteredHouseTwo = true;

                        if (HouseTwo.Contains((int)Player.Position.X, (int)Player.Position.Y))
                        {
                            ActiveLevel = Island2;
                            Player.Position = new Vector2(680, 390);
                            Player.Sprite.AnimationId = 0;
                            ActiveNpc = null;
                        }
                    }

                    if (ActiveLevel == Island3)
                    {
                        if (IslandThreeNorth.Contains((int)Player.Position.X, (int)Player.Position.Y))
                        {
                            ActiveLevel = Island1;
                            Player.Position = new Vector2(300, 600);
                            Player.Sprite.AnimationId = ActiveLevel.StartAnimation;
                        }
                        if (IslandThreeHouse.Contains((int)Player.Position.X, (int)Player.Position.Y)
                            && HasEnteredHouseOne && HasEnteredHouseTwo)
                        {
                            ActiveLevel = Island3House;
                            Player.Position = ActiveLevel.StartPosition;
                            Player.Sprite.AnimationId = ActiveLevel.StartAnimation;
                        }
                    }

                    if (ActiveLevel == Island3House)
                    {
                        ActiveNpc = Mimmy;
                        if (Mimmy.IsDialogActive)
                            gamestate = GameStates.End;

                        if (HouseThree.Contains((int)Player.Position.X, (int)Player.Position.Y))
                        {
                            ActiveLevel = Island3;
                            Player.Position = new Vector2(850, 300);
                            Player.Sprite.AnimationId = 0;
                            ActiveNpc = null;
                        }
                    }
                }
            }

            else if (gamestate == GameStates.Menu)
            {
                menu.Update();
                HellMarchInstance.Stop();

                // Play menu music
                if (!IsMenuMusicPlaying)
                {
                    HelloKittyThemeInstance.IsLooped = true;
                    HelloKittyThemeInstance.Play();
                    IsMenuMusicPlaying = true;
                }
            }

            else if (gamestate == GameStates.Credits)
            {
                if (InputHandler.Instance.IsActionPressed())
                {
                    gamestate = GameStates.Menu;
                }
            }
            else if (gamestate == GameStates.End)
            {
                if (InputHandler.Instance.IsActionPressed())
                {
                    HellMarchInstance.Stop();
                    gamestate = GameStates.Menu;
                }
            }
            base.Update(gameTime);
        }
Exemplo n.º 3
0
 public static void ResetGame()
 {
     HasEnteredHouseOne = false;
     HasEnteredHouseTwo = false;
     ActiveLevel = Island1;
     ActiveNpc = null;
     Player.Position = new Vector2(640, 500);
     Player.Sprite.AnimationId = 2;
 }