88 lines
2.2 KiB
C#
88 lines
2.2 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Configuration;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace Game
|
|||
|
{
|
|||
|
|
|||
|
public class RoleSnapshotClass
|
|||
|
{
|
|||
|
public float time;
|
|||
|
public Sprite mSprite;
|
|||
|
public Vector3 BridgeDir;
|
|||
|
public Vector3 Pos;
|
|||
|
public void Reset()
|
|||
|
{
|
|||
|
time = 0;
|
|||
|
mSprite = null;
|
|||
|
BridgeDir = Vector3.zero;
|
|||
|
Pos = Vector3.zero;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public class SnapshotData
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// <20>ͷų<CDB7><C5B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʷ
|
|||
|
/// </summary>
|
|||
|
List<RoleSnapshotClass> KeyHistory = new List<RoleSnapshotClass>();
|
|||
|
static Queue<RoleSnapshotClass> tempHistoryQueue = new Queue<RoleSnapshotClass>();
|
|||
|
const int HistoryLimit = 10;
|
|||
|
|
|||
|
public SnapshotData()
|
|||
|
{
|
|||
|
Init();
|
|||
|
}
|
|||
|
|
|||
|
void Init()
|
|||
|
{
|
|||
|
ClearHistory();
|
|||
|
}
|
|||
|
|
|||
|
RoleSnapshotClass EnqueueOneMotionHistory()
|
|||
|
{
|
|||
|
if (tempHistoryQueue.Count > 0)
|
|||
|
return tempHistoryQueue.Dequeue();
|
|||
|
|
|||
|
return new RoleSnapshotClass();
|
|||
|
}
|
|||
|
|
|||
|
public void AddSnap(Sprite sprite,Vector3 bridgeDir,Vector3 pos)
|
|||
|
{
|
|||
|
while (KeyHistory.Count > HistoryLimit)
|
|||
|
{
|
|||
|
KeyHistory[0].Reset();
|
|||
|
tempHistoryQueue.Enqueue(KeyHistory[0]);
|
|||
|
KeyHistory.RemoveAt(0);
|
|||
|
}
|
|||
|
|
|||
|
RoleSnapshotClass snap = EnqueueOneMotionHistory();
|
|||
|
snap.time = Time.time;
|
|||
|
snap.mSprite = sprite;
|
|||
|
snap.BridgeDir = bridgeDir;
|
|||
|
snap.Pos = pos;
|
|||
|
KeyHistory.Add(snap);
|
|||
|
}
|
|||
|
|
|||
|
public void ClearHistory()
|
|||
|
{
|
|||
|
for (int i = 0; i < KeyHistory.Count; i++)
|
|||
|
{
|
|||
|
KeyHistory[i].Reset();
|
|||
|
tempHistoryQueue.Enqueue(KeyHistory[i]);
|
|||
|
}
|
|||
|
KeyHistory.Clear();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD>ú<EFBFBD><C3BA>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD>ȿ<EFBFBD><C8BF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public RoleSnapshotClass[] GetHistoryArray()
|
|||
|
{
|
|||
|
return KeyHistory.ToArray();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|