Beispiel #1
0
 void createPlayer(XmlReader reader)
 {
     Vector2 pos = Vector2.Zero;
     TextureMap t = new TextureMap();
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             switch (reader.Name)
             {
                 case "position":
                     {
                         reader.ReadToDescendant("x");
                         float x = (float)float.Parse((reader.GetAttribute(0)));
                         reader.ReadToNextSibling("y");
                         float y = (float)float.Parse((reader.GetAttribute(0)));
                         pos = new Vector2(x, y);
                     }
                     break;
                 default:
                     int o = 0;//fer teh deboog
                     break;
             }
         }
     }
     Player p = new Player(pos, t);
 }
Beispiel #2
0
 public ItemButton(Texture2D texture, SpriteFont font, String text, Player p, BattleSequence bs, List<Event> events)
     : base(texture, font, text)
 {
     this.player = p;
     this.eventList = events;
     this.bs = bs;
 }
Beispiel #3
0
 public Enemy(Player p, Item prize, int expGiveBase = 20, int goldGiveBase = 20)
 {
     this.player = p;
     this.expGiveBase = expGiveBase;
     this.goldGiveBase = goldGiveBase;
     this.prize = prize;
 }
 public BattleAction(BattleSequence bs, Player user, Player[] target, BattleActionType type, Spell spell, Item item)
 {
     this.user = user;
     this.target = target;
     this.type = type;
     this.spell = spell;
     this.item = item;
     this.battleSequence = bs;
 }
Beispiel #5
0
 public Party(Player[] partyMembers, int score = 0, int money = 1000)
 {
     this.open = new Dictionary<String, Quest>();
     this.completed = new Dictionary<String, Quest>();
     this.partyMembers = partyMembers;
     this.score = score;
     this.money = money;
     //this.partyMembers[0].inventory.AddItem(Item.DRAGON_SKULL);
 }
Beispiel #6
0
        public GameScreen(ref SpriteBatch sb, ref Player p, TextureMap eMap, 
            params string[] bgNames)
        {
            bg2pos = new Vector2(0.0f, 0.0f);
            SB = sb;
            Player1 = p;
            pressedPause = false;
            Backgrounds = new List<TextureMap>();
            DrawableEntities = new List<GameEntity>();
            foreach (string bg in bgNames)
            {
                DrawableEntities.Add(new GameEntity(Vector2.Zero, Vector2.Zero,
                    new TextureMap(Constants.content.Load<Texture2D>(".\\art\\" + bg), 1, 1), GameEntity.ENTITY_TYPE.AI));
            }

            enemyMap = eMap;
            r = new Random();
        }
Beispiel #7
0
        public Texture2D UseSpell(Player target, Spell spell)
        {
            Texture2D ret = null;
            switch(spell.type)
            {
                case SpellType.MAGIC:
                    ret = Game1.fire;
                    break;
                case SpellType.SUPPORT:
                    ret = Game1.heal;
                    break;
                case SpellType.PHYSICAL:
                    ret = Game1.sword;
                    break;
                default:
                    ret = Game1.sword;
                    break;
            }
            switch (spell.type)
            {
                case SpellType.MAGIC:

                    foreach(SpellEffect se in spell.effects)
                    {
                        if (se.target == SpellTargetType.SELF)
                        {
                            switch (se.type)
                            {
                                case SpellEffectType.MP:
                                    if ((se.value * -1) > this.GetCurrentMana())
                                        return null;
                                    break;
                                case SpellEffectType.HP:
                                    if ((se.value * -1) > this.GetCurrentHealth())
                                        return null;
                                    break;

                            }
                        }
                    }

                    foreach (SpellEffect se in spell.effects)
                    {

                        switch (se.target)
                        {
                            case SpellTargetType.ALL:
                                break; //not supported
                            case SpellTargetType.SELF:
                                this.ModifyStatSpell(se.type, se.value);
                                break;
                            case SpellTargetType.SINGLE:
                                int damage = se.value + this.GetCurrentMAGATK();
                                target.ModifyStatSpell(se.type,-1 * damage);
                                break;
                            default: break;
                        }
                    }
                    break;
                case SpellType.PHYSICAL:
                    foreach (SpellEffect se in spell.effects)
                    {
                        switch (se.target)
                        {
                            case SpellTargetType.ALL:
                                break; //not supported
                            case SpellTargetType.SELF:
                                this.ModifyStatSpell(se.type, se.value);
                                break;
                            case SpellTargetType.SINGLE:
                                int damage = se.value + this.GetCurrentATK();
                                target.ModifyStatSpell(se.type, -1 * damage);
                                break;
                            default: break;
                        }
                    }
                    break;
                case SpellType.SUPPORT:
                    foreach (SpellEffect se in spell.effects)
                    {
                        switch (se.target)
                        {
                            case SpellTargetType.ALL:
                                break; //not supported
                            case SpellTargetType.SELF:
                                this.ModifyStatSpell(se.type, se.value);
                                break;
                            case SpellTargetType.SINGLE:
                                int damage = se.value + this.GetCurrentMAGATK();
                                target.ModifyStatSpell(se.type, damage);
                                break;
                            default: break;
                        }
                    }
                    break;
                default: break;
            }
            return ret;
        }
