mirror of
https://github.com/imperialsushi/gutterball-3.git
synced 2025-06-15 05:07:42 +00:00
66 lines
1.5 KiB
C#
66 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ActionReplay : MonoBehaviour
|
|
{
|
|
public List<ActionReplayRecord> actionReplayRecords = new List<ActionReplayRecord>();
|
|
private Game game;
|
|
private Rigidbody rigidBody;
|
|
private Vector3 velocity;
|
|
private Vector3 angularVelocity;
|
|
|
|
void Start ()
|
|
{
|
|
game = GameObject.FindObjectOfType<Game>();
|
|
rigidBody = GetComponent<Rigidbody>();
|
|
}
|
|
|
|
void Update ()
|
|
{
|
|
if (!rigidBody.isKinematic)
|
|
{
|
|
velocity = rigidBody.velocity;
|
|
angularVelocity = rigidBody.angularVelocity;
|
|
}
|
|
}
|
|
|
|
public void RigidBodyCollider(bool isCollider)
|
|
{
|
|
foreach (Collider collider in GetComponents<Collider>())
|
|
{
|
|
collider.enabled = isCollider;
|
|
}
|
|
}
|
|
|
|
public void RigidBodyFreeze(bool isFreeze)
|
|
{
|
|
rigidBody.isKinematic = isFreeze;
|
|
}
|
|
|
|
public void Add()
|
|
{
|
|
actionReplayRecords.Add(new ActionReplayRecord { position = transform.position, rotation = transform.rotation });
|
|
}
|
|
|
|
public void Clear ()
|
|
{
|
|
actionReplayRecords.Clear();
|
|
}
|
|
|
|
public void SetTransform(float index)
|
|
{
|
|
game.currentReplayIndex = index;
|
|
|
|
ActionReplayRecord record = actionReplayRecords[(int)index];
|
|
|
|
transform.position = record.position;
|
|
transform.rotation = record.rotation;
|
|
}
|
|
|
|
public void SetVelocity()
|
|
{
|
|
rigidBody.velocity = velocity;
|
|
rigidBody.angularVelocity = angularVelocity;
|
|
}
|
|
}
|