using System;
using System.Collections.Generic;
using System.Configuration;
using UnityEngine;
namespace Game
{
public enum E_MOTION_TYPE
{
None,
Attack_1,
Attack_2,
}
public class MontionkeyClass
{
public int Frame;
public E_MOTION_TYPE MontionType;
}
//主控玩家角色操作数据
public class InputMotionData
{
///
/// 释放出来的行为历史
///
List KeyHistory = new List();
static Queue tempHistoryQueue = new Queue();
const int MontionHistoryLimit = 10;
public void Init()
{
ClearHistoryMotion();
}
MontionkeyClass EnqueueOneMotionHistory()
{
if (tempHistoryQueue.Count > 0)
return tempHistoryQueue.Dequeue();
return new MontionkeyClass();
}
public void AddMontionKey(E_MOTION_TYPE type)
{
while (KeyHistory.Count > MontionHistoryLimit)
{
tempHistoryQueue.Enqueue(KeyHistory[0]);
KeyHistory.RemoveAt(0);
}
MontionkeyClass motion = EnqueueOneMotionHistory();
motion.Frame = Time.frameCount;
motion.MontionType = type;
KeyHistory.Add(motion);
}
public void ClearHistoryMotion()
{
for (int i = 0; i < KeyHistory.Count; i++)
{
tempHistoryQueue.Enqueue(KeyHistory[i]);
}
KeyHistory.Clear();
}
public bool CheckHistoryLastMotion(E_MOTION_TYPE type)
{
if (KeyHistory.Count == 0)
return false;
return KeyHistory[KeyHistory.Count - 1].MontionType == type;
}
///
/// 检查连续行为是否匹配
///
///
///
public bool CheckHistoryLastMotion(E_MOTION_TYPE[] types)
{
if (KeyHistory.Count < types.Length)
return false;
for (int i = 0; i < types.Length; i++)
{
if (KeyHistory[KeyHistory.Count - i - 1].MontionType != types[types.Length - i - 1])
{
return false;
}
}
return true;
}
}
}