コード例 #1
0
ファイル: Referee.cs プロジェクト: vkd/DesktopDungeons
        /// <summary>
        /// Fight among hero and monster
        /// </summary>
        /// <param name="parHero">Hero</param>
        /// <param name="parMonster">Monster</param>
        public void Fight(Hero parHero, Monster parMonster)
        {
            if (parHero.ClassHero == Class.Assassin)
            {
                if (parMonster.Level < parHero.Level)
                {
                    parHero.AddExperience(parMonster.Level, true, 0);
                    map.DeathMonster(parMonster);
                    return;
                }

                if (VisibleAroundMonster(parMonster))
                    parHero.FirstStrike = true;
            }

            //first strike
            if (parHero.CheckFirstStrike(parMonster))
            {
                if (FirstStrikeSecond(parHero, parMonster))
                {
                    if (parHero.ClassHero == Class.Paladin && parMonster.Undead)
                        parHero.HealthCurrent += parHero.HealthMax / 2;
                    parHero.AddExperience(parMonster.Level, true, 0);
                    map.DeathMonster(parMonster);
                    return;
                }
                if (FirstStrikeSecond(parMonster, parHero))
                {
                    if (parHero.Death())
                    {
                        if (parHero.ClassHero == Class.Crusader)
                        {
                            parMonster.HealthCurrent -= parHero.DamageBase * 3;
                            if (parMonster.HealthCurrent <= 0)
                            {
                                parHero.AddExperience(parMonster.Level, true, 0);
                                map.DeathMonster(parMonster);
                            }
                        }
                        ChangeGameState(GameState.Score);
                    }
                }
                if (parHero.ClassHero == Class.Sorcerer)
                {
                    parMonster.SetDamage(parHero.AttackResponse(true), true);
                    if (parMonster.HealthCurrent <= 0)
                    {
                        parHero.AddExperience(parMonster.Level, true, 0);
                        map.DeathMonster(parMonster);
                        return;
                    }
                }
            }
            else
            {
                if (FirstStrikeSecond(parMonster, parHero))
                {
                    if (parHero.Death())
                    {
                        if (parHero.ClassHero == Class.Crusader)
                        {
                            parMonster.HealthCurrent -= parHero.DamageBase * 3;
                            if (parMonster.HealthCurrent <= 0)
                            {
                                parHero.AddExperience(parMonster.Level, true, 0);
                                map.DeathMonster(parMonster);
                            }
                        }
                        ChangeGameState(GameState.Score);
                    }
                }
                if (parHero.ClassHero == Class.Sorcerer)
                {
                    parMonster.SetDamage(parHero.AttackResponse(true), true);
                    if (parMonster.HealthCurrent <= 0)
                    {
                        if (parHero.ClassHero == Class.Paladin && parMonster.Undead)
                            parHero.HealthCurrent += parHero.HealthMax / 2;
                        parHero.AddExperience(parMonster.Level, true, 0);
                        map.DeathMonster(parMonster);
                        return;
                    }
                }
                if (FirstStrikeSecond(parHero, parMonster))
                {
                    parHero.AddExperience(parMonster.Level, true, 0);
                    map.DeathMonster(parMonster);
                }
            }
        }
コード例 #2
0
ファイル: Map.cs プロジェクト: vkd/DesktopDungeons
 /// <summary>
 /// Create hero
 /// </summary>
 /// <param name="X">X on map</param>
 /// <param name="Y">Y on map</param>
 /// <param name="parRace">Race</param>
 /// <param name="parClass">Class</param>
 /// <param name="hero">Instance of hero class</param>
 private void CreateHero(int X, int Y, Race parRace, Class parClass, out Hero hero)
 {
     hero = new Hero(X, Y, ContentPack.HeroTexture[(int)parClass], parRace, parClass);
     switch (parClass)
     {
         case Class.Fighter:
             hero = new Fighter(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Thief:
             hero = new Thief(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Priest:
             hero = new Priest(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Wizard:
             hero = new Wizard(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Berserker:
             hero = new Berserker(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Rogue:
             hero = new Rogue(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Monk:
             hero = new Monk(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Sorcerer:
             hero = new Sorcerer(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Warlord:
             hero = new Warlord(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Assassin:
             hero = new Assassin(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Paladin:
             hero = new Paladin(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Bloodmage:
             hero = new Bloodmage(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Transmuter:
             hero = new Transmuter(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Crusader:
             hero = new Crusader(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
         case Class.Tinker:
             hero = new Tinker(X, Y, ContentPack.HeroTexture[(int)parClass], parRace);
             break;
     }
 }