A scriptable map that can be drawn to the screen. Author: Dennis Honeyman
상속: ScriptableMap
예제 #1
0
        public Overworld(Game game, Player player, DrawableMap map)
            : base(game)
        {
            playerObj = player;
            mappy = map;

            try
            {
                if (mappy.OverworldMusic != null)
                    MediaPlayer.Play(mappy.OverworldMusic);
            }
            catch (Exception)
            {
            }

            //The destination rectangle is the location where the sprite will be drawn.
            destinationRectangle = new Rectangle(0, 0, spriteWidth, spriteHeight);

            timer = 0;
            canPressZ = false;
            pedometer = 0;
            canPressEscape = false;
            movingLeft = false;
            movingRight = false;
            movingUp = false;
            movingDown = false;

            hud = new HUD(game, playerObj, mappy);
        }
예제 #2
0
        public override void Update(GameTime gameTime)
        {
            try
            {
                if (MediaPlayer.Queue.ActiveSong != song)
                {
                    MediaPlayer.Play(song);
                    MediaPlayer.IsRepeating = true;
                    MediaPlayer.Volume = 1;
                }
            }
            catch (Exception)
            {
            }
            menu.Update(gameTime, Keyboard.GetState());

            if (!menu.IsFinished)
                return;

            string selectedOption = options[menu.SelectedOption];

            if (selectedOption == "New Game")
            {
                //dungeon_1
                Flags.SetAllFlags(new Dictionary<string, bool>());
                var player = new Player(game, 1, 9);
                var map = new DrawableMap(game);
                map.LoadMap("dungeon_1.js");
                StateManager.PushState(new Overworld(game, player, map));
                StateManager.PushState(new Dialogue(game, "Jordan: ...Ugh... (Wh... where am I...? So... hungry...)|???: <What? How are you still conscious?!>|Jordan: (Woah! Where is that voice coming from?!)|???: <You've been lying here without food for a week! I was sure you'd be dead by now!!>|Jordan: W-who's there?|Ludovic: <I'm Ludovic, a demon, and I've taken over your body. I kind of was hoping you were a bit more DEAD, though...>|Jordan: Gee, thanks...|Ludovic: <You don't have to talk aloud, you know. I can hear your thoughts. Plus, you're making that guard over there suspicious. Anyway, we have to get out of this castle.>|Jordan: (What is going on here?!)"));
            }
            else if (selectedOption == "Load Game")
            {
                object[] saveFile = GameData.Load();

                if (saveFile == null)
                {
                    StateManager.PushState(new Dialogue(game, "Save file could not be loaded."));
                    return;
                }

                var player = (Player)saveFile[0];
                player.LoadTexture(game);
                Flags.SetAllFlags((Dictionary<string, bool>)saveFile[2]);
                var map = new DrawableMap(game);
                map.LoadMap((string)saveFile[1]);
                StateManager.PushState(new Overworld(game, player, map));
            }
            else if (selectedOption == "About")
            {
                StateManager.PushState(new AboutState(game));
            }
            else if (selectedOption == "Exit")
                StateManager.PopState();
        }
예제 #3
0
        public void DrawForOverworld(SpriteBatch spriteBatch, DrawableMap map, int x, int y)
        {
            if (direction == Player.Directions.West)
            {
                currentSpriteY = 3;
            }
            else if (direction == Player.Directions.East)
            {
                currentSpriteY = 1;
            }
            else if (direction == Player.Directions.South)
            {
                currentSpriteY = 2;
            }
            else
            {
                currentSpriteY = 0;
            }

            sourceRectangle = new Rectangle(currentSpriteX * spriteWidth, currentSpriteY * spriteHeight, spriteWidth, spriteHeight);

            spriteBatch.Draw(overworldTexture, new Vector2(x - 3 + xPos * map.TileSize - modX, y - 8 + yPos * map.TileSize - modY), sourceRectangle, Color.White);
        }
예제 #4
0
 public TestMapState(Game game)
     : base(game)
 {
     map = new DrawableMap(game);
     map.LoadMap("testmap.js");
 }