예제 #1
0
 public override bool IsBattleEnd(Combat combat, CombatVariable atkVal, CombatVariable defVal)
 {
     return(false);
 }
예제 #2
0
 public abstract bool IsBattleEnd(Combat combat, CombatVariable atkVal, CombatVariable defVal);
예제 #3
0
        public override CombatStep CalcBattle(Combat combat, CombatVariable atkVal, CombatVariable defVal)
        {
            CombatUnit atker = combat.GetCombatUnit(atkVal.position);
            CombatUnit defer = combat.GetCombatUnit(defVal.position);

            atkVal.animaType = CombatAnimaType.Attack;

            // 真实命中率 = 攻击者命中 - 防守者回避
            int realHit = atker.Hit - defer.Avoidance;

            // 概率是否击中
            int  hitRate = Random.Range(0, 100);
            bool isHit   = hitRate <= realHit;

            if (isHit)
            {
                bool crit    = false; // TODO 是否暴击
                int  realAtk = atker.Atk;

                ///////////////////
                // TODO 触发伤害技能
                //////////////////

                if (crit)
                {
                    realAtk *= 3; // 假定暴击造成三倍伤害
                }

                // 掉血 = 攻击者攻击力 - 防守者防御力
                // 最少不掉血
                int damageHp = Mathf.Max(0, realAtk - defer.Def);
                if (damageHp > defVal.hp)
                {
                    damageHp = defVal.hp;
                }
                defVal.hp -= damageHp;

                atkVal.crit      = crit;
                defVal.animaType = CombatAnimaType.Damage;

                // 更新此次攻击信息
                this.Message = string.Format(
                    "{0} 对 {1} 的攻击造成了 {2} 点伤害{3}。",
                    atker.Role.Character.Info.name,
                    defer.Role.Character.Info.name,
                    damageHp,
                    crit ? "(暴击)" : string.Empty);

                if (defVal.IsDead)
                {
                    Message += string.Format(" {0}被击败了。", defer.Role.Character.Info.name);
                }
            }
            else
            {
                defVal.animaType = CombatAnimaType.Evade;

                // 更新此次躲闪信息
                Message = string.Format(
                    "{1} 躲闪了 {0} 的攻击。",
                    atker.Role.Character.Info.name,
                    defer.Role.Character.Info.name);
            }

            // 只有玩家才会减低耐久度
            if (atker.Role.AttitudeTowards == AttitudeTowards.Player)
            {
                // 攻击者武器耐久度 -1
                atkVal.durability = Mathf.Max(0, atkVal.durability - 1);
            }

            // 攻击者行动过了
            atkVal.action = true;

            CombatStep step = new CombatStep(atkVal, defVal);

            return(step);
        }
예제 #4
0
 public abstract CombatStep CalcBattle(Combat combat, CombatVariable atkVal, CombatVariable defVal);