Beispiel #8
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            if (STARTPLAY)
            {
                state = GameState.RUNNING;
                playstate = PlayState.WORLD;
            }
            else
            {
                state = GameState.EDIT;
            }
            eventqueue = new Queue<Event>();
            quests = new Dictionary<String, Quest>();
            quests.Add(Quests.DRAGONQUEST.getQuestID(), Quests.DRAGONQUEST);
            playedendsound = false;
            texmap = new Dictionary<String, Texture2D>();
            maps = new Dictionary<String, TileMap>();
            lastmonstermove = 0;
            lastplayermove = 0;
            inaddevent = false;
            buttonFont = Content.Load<SpriteFont>("buttonFont");
            buttonImage = Content.Load<Texture2D>("Tiles/button");
            //PlayerBase war = p.getNewPlayer("WARRIOR");

            Player[] playerList = new Player[] { new Player(Player.WARRIOR, Sprite.WARRIOR, "Baethor", 10) };
            party = new Party(playerList);
            base.Initialize();
        }
Beispiel #9
0
        private void processEvents(GameTime gameTime)
        {
            while (eventqueue.Count > 0)
            {
                Event e = eventqueue.Dequeue();
                if (e.getEventType() == EventType.MAP_TRANSITION)
                {
                    String mapfile = e.getProperty("mapfile");
                    int x = Convert.ToInt32(e.getProperty("x"));
                    int y = Convert.ToInt32(e.getProperty("y"));

                    //if(DEBUG)
                    Console.WriteLine("Processing Map Transition Event for " + mapfile + " x=" + x + ",y=" + y);

                    if(mapfile.Contains("dragon"))
                    {
                        if (!currSong.Equals(cave))
                        {
                            MediaPlayer.Stop();
                            PlayMusic(cave);
                            currSong = cave;
                        }
                    }
                    else
                    {
                        if (!currSong.Equals(town))
                        {
                            MediaPlayer.Stop();
                            PlayMusic(town);
                            currSong = town;
                        }
                    }
                    map = getMap(mapfile, x, y);
                    if(DEBUG)
                    Console.WriteLine("Reached 2");

                    Game1.playstate = PlayState.WORLD;
                    map.setEnemySpawnTime((int)gameTime.TotalGameTime.TotalMilliseconds);
                }
                else if (e.getEventType() == EventType.BATTLE_TILE)
                {
                    int x = map.getPlayerTile().getMapX();
                    int y = map.getPlayerTile().getMapY();
                    playstate = PlayState.BATTLE;
                    String file = map.filename;
                    int ind = Convert.ToInt32(e.getProperty("index"));
                    Console.WriteLine("index=" + ind + " monstertiles.count = " + map.getMonsterTilesCount());
                    map.RemoveMonsterTile(Convert.ToInt32(e.getProperty("index")));
                    map = getMap(e.getProperty("battlemap"), 8, 8);
                    //map.removePlayer();

                    Enemy[] enemies;
                    Player px = new Player();
                    if(file.Contains("-m2"))
                    {
                        Enemy m = null;
                        if (!party.hasItem(Item.DRAGON_SKULL))
                            m = new Enemy(new Player(px.getNewEnemy("WARRIOR"), Sprite.ENEMY_2, "Dragon Cat", 7), Item.DRAGON_SKULL);
                        else
                            m = new Enemy(new Player(px.getNewEnemy("WARRIOR"), Sprite.ENEMY_1, "Ninja Pu", 1), Item.HP_POTION_100);

                        enemies = new Enemy[] { m };
                        enemy1RightFaceFile = enemies[0].player.sprite.GetRightFaceImage();
                        enemy1RightFace = Content.Load<Texture2D>(enemy1RightFaceFile);
                        enemy1RightFaceFileHit = enemies[0].player.sprite.GetRightFaceHitImage();
                        enemy1RightFaceHit = Content.Load<Texture2D>(enemy1RightFaceFileHit);
                        playerLeftFaceFile = party.partyMembers[0].sprite.GetLeftFaceImage();
                        playerLeftFace = Content.Load<Texture2D>(playerLeftFaceFile);
                        playerLeftFaceFileHit = party.partyMembers[0].sprite.GetLeftFaceHitImage();
                        playerLeftFaceHit = Content.Load<Texture2D>(playerLeftFaceFileHit);
                    }
                    else
                    {
                        enemies = new Enemy[] { new Enemy(new Player(px.getNewEnemy("WARRIOR"), Sprite.ENEMY_1, "Ninja Pu", 1), Item.HP_POTION_100) };
                        enemy1RightFaceFile = enemies[0].player.sprite.GetRightFaceImage();
                        enemy1RightFace = Content.Load<Texture2D>(enemy1RightFaceFile);
                        enemy1RightFaceFileHit = enemies[0].player.sprite.GetRightFaceHitImage();
                        enemy1RightFaceHit = Content.Load<Texture2D>(enemy1RightFaceFileHit);
                        playerLeftFaceFile = party.partyMembers[0].sprite.GetLeftFaceImage();
                        playerLeftFace = Content.Load<Texture2D>(playerLeftFaceFile);
                        playerLeftFaceFileHit = party.partyMembers[0].sprite.GetLeftFaceHitImage();
                        playerLeftFaceHit = Content.Load<Texture2D>(playerLeftFaceFileHit);
                    }

                    bs = new BattleSequence(party, enemies , Content.Load<SpriteFont>("gameFont"),map, x,y,file);
                    bs.Start();
                    //bs = null;

                    PlayMusic(battle);
                    currSong = battle;
                    /*String mapfile = e.getProperty("mapfile");
                    int x = Convert.ToInt32(e.getProperty("x"));
                    int y = Convert.ToInt32(e.getProperty("y"));
                    */
                }
                else if (e.getEventType() == EventType.WAITFORNPC)
                {
                    currentevent = e;
                    playstate = PlayState.WAITFORNPC;
                }
                else if (e.getEventType() == EventType.NPCQUEST)
                {
                    currentevent = e;
                    playstate = PlayState.NPCQUEST;
                }
                else if (e.getEventType() == EventType.MESSAGE)
                {
                    currentevent = e;
                    playstate = PlayState.MESSAGE;
                }
                else if (e.getEventType() == EventType.WIN_GAME)
                {
                    currentevent = e;
                    state = GameState.GAMEOVER;
                    playstate = PlayState.GAMEOVER_WIN;
                }
                else if (e.getEventType() == EventType.LOSE_GAME)
                {
                    currentevent = e;
                    state = GameState.GAMEOVER;
                    playstate = PlayState.GAMEOVER_LOSE;
                }
                else if (e.getEventType() == EventType.QUESTRETURN)
                {
                    String questid = e.getProperty("questid");
                    if (!party.questCompleted(questid))
                    {
                        Quest q = quests[questid];

                        if (party.hasItem(q.getQuestItem()))
                        {
                            party.removeItem(q.getQuestItem());
                            party.completeQuest(q);

                            Event m = new Event();
                            m.setEventType(EventType.MESSAGE);
                            m.addProperty("text", q.getQuestCompleteText());
                            addToEventQueue(m);

                            Event n = new Event();
                            n.setEventType(EventType.WIN_GAME);
                            addToEventQueue(n);

                        }
                        else
                        {
                            Event m = new Event();
                            m.setEventType(EventType.MESSAGE);
                            m.addProperty("text", "You have not completed this\nquest yet.");
                            addToEventQueue(m);
                        }
                    }
                    else
                        playstate = PlayState.WORLD;
                }
            }
        }
Beispiel #10
0
 public bool SellItem(Player member, Item item)
 {
     if(member.inventory.Search(item))
     {
         this.money += (item.cost / 2);
         return member.inventory.RemoveItem(item);
     }
     return false;
 }