完善影子特效

This commit is contained in:
sin365 2023-01-09 14:49:45 +08:00
parent 74d968ed94
commit 3be7c34642

View File

@ -28,6 +28,9 @@ public class RoleFastShadow : MonoBehaviour
public int CurrPlayIndex = -1;
public float NextPlayTime = 0;
public float SnapStepStartTime = 0;
public Vector3 SnapStepStartPos = Vector3.zero;
public Vector3 NextPos = Vector3.zero;
public bool bCanPlay = false;
public float StartPlayTime;
@ -110,12 +113,22 @@ public class RoleFastShadow : MonoBehaviour
StartPlayTime = 0;
CurrPlayIndex = -1;
NextPlayTime = 0;
StartPlayTime = Time.time;
StartPlayTime = Time.time;
NextPos = Vector3.zero;
}
}
public void Update()
{
if (NextPos != Vector3.zero)
{
if (NextPlayTime - SnapStepStartTime <= 0)//±ÜÃâ·ÖĸΪ0
return;
Vector3 stepPr = ( (NextPos - SnapStepStartPos) * (Time.time - SnapStepStartTime) / (NextPlayTime - SnapStepStartTime) );
transform.position = SnapStepStartPos + stepPr + offset;
}
//未到达播放下一帧的事件
if (!bCanPlay || Time.time < NextPlayTime)
return;
@ -129,6 +142,8 @@ public class RoleFastShadow : MonoBehaviour
mSpriteRenderer.sprite = snap.mSprite;
mBridgeTransfrom.localEulerAngles = snap.BridgeDir;
transform.position = snap.Pos + offset;
SnapStepStartPos = transform.position;
SnapStepStartTime = Time.time;
//没有后续帧了
if (KeyHistory.Count < CurrPlayIndex + 2)
@ -139,6 +154,7 @@ public class RoleFastShadow : MonoBehaviour
else//后续帧
{
NextPlayTime = StartPlayTime + KeyHistory[CurrPlayIndex + 1].time;
NextPos = KeyHistory[CurrPlayIndex + 1].Pos;
}
}