| | |
| | | |
| | | public class RecordPlayer |
| | | { |
| | | |
| | | |
| | | // 初始化之前允许的record action类型 |
| | | private readonly static List<Type> allowedActionTypes = new List<Type>() |
| | | { |
| | | typeof(BattleStartAction), |
| | | typeof(PreloadResAction), |
| | | }; |
| | | |
| | | private List<RecordAction> tempPreinitRecordActionList = new List<RecordAction>(); |
| | | |
| | | protected BattleField battleField; |
| | | |
| | | private Queue<RecordAction> recordActionQueue = new Queue<RecordAction>(); |
| | |
| | | public void PlayRecord(RecordAction recordAction) |
| | | { |
| | | if (recordAction == null) return; |
| | | if (!CheckRecordType(recordAction)) return; |
| | | recordAction.actionOwner = this; |
| | | // Debug.LogError("Enqueue record action " + recordAction.GetType() + " to queue"); |
| | | if (isForceFinish || stepForcefinish) |
| | |
| | | public void PlayRecord(RecordAction recordAction, RecordAction waitingAnimeAction) |
| | | { |
| | | if (recordAction == null) return; |
| | | if (!CheckRecordType(recordAction)) return; |
| | | recordAction.actionOwner = this; |
| | | // Debug.LogError("Enqueue record action " + recordAction.GetType() + " to queue"); |
| | | if (isForceFinish || stepForcefinish) |
| | |
| | | public void InsertRecord(RecordAction recordAction, int position = 0) |
| | | { |
| | | if (recordAction == null) return; |
| | | if (!CheckRecordType(recordAction)) return; |
| | | recordAction.actionOwner = this; |
| | | if (isForceFinish || stepForcefinish) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private bool CheckRecordType(RecordAction recordAction) |
| | | { |
| | | if (battleField.IsInit) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | if (!allowedActionTypes.Contains(recordAction.GetType())) |
| | | { |
| | | tempPreinitRecordActionList.Add(recordAction); |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public virtual void Run() |
| | | { |
| | | |
| | | if (battleField != null) |
| | | { |
| | | if (!battleField.IsInit) |
| | | { |
| | | return; |
| | | } |
| | | if (tempPreinitRecordActionList.Count > 0) |
| | | { |
| | | foreach (var action in tempPreinitRecordActionList) |
| | | { |
| | | PlayRecord(action); |
| | | } |
| | | tempPreinitRecordActionList.Clear(); |
| | | } |
| | | } |
| | | |
| | | ImmediatelyPlayRun(); |
| | | |
| | | // 等待下一个action |