Ejemplo n.º 1
0
        public static void Attack(BattleHeroInfo attacker, BattleHeroInfo defender, ref StringBuilder log)
        {
            int ab = attacker.BaseInfo.GetAdvProp(enmPropType.ATTACK_BONUS);
            int ac = defender.BaseInfo.GetAdvProp(enmPropType.ARMOR_CLASS);

            int roll = GameLogic.Dice(1, 20, ab);

            log.AppendFormat("{0} attack to {1}!(Roll {2}),", attacker.BaseInfo.Name, defender.BaseInfo.Name, roll);
            if (roll == 1)
            {
                log.AppendLine("Miss!");
            }
            else if (roll == 20)
            {
                //简化确认重击步骤
                log.AppendLine("Critical!").AppendFormat(" Cause {0} damage!", CalcDamage(attacker, defender, true)).AppendLine();
            }
            else if (roll >= ac)
            {
                log.Append("Hit!").AppendFormat(" Cause {0} damage!", CalcDamage(attacker, defender, false)).AppendLine();
            }
            else
            {
                log.AppendLine("Miss!");
            }
            if (!defender.MIsAlive)
            {
                log.AppendLine(defender.BaseInfo.Name + " dead");
            }
        }
Ejemplo n.º 2
0
        public static int CalcDamage(BattleHeroInfo attacker, BattleHeroInfo defender, bool isCritical)
        {
            EquipInfo wInfo = attacker.GetWeapon();

            int dmg = 0;

            if (wInfo == null)
            {
                dmg = attacker.BaseInfo.GetAdvProp(enmPropType.ATTACK_BONUS);
                if (isCritical)
                {
                    dmg *= 2; //简化徒手攻击
                }
            }
            else
            {
            }

            defender.ReduceHp(dmg);//简化对方减伤
            return(dmg);
        }
Ejemplo n.º 3
0
        public void SetTeam(TeamInfo team1, TeamInfo team2)
        {
            mTeam1      = new List <BattleHeroInfo>();
            mTeam2      = new List <BattleHeroInfo>();
            mActionTurn = new List <BattleHeroInfo>();

            HeroInfo       info;
            BattleHeroInfo bInfo;

            for (int i = 0; i < team1.MHeroes.Count; i++)
            {
                info = team1.MHeroes[i];
                //bInfo = ConvertHelper.ConvertHeroInfoToBattleInfo(info);// new BattleHeroInfo(info, GameLogic.Dice(1, 20, info.GetBasePropMod(enmPropType.DEX)));
                //bInfo.SetAttackTurn(GameLogic.Dice(1, 20, info.GetBasePropMod(enmPropType.DEX)));
                //bInfo.SetRemainHp(info.GetAdvProp(enmPropType.HP));
                //bInfo.Name = "Your " + bInfo.GetRace() + " " + (i+1);
                //bInfo.Side = 1;
                bInfo = new BattleHeroInfo(info, GameLogic.Dice(1, 20, info.GetBasePropMod(enmPropType.DEX)), 1);
                mTeam1.Add(bInfo);
                mActionTurn.Add(bInfo);
            }

            for (int i = 0; i < team2.MHeroes.Count; i++)
            {
                info = team2.MHeroes[i];
                //bInfo = ConvertHelper.ConvertHeroInfoToBattleInfo(info);
                //bInfo.SetAttackTurn(GameLogic.Dice(1, 20, info.GetBasePropMod(enmPropType.DEX)));
                //bInfo.SetRemainHp(info.GetAdvProp(enmPropType.HP));
                //bInfo.Name = bInfo.GetRace() + " " + (i + 1);
                //bInfo.Side = 2;
                bInfo = new BattleHeroInfo(info, GameLogic.Dice(1, 20, info.GetBasePropMod(enmPropType.DEX)), 2);
                mTeam2.Add(bInfo);
                mActionTurn.Add(bInfo);
            }

            mActionTurn.Sort(GameLogic.SortHeroesByActionTurn);
        }
Ejemplo n.º 4
0
 public static int SortHeroesByActionTurn(BattleHeroInfo a, BattleHeroInfo b)
 {
     return((a.MAttackTurn > b.MAttackTurn) ? -1 : 1);
 }