Inheritance: IOverworldEntity, IBattleCharacter
Example #1
0
        public override void Update(GameTime gameTime)
        {
            Enemy en = new Enemy(game.Content.Load<Texture2D>("ghostie"));
            Player pl = new Player(game, 0, 0);

            StateManager.PushState(new Battle(game, game.Content.Load<Texture2D>("test-battle-background"), null, pl, en, true));
        }
Example #2
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);
        }
Example #3
0
        // constructor
        public Battle(Game game, Texture2D bgTex, Song battleSong, Player p, Enemy e, bool run)
            : base(game)
        {
            StateManager.PushState(new LevelState(game, p));

            play = p;
            en = e;
            font = game.Content.Load<SpriteFont>("battle-font");
            tMenu = new TextMenu(font, choices);
            combatColor = new Texture2D(game.GraphicsDevice, 1, 1);
            combatColor.SetData<Color>(new Color[] { new Color(Color.Black, 150) });
            transparent = true;
            rgen = new Random();

            try
            {
                if (battleSong != null)
                {
                    MediaPlayer.Play(battleSong);
                    MediaPlayer.Volume = .5f;
                    MediaPlayer.IsRepeating = true;
                }
            }
            catch (Exception)
            {
            }

            canRun = run;

            backgroundTexture = bgTex;
            hasRun = false;
            currentItemCount = play.Items.Count;
            calculateSpeed();
        }
Example #4
0
        public override void Update(GameTime gameTime)
        {
            var player = new Player(game, 0, 0);
            player.Items.Add(new Item("Bottle of Mead", "A delicious bottle of mead. HP+50,MP+80", 50, 80, 10));
            player.Items.Add(new Item("Can of Soda", "A delicious can of soda. HP+50,MP+80", 50, 80, 10));

            StateManager.PushState(new ItemState(game, player, false));
        }
Example #5
0
 public HUD(Game game, Player player, ScriptableMap map)
 {
     font = game.Content.Load<SpriteFont>("hud-font");
     background = new Texture2D(game.GraphicsDevice, 1, 1);
     background.SetData<Color>(new Color[] { new Color(100, 100, 100) });
     this.player = player;
     this.map = map;
     screenSize = game.GraphicsDevice.Viewport.Height;
 }
Example #6
0
 public PauseState(Game game, Player player)
     : base(game)
 {
     transparent = true;
     height = game.GraphicsDevice.Viewport.Height;
     font = game.Content.Load<SpriteFont>("hud-font");
     this.player = player;
     MediaPlayer.Volume = .5f;
 }
Example #7
0
        public override void Update(GameTime gameTime)
        {
            Player pl = new Player(game, 0, 0);
            Item[] inventory = new Item[2];
            inventory[0] = new Item("Bottle of Mead", "A delicious bottle of mead. HP+50,MP+80", 50, 80, 10);
            inventory[0].Cost = 50;
            inventory[1] = new Item("Can of Soda", "A delicious can of soda. HP+50,MP+80", 50, 80, 10);
            inventory[1].Cost = 35;

            StateManager.PushState(new Store(game, pl, inventory));
        }
Example #8
0
 public Store(Game game, Player pl, Item[] items)
     : base(game)
 {
     player = pl;
     storeInventory = items;
     storeTexture = new Texture2D(game.GraphicsDevice, 1, 1);
     storeTexture.SetData<Color>(new Color[] { new Color(Color.Gray, 255) });
     background = game.Content.Load<Texture2D>("store-bg");
     spriteFont = game.Content.Load<SpriteFont>("inventory-list-font");
     textInventory = new TextMenu(spriteFont, this.getItemNames(storeInventory));
 }
Example #9
0
 //Health and mana will go up each level everytime
 public LevelState(Game game, Player player)
     : base(game)
 {
     this.play = player;
     font = game.Content.Load<SpriteFont>("level-up-menu-font");
     fontLevelUp = game.Content.Load<SpriteFont>("level-up-font");
     fontLevel = game.Content.Load<SpriteFont>("level-font");
     tMenu = new TextMenu(font, choices);
     transparent = true;
     increaseStats = true;
     combatColor = new Texture2D(game.GraphicsDevice, 1, 1);
     combatColor.SetData<Color>(new Color[] { new Color(Color.Black, 200) });
     pointsLeft = 0;
 }
Example #10
0
 public ItemState(Game game, Player player, bool oneTimeUse)
     : base(game)
 {
     this.player = player;
     texture = new Texture2D(game.GraphicsDevice, 1, 1);
     texture.SetData<Color>(new Color[] { new Color(Color.Black, 150) });
     font = game.Content.Load<SpriteFont>("inventory-header-font");
     //The menu is only needed if the player has items.
     if (player.Items.Count > 0)
         menu = new TextMenu(game.Content.Load<SpriteFont>("inventory-list-font"), getStringOfPlayerItems());
     canPressEscape = false;
     transparent = true;
     this.oneTimeUse = oneTimeUse;
 }
Example #11
0
 /// <summary>
 /// Saves using the .NET serialization libraries
 /// Saved file is an array containing...
 /// [player object, current map, flags]
 /// </summary>
 /// <param name="currentMapName"></param>
 /// <param name="player"></param>
 public static void Save(string currentMapName, Player player)
 {
     try
     {
         var saveFile = new object[] {
             player, currentMapName, Flags.GetAllFlags(),
         };
         var formatter = new BinaryFormatter();
         var stream = new FileStream(SAVE_FILE_LOCATION, FileMode.Create);
         formatter.Serialize(stream, saveFile);
         stream.Close();
     }
     catch (Exception e)
     {
         Console.WriteLine("{0} {1}", e.Message, e.StackTrace);
     }
 }
Example #12
0
 private void save(Player player)
 {
     GameData.Save(scriptFilename, player);
 }
Example #13
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();
        }
Example #14
0
 private void js_battle(Player player, Enemy enemy, string song)
 {
     StateManager.Running = false;
     int currentStackSize = StateManager.StackSize;
     Song battleSong = game.Content.Load<Song>(song);
     StateManager.PushState(new Battle(game, battleTexture, battleSong, player, enemy, false));
     StateManager.Running = true;
     while (currentStackSize != StateManager.StackSize && currentStackSize != 0)
     {
     }
     if (player.IsDead())
         Thread.CurrentThread.Abort();
 }
Example #15
0
 private void js_save(Player player)
 {
     player.Health = player.MaxHealth;
     player.Mana = player.MaxMana;
     GameData.Save(scriptFilename, player);
 }
Example #16
0
 private void js_store(Player player, ArrayList itemsArrayList)
 {
     StateManager.Running = false;
     int currentStackSize = StateManager.StackSize;
     Item[] items = null;
     if (itemsArrayList != null)
         items = createItemArray(itemsArrayList);
     StateManager.PushState(new Store(game, player, items));
     StateManager.Running = true;
     while (currentStackSize != StateManager.StackSize && currentStackSize != 0)
     {
     }
 }
Example #17
0
 public void Interact(Player player, ScriptableMap map)
 {
     var thread = new Thread(new ParameterizedThreadStart(interact));
     thread.Start(player);
 }