1
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Palmmedia.ReportGenerator.Core;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
@@ -31,7 +34,73 @@ public class BattleSimulator {
|
||||
|
||||
// 哥布林射手死亡
|
||||
|
||||
public BattleSimulator() {
|
||||
/// <summary> 回合计数 </summary>
|
||||
public int roundCount;
|
||||
/// <summary> 行动间隔 </summary>
|
||||
public float interval;
|
||||
/// <summary> 最大间隔 </summary>
|
||||
public float maxInterval = 1f;
|
||||
/// <summary> 当前行动 </summary>
|
||||
public Action currentAction;
|
||||
/// <summary> 队伍1 </summary>
|
||||
public BattleTeam team1;
|
||||
/// <summary> 队伍2 </summary>
|
||||
public BattleTeam team2;
|
||||
/// <summary> 战斗队列 </summary>
|
||||
public BattleQueue battleQueue = new BattleQueue();
|
||||
|
||||
public BattleSimulator(List<DataCharacter> cha1, List<DataCharacter> cha2) {
|
||||
List<BattleCharacter> bCha1 = new List<BattleCharacter>();
|
||||
cha1.ForEach(obj => bCha1.Add(new BattleCharacter(obj)));
|
||||
List<BattleCharacter> bCha2 = new List<BattleCharacter>();
|
||||
cha2.ForEach(obj => bCha2.Add(new BattleCharacter(obj)));
|
||||
|
||||
team1 = new BattleTeam(bCha1);
|
||||
team2 = new BattleTeam(bCha2);
|
||||
|
||||
battleQueue.Add(bCha1);
|
||||
battleQueue.Add(bCha2);
|
||||
battleQueue.Sequence();
|
||||
battleQueue.OrderByDescending();
|
||||
|
||||
currentAction = UpdateRound;
|
||||
}
|
||||
public void Update() {
|
||||
if (interval > 0) { interval -= Time.deltaTime; return; }
|
||||
currentAction?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary> 更新回合 </summary>
|
||||
public void UpdateRound() {
|
||||
roundCount++;
|
||||
battleQueue.Reset();
|
||||
Debug.Log($"正式回合 {roundCount}");
|
||||
|
||||
interval = maxInterval;
|
||||
currentAction = SelectActionTarget;
|
||||
}
|
||||
/// <summary> 选择行动对象 </summary>
|
||||
public void SelectActionTarget() {
|
||||
if (!battleQueue.Current(out BattleCharacter character)) {
|
||||
currentAction = UpdateRound; return;
|
||||
}
|
||||
Debug.Log($"当前 {character.name}({character.sequence}) 行动");
|
||||
|
||||
interval = maxInterval;
|
||||
currentAction = SelectActionTarget;
|
||||
}
|
||||
public void SelectAttackTarget(BattleCharacter character) {
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 战斗队伍
|
||||
/// </summary>
|
||||
public class BattleTeam {
|
||||
|
||||
public List<BattleCharacter> characters;
|
||||
|
||||
public BattleTeam(List<BattleCharacter> characters) {
|
||||
this.characters = characters;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user