/// <summary> /// 播放敌人攻击玩家时的动画效果 /// </summary> /// <param name="attacker"></param> /// <param name="att_index"></param> /// <param name="target"></param> /// <param name="tar_index"></param> public static void DrawAttackAnimationEnemy(BaseCharacter attacker, int att_index, BaseCharacter target, int tar_index) { int xStart = Program.width - GetLength("HP:" + attacker.Hp) - 2; int xEnd = GetLength("HP:" + target.Hp) + 2; int xMiddle = (xStart - xEnd) / 2; int yStart = att_index * 4 + 3; int yEnd = tar_index * 4 + 3; for (int i = xStart; i > xEnd; i = i - 2) { if (i == xMiddle || i == xMiddle - 1) { Console.SetCursorPosition(i + 2, yStart); Console.Write(" "); if (yStart > yEnd) { for (int j = yStart; j >= yEnd; j--) { Console.SetCursorPosition(i, j + 1); Console.Write(" "); Console.SetCursorPosition(i, j); Console.Write("↑"); Thread.Sleep(20); } } else if (yStart < yEnd) { for (int j = yStart; j <= yEnd; j++) { Console.SetCursorPosition(i, j - 1); Console.Write(" "); Console.SetCursorPosition(i, j); Console.Write("↓"); Thread.Sleep(20); } } } else if (i < xMiddle) { if (i != xStart) { Console.SetCursorPosition(i + 2, yEnd); Console.Write(" "); } Console.SetCursorPosition(i, yEnd); Console.Write("←"); } else { if (i != xStart) { Console.SetCursorPosition(i + 2, yStart); Console.Write(" "); } Console.SetCursorPosition(i, yStart); Console.Write("←"); } Thread.Sleep(20); } Console.SetCursorPosition(xEnd + 2, yEnd); Console.Write(" "); }
/// <summary> /// 显示指定角色的状态栏 /// </summary> /// <param name="bc"></param> /// <param name="index"></param> public static void DrawState(BaseCharacter bc, int index) { string temp = ""; foreach (State s in bc.state) { switch (s.type) { case StateType.DamageOverTime: temp += "DOT "; break; case StateType.Silence: temp += "SI "; break; case StateType.Buff: if (s.atkUp > 0) { temp += "AU "; } if (s.defUp > 0) { temp += "DU "; } if (s.atkUp < 0) { temp += "AD "; } if (s.defUp < 0) { temp += "DD "; } break; case StateType.MagicReflect: temp += "MR "; break; case StateType.PhysicalReflect: temp += "PR "; break; case StateType.PhysicalDamageIncrease: temp += "PI "; break; case StateType.PhysicalBeDamageIncrease: temp += "PBD "; break; case StateType.Taunt: temp += "TA "; break; case StateType.Revive: temp += "RE "; break; case StateType.Invincible: temp += "IV "; break; case StateType.HealOverTime: temp += "HOT "; break; case StateType.Dizzy: temp += "DI "; break; case StateType.ForbidHeal: temp += "FH "; break; default: break; } } if (bc.type == CharacterType.Hero) { Console.SetCursorPosition(0, index * 4 + 5); WriteEmpty(); Console.SetCursorPosition(0, index * 4 + 5); } else { int len = GetLength(temp); Console.SetCursorPosition(Program.width - len - 1, index * 4 + 5); WriteEmpty(len); Console.SetCursorPosition(Program.width - len - 1, index * 4 + 5); } if (temp != "") { Console.ForegroundColor = ConsoleColor.Gray; Console.Write(temp); } Console.SetCursorPosition(0, 0); }
/// <summary> /// 释放一个技能 /// </summary> /// <param name="attacker"></param> /// <param name="att_index"></param> /// <param name="target"></param> /// <param name="tar_index"></param> private void UseSkill(BaseCharacter attacker, int att_index, BaseCharacter target, int tar_index) { //过程中生存游戏提示信息的文本 string text = ""; int tempdamage = 0; MyDraw.DrawCharacterInfo(attacker, att_index); text = string.Format("{0}对{1}施放了{2}", attacker.name, target.name, name); MyDraw.DrawBattleMessageDelay(text); if (targetType == TargetType.EnemyMulti || targetType == TargetType.EnemySingle) { if (attacker.type == CharacterType.Hero) { MyDraw.DrawAttackAnimation(attacker, att_index, target, tar_index); } else { MyDraw.DrawAttackAnimationEnemy(attacker, att_index, target, tar_index); } } //对即时伤害的技能的处理 if (type == SkillType.Damage || type == SkillType.NormalAttack) { //获取技能的基础伤害值 if (skillDamage != null) { tempdamage = skillDamage.Invoke(attacker, target); //判断目标是否无敌 if (target.IsInvincible()) { return; } //判断目标是否具有技能伤害类型对应的反射状态 if (damageType == DamageType.Physical) { if (target.IsPhysicalReflect()) { if (target.type == CharacterType.Hero) { MyDraw.DrawAttackAnimation(target, tar_index, attacker, att_index); } else { MyDraw.DrawAttackAnimationEnemy(target, tar_index, attacker, att_index); } if (attacker.IsInvincible()) { return; } else { //获取攻击者和目标身上的物理伤害加深BUFF并且计算他们的效果 tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.PhysicalDamageIncrease); tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.PhysicalBeDamageIncrease); attacker.GetDamage(tempdamage, att_index); return; } } if (!IsHit(attacker) && noMiss == false) { text = string.Format("{0}未能击中目标!", attacker.name); MyDraw.DrawBattleMessageDelay(text); return; } if (IsCrit(attacker) || mustCrit == true) { text = string.Format("{0}触发了会心一击!", attacker.name); MyDraw.DrawBattleMessageDelay(text); tempdamage = tempdamage * 15 / 10; } //获取攻击者和目标身上的物理伤害加深BUFF并且计算他们的效果 tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.PhysicalDamageIncrease); tempdamage = target.GetIncreaseDamage(tempdamage, StateType.PhysicalBeDamageIncrease); } else if (damageType == DamageType.Magic) { if (target.IsMagicReflect()) { if (target.type == CharacterType.Hero) { MyDraw.DrawAttackAnimation(target, tar_index, attacker, att_index); } else { MyDraw.DrawAttackAnimationEnemy(target, tar_index, attacker, att_index); } if (attacker.IsInvincible()) { return; } else { //获取攻击者和目标身上的魔法伤害加深BUFF并且计算他们的效果 tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.MagicDamageIncrease); tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.MagicBeDamageIncrease); attacker.GetDamage(tempdamage, att_index); return; } } else { //获取攻击者和目标身上的魔法伤害加深BUFF并且计算他们的效果 tempdamage = attacker.GetIncreaseDamage(tempdamage, StateType.MagicDamageIncrease); tempdamage = target.GetIncreaseDamage(tempdamage, StateType.MagicBeDamageIncrease); } } //进行即时伤害并且生成对应的文字信息 for (int t = 0; t < hitTimes; t++) { int realdamage = Convert.ToInt32(tempdamage + tempdamage * Program.random.Next(-dispersion, dispersion) * 0.01); //处理即死效果 if (isDeathNow) { if (Program.random.Next(0, 100) < deathRatio) { MyDraw.DrawBattleMessageDelay("触发了即死效果。"); realdamage = target.maxHp; } } if (!target.GetDamage(realdamage, tar_index)) { break; } } } //如果技能有特殊效果,执行特殊效果 if (skillEffect != null) { MyDraw.DrawEffectAnimation(target, tar_index); skillEffect.Invoke(attacker, target); MyDraw.DrawState(target, tar_index); } return; } //对即时回复类技能的处理 if (type == SkillType.Heal) { if (skillDamage != null) { tempdamage = skillDamage.Invoke(attacker, target); if (!target.IsForbidHeal()) { target.GetRecover(tempdamage, tar_index); } } if (skillEffect != null) { MyDraw.DrawEffectAnimation(target, tar_index); skillEffect.Invoke(attacker, target); MyDraw.DrawState(target, tar_index); } return; } //对状态类技能的处理,主要是Buff,Debuff等 if (type == SkillType.State) { if (skillEffect != null) { MyDraw.DrawEffectAnimation(target, tar_index); skillEffect.Invoke(attacker, target); MyDraw.DrawState(target, tar_index); } } return; }