Data class for enemies.
Inheritance: IRpgObject
Example #1
0
File: Area.cs Project: dmacy5/RPG
        public void enter()
        {
            Random generator = new Random();
            double eventType = generator.NextDouble();
            Event areaEvent;

            if (eventType > .5)
            {
                Character enemy = new Enemy("Bitch");
                Console.WriteLine(player.Name + " is being attacked by " + enemy.Name);
                areaEvent = new Event(player, enemy);
            }
            else
                areaEvent = new Event(player);

            areaEvent.initiate();
        }
Example #2
0
 private void DataObjectListOnListBoxIndexChanged(object sender, EventArgs e)
 {
     int index = this.dataObjectList.SelectedIndex;
     if (index >= 0)
     {
         this._enemy = this.Data[index + 1];
         this.RefreshCurrentObject();
     }
 }
Example #3
0
 private static ListViewItem MakeActionItem(Enemy.Action action)
 {
     var conditions = new List<string>();
     bool turnCondition = !(action.condition_turn_a == 0 && action.condition_turn_b == 1);
     if (turnCondition)
         conditions.Add(String.Format("Turn {0} + {1}X",
             action.condition_turn_a, action.condition_turn_b));
     if (action.condition_hp != 100)
         conditions.Add(String.Format("{0}% HP or below", action.condition_hp));
     if (action.condition_level != 1)
         conditions.Add(String.Format("Level {0} or above", action.condition_level));
     if (action.condition_switch_id != 0)
         conditions.Add(String.Format("Switch [{0:d4}: {1}] is ON",
             action.condition_switch_id, Project.Data.System.switches[action.condition_switch_id]));
     if (conditions.Count == 0)
         conditions.Add("<None>");
     string condition = String.Join(", ", conditions);
     string cmd = action.kind == 0 ? _actions[action.basic] :
         Project.Data.Skills[action.skill_id].name;
     return new ListViewItem(new[] { cmd, condition,
         action.rating.ToString(CultureInfo.InvariantCulture) });
 }
Example #4
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;
                }
            }
        }
Example #5
0
 public BattleSequence(Party party, Enemy[] enemies, SpriteFont displayTextFont, TileMap battleMap, int xRet, int yRet, String retMap)
 {
     this.playerec = new BattleEntity[] { new BattleEntity(new Rectangle(366, 207, 32, 32), Game1.playerLeftFace, Game1.playerLeftFaceHit) };
     this.enemyrec = new BattleEntity[] { new BattleEntity(new Rectangle(111, 207, 32, 32), Game1.enemy1RightFace, Game1.enemy1RightFaceHit) };
     this.party = party;
     this.enemies = enemies;
     this.combatLog = new List<String>();
     this.combatLogFont = displayTextFont;
     this.currentActions = new Queue<BattleAction>();
     this.continueCombat = true;
     this.partyDead = false;
     this.enemiesDead= false;
     this.isWaiting = false;
     this.xRet = Convert.ToString(xRet);
     this.yRet = Convert.ToString(yRet);
     this.retMap = retMap;
     this.projectiles = new Queue<Projectile>();
     state = BattleStageType.ACTION;
     drawplayerhpattime = Int32.MaxValue;
 }
 private void SetAction(Enemy.Action action)
 {
     var turnC = !(action.condition_turn_a == 0 && action.condition_turn_b == 1);
     if (turnC)
     {
         this.checkBoxTurn.Checked = true;
         this.numericUpDownTurn.Value = action.condition_turn_a;
         this.numericUpDownTurnX.Value = action.condition_turn_b;
     }
     if (action.condition_hp != 100)
     {
         this.checkBoxHP.Checked = true;
         this.numericUpDownHP.Value = action.condition_hp;
     }
     if (action.condition_level != 1)
     {
         this.checkBoxLevel.Checked = true;
         this.numericUpDownLevel.Value = action.condition_level;
     }
     if (action.condition_switch_id != 0)
     {
         this.checkBoxSwitch.Checked = true;
         this.comboBoxSwitch.SelectedIndex = action.condition_switch_id - 1;
     }
     this.comboBoxBasic.SelectedIndex = action.basic;
     this.comboBoxSkill.SelectedIndex = action.skill_id - 1;
     if (action.kind == 0)
         this.radioButtonBasic.Checked = true;
     else
         this.radioButtonSkill.Checked = true;
     this.numericUpDownRating.Value = action.rating;
 }