/// <summary> /// 执行DOT效果 /// </summary> /// <param name="index"></param> public void ExeCountEndState(int index) { foreach (State s in state) { if (s.type != StateType.DamageOverTime && s.type != StateType.HealOverTime) { continue; } string text = string.Format("因为{0}的效果!", s.name); if (s.type == StateType.DamageOverTime) { if (s.times == 0 && s.counts == 0) { continue; } if (s.times > 0) { s.times--; } MyDraw.DrawBattleMessage(text); if (!IsInvincible()) { GetDamage(s.damage, index); } } } }
/// <summary> /// 执行HOT效果 /// </summary> /// <param name="index"></param> public void ExeCountStartState(int index) { foreach (State s in state) { if (s.type != StateType.DamageOverTime && s.type != StateType.HealOverTime) { continue; } string text = string.Format("因为{0}的效果!", s.name); if (s.type == StateType.HealOverTime) { if (s.times == 0 && s.counts == 0) { continue; } if (s.times > 0) { s.times--; } MyDraw.DrawBattleMessage(text); if (!IsForbidHeal()) { GetRecover(s.hprecover, index); } } } }
public int GetPartyChoice() { int temp = 0; MyDraw.DrawChoiced(temp, players[temp].Name, textPos[temp]); bool enter = false; while (!enter) { ConsoleKeyInfo key = Console.ReadKey(true); if (key.Key == ConsoleKey.LeftArrow) { if (temp > 0) { MyDraw.ClearLine(21); MyDraw.DrawChoiceText(temp, players[temp].Name, textPos[temp]); temp = temp - 1; MyDraw.DrawChoiced(temp, players[temp].Name, textPos[temp]); } } else if (key.Key == ConsoleKey.RightArrow) { if (temp < textPos.Count - 1) { MyDraw.ClearLine(21); MyDraw.DrawChoiceText(temp, players[temp].Name, textPos[temp]); temp = temp + 1; MyDraw.DrawChoiced(temp, players[temp].Name, textPos[temp]); } } else if (key.Key == ConsoleKey.Enter) { if (players[temp].CanBeTarget(tempSkill)) { MyDraw.ClearChoiceText(); break; } else { MyDraw.DrawBattleMessage("无法选择已经死亡的目标,请重新选择"); } } else if (key.Key == ConsoleKey.Escape) { MyDraw.ClearLine(1); return(-1); } } return(temp); }
/// <summary> /// 检查游戏是否已经结束 /// </summary> /// <returns></returns> private bool IsGameOver() { if (IsAllDead(enemys)) { MyDraw.DrawBattleMessage("敌人全灭,玩家胜利!"); return(true); } if (IsAllDead(players)) { MyDraw.DrawBattleMessage("玩家全灭,战斗失败!"); return(true); } return(false); }
/// <summary> /// 判断某个角色是否可以使用技能 /// </summary> /// <param name="attacker"></param> /// <returns></returns> public bool CanUseSkill(BaseCharacter attacker) { if (attacker.Hp <= hpCost || attacker.Mp < mpCost) { MyDraw.DrawBattleMessage("无法使用技能:Hp或者mp不满足技能的最小消耗!"); return(false); } if (attacker.IsSilence() && type != SkillType.NormalAttack) { MyDraw.DrawBattleMessage(attacker.Name + " 无法使用技能: 被沉默了!"); return(false); } return(true); }
/// <summary> /// 玩家开始行动 /// </summary> private void PlayerAction() { for (int i = 0; i < players.Count; i++) { if (players[i].Hp <= 0 || players[i].IsDizzy()) { //混乱的,也不能行动 continue; } actionIndex = i; textPos.Clear(); SetSkillPos(); DrawPlayerSkills(); MyDraw.DrawIntroText($"当前回合为{players[actionIndex].Name}行动了,请选择指令:"); tempSkill = players[actionIndex].skill[GetSkillChoice(players[actionIndex])]; MyDraw.DrawBattleMessage(players[actionIndex].Name + "选择了技能 " + tempSkill.name); //技能一共作用对象为5种:单个敌人、多个敌人、单个队友、多个队友、只能自身 if (tempSkill.targetType == TargetType.EnemySingle) { MyDraw.DrawIntroText("请选择目标:"); SetEnemyPos(); DrawEnemy(); chooseEnemyIndex = GetEnemyChoice(); if (chooseEnemyIndex == -1) { i--; continue; } tempSkill.UseSkillSingle(players[actionIndex], actionIndex, enemys[chooseEnemyIndex], chooseEnemyIndex); } if (tempSkill.targetType == TargetType.EnemyMulti) { tempSkill.UseSkillMulti(players[actionIndex], actionIndex, enemys); } if (tempSkill.targetType == TargetType.PartySingle) { MyDraw.DrawIntroText("请选择目标:"); SetPartyPos(); DrawParty(); choosePartyIndex = GetPartyChoice(); if (choosePartyIndex == -1) { i--; continue; } tempSkill.UseSkillSingle(players[actionIndex], actionIndex, players[choosePartyIndex], choosePartyIndex); } if (tempSkill.targetType == TargetType.PartyMulti) { tempSkill.UseSkillMulti(players[actionIndex], actionIndex, players); } if (tempSkill.targetType == TargetType.Self) { tempSkill.UseSkillSingle(players[actionIndex], actionIndex, players[actionIndex], actionIndex); } textPos.Clear(); } }