1
This commit is contained in:
@@ -34,4 +34,9 @@ public class BattleCharacter : DataAttribute {
|
||||
hitPoint = new Vector2Int(character.HitPoint, character.HitPoint);
|
||||
armorClass = character.ArmorClass;
|
||||
}
|
||||
|
||||
/// <summary> 攻击目标 </summary>
|
||||
public bool AttackTarget(BattleCharacter target) {
|
||||
return team != target.team && target.hitPoint.x > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ public class PhaseAction : BattlePhase {
|
||||
// 选择行动目标,没有行动目标则进入结算阶段
|
||||
if (!BattleQueue.Dequeue(out BattleCharacter character)) { simulator.Transition(PhaseType.结算阶段); return; }
|
||||
// 判断是否可以行动
|
||||
|
||||
// 选择一个目标
|
||||
|
||||
if (ActionPredicate(character)) { return; }
|
||||
// 选择一个可以攻击的目标
|
||||
BattleCharacter target = BattleQueue.FirstOrDefault(obj => character.AttackTarget(obj));
|
||||
// 对目标进行攻击
|
||||
|
||||
// TODO:记录器
|
||||
@@ -27,4 +27,10 @@ public class PhaseAction : BattlePhase {
|
||||
public override void QuitPhase() {
|
||||
// throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary> 行动判断 </summary>
|
||||
private bool ActionPredicate(BattleCharacter character) {
|
||||
return character.hitPoint.x > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,14 @@ public class BattleQueue {
|
||||
public void OrderByDescending(Func<BattleCharacter, int> func) {
|
||||
characters = characters.OrderByDescending(func).ToList();
|
||||
}
|
||||
/// <summary> 根据条件查询元素 </summary>
|
||||
public List<BattleCharacter> Where(Func<BattleCharacter, bool> predicate) {
|
||||
return characters.Where(predicate).ToList();
|
||||
}
|
||||
/// <summary> 根据条件查询第一个匹配的元素 </summary>
|
||||
public BattleCharacter FirstOrDefault(Func<BattleCharacter, bool> predicate) {
|
||||
return characters.FirstOrDefault(predicate);
|
||||
}
|
||||
/// <summary> 更新队列 </summary>
|
||||
public void UpdateQueue() {
|
||||
queue = new Queue<BattleCharacter>(characters);
|
||||
|
||||
Reference in New Issue
Block a user