//计算放招的消耗 public void performSkillCost(Role role, Skill skill) { role.Balls -= skill.RequireBall; //有变化才记录 if (skill.RequireBall != 0) { battleResult.Actions.Add(BattleActionView.AddBall(role, -skill.RequireBall)); } }
//攻击一个单体敌人 public void hitSingleEnemy(Role sourceRole, Role target, Skill skill) { //战斗判定:先给个简单的计算公式 bool isMissed = true; //if (target.Team != sourceRole.Team) Buff piaomiao = target.getBuff("飘渺"); float piaomiaoRatio = 0.0f; if (piaomiao != null) { piaomiaoRatio = piaomiao.Power / 1000.0f * 1.0f; } isMissed = Tools.ProbabilityTest(target.Dodge / 100.0 + piaomiaoRatio); if (!isMissed) { //天赋:奋不顾身 if (skill.range == Range.Single) { Role toDefend = null; foreach (Role role in CurrentRoles) { if (role.Id != target.Id && role.Team == target.Team && role.getTalent("奋不顾身") != null && Tools.ProbabilityTest(0.3f + role.getTalent("奋不顾身").Level / 1000.0f)) { toDefend = role; break; } } if (toDefend != null) { Role originalTarget = target.BattleCopy(); target = toDefend; battleResult.Actions.Add(BattleActionView.Defend(toDefend, originalTarget)); } } int HP = calcAttack(sourceRole, skill);// - action.target.Defence; //命中动画 battleResult.Actions.Add(BattleActionView.ShowSkill(target, skill)); //攻击特效 calcEffects(sourceRole, target, skill, HP); //Buff & Debuff addBuffs(sourceRole, target, skill); //加气格 int ball = Tools.ProbabilityTest(0.5) ? 1 : 0; if (sourceRole.Balls >= 6) { ball = 0; } sourceRole.Balls += ball; if (ball != 0) { battleResult.Actions.Add(BattleActionView.AddBall(sourceRole, ball)); } int targetBall = Tools.ProbabilityTest(0.5) ? 1 : 0; target.Balls += targetBall; if (targetBall != 0) { battleResult.Actions.Add(BattleActionView.AddBall(target, targetBall)); } //损血动画 costHP(target, HP); } else { //闪躲动画 battleResult.Actions.Add(BattleActionView.Miss(target)); } }