2023-01-12 23:49:16 +08:00
|
|
|
|
using Axibug;
|
|
|
|
|
using Axibug.Event;
|
2023-01-07 23:24:18 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Game
|
|
|
|
|
{
|
|
|
|
|
public enum E_MOTION_TYPE
|
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
Attack_1,
|
|
|
|
|
Attack_2,
|
2023-01-12 23:49:16 +08:00
|
|
|
|
Attack_3,
|
2023-01-07 23:24:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MontionkeyClass
|
|
|
|
|
{
|
|
|
|
|
public int Frame;
|
|
|
|
|
public E_MOTION_TYPE MontionType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public class InputMotionData
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>ͷų<CDB7><C5B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʷ
|
|
|
|
|
/// </summary>
|
|
|
|
|
List<MontionkeyClass> KeyHistory = new List<MontionkeyClass>();
|
|
|
|
|
static Queue<MontionkeyClass> tempHistoryQueue = new Queue<MontionkeyClass>();
|
|
|
|
|
const int MontionHistoryLimit = 10;
|
|
|
|
|
|
2023-01-12 23:49:16 +08:00
|
|
|
|
bool mNeedClear = false;
|
|
|
|
|
const float ClearCD = 0.3f;
|
|
|
|
|
//ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
float flagTime = 0;
|
|
|
|
|
bool NeedClear { get { return mNeedClear; }
|
|
|
|
|
set {
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
flagTime = ClearCD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
flagTime = 0;
|
|
|
|
|
}
|
|
|
|
|
mNeedClear = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-07 23:24:18 +08:00
|
|
|
|
public void Init()
|
|
|
|
|
{
|
|
|
|
|
ClearHistoryMotion();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-12 23:49:16 +08:00
|
|
|
|
public void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
AppEntry.Event.Subscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnDestory()
|
|
|
|
|
{
|
|
|
|
|
AppEntry.Event.Unsubscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnMainPlayerInAttackEventArgs(object sender, LogicEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MainPlayerOnceAttackEventArgs msg = (MainPlayerOnceAttackEventArgs)e;
|
|
|
|
|
if (msg == null) throw new GameException("MainPlayerOnceAttackEventArgs is null");
|
|
|
|
|
if (msg.RoleID == GamePlayEntry.MainPlayer.Player.RoleID)
|
|
|
|
|
{
|
|
|
|
|
if (msg.Step == E_ONCEATTACK_STEP.InAttack)
|
|
|
|
|
NeedClear = false;
|
|
|
|
|
else if(msg.Step == E_ONCEATTACK_STEP.None)
|
|
|
|
|
NeedClear = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-07 23:24:18 +08:00
|
|
|
|
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();
|
2023-01-12 23:49:16 +08:00
|
|
|
|
NeedClear = false;
|
|
|
|
|
AxibugLog.Debug("<22><><EFBFBD><EFBFBD>MotionHistory");
|
2023-01-07 23:24:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CheckHistoryLastMotion(E_MOTION_TYPE type)
|
|
|
|
|
{
|
|
|
|
|
if (KeyHistory.Count == 0)
|
|
|
|
|
return false;
|
|
|
|
|
return KeyHistory[KeyHistory.Count - 1].MontionType == type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>Ƿ<EFBFBD>ƥ<EFBFBD><C6A5>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="types"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
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;
|
|
|
|
|
}
|
2023-01-12 23:49:16 +08:00
|
|
|
|
|
|
|
|
|
public void Update_Logic()
|
|
|
|
|
{
|
|
|
|
|
if (NeedClear)
|
|
|
|
|
{
|
|
|
|
|
flagTime -= Time.deltaTime;
|
|
|
|
|
if (flagTime <= 0)
|
|
|
|
|
{
|
|
|
|
|
ClearHistoryMotion();
|
|
|
|
|
NeedClear = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-07 23:24:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|