Example #1
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;
 }
Example #2
0
 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;
 }
Example #3
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;
                }
            }
        }