96 lines
2.3 KiB
C#
96 lines
2.3 KiB
C#
![]() |
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace G
|
|||
|
{
|
|||
|
public class Cutin01 : MonoBehaviour
|
|||
|
{
|
|||
|
private float _startTime;
|
|||
|
|
|||
|
private float _prevTimescale = 1f;
|
|||
|
|
|||
|
private Vector3 _originScale = Vector3.zero;
|
|||
|
|
|||
|
private Vector3 _originPos = Vector3.zero;
|
|||
|
|
|||
|
private float _startLerp;
|
|||
|
|
|||
|
private float _endLerp;
|
|||
|
|
|||
|
private bool _cinematicMode;
|
|||
|
|
|||
|
private EntityMainPlayer _scriptCha;
|
|||
|
|
|||
|
private GameCamera _scriptCam;
|
|||
|
|
|||
|
public Transform bg_black;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
_scriptCha = EntityMainPlayer.Instance;// GameObject.FindWithTag("Player").GetComponent<EntityMainPlayer>();
|
|||
|
_scriptCam = Camera.main.GetComponent<GameCamera>();
|
|||
|
this.GetComponent<Renderer>().enabled = false;
|
|||
|
this.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public void CutinOn(Vector3 startpos, Vector3 finishpos, Vector3 _originscale, float timescale, float a, float b, bool cinema)
|
|||
|
{
|
|||
|
_originScale = _originscale;
|
|||
|
//this.GetComponent<Renderer>().enabled = true;
|
|||
|
_prevTimescale = Time.timeScale;
|
|||
|
_startTime = Time.unscaledTime;
|
|||
|
transform.position = startpos;
|
|||
|
transform.localScale = _originScale * 10f;
|
|||
|
Time.timeScale = 1f;
|
|||
|
_originPos = finishpos;
|
|||
|
_startLerp = a;
|
|||
|
_endLerp = b;
|
|||
|
_cinematicMode = cinema;
|
|||
|
}
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (Time.timeScale <= float.Epsilon)
|
|||
|
return;
|
|||
|
|
|||
|
if (!this.GetComponent<Renderer>().enabled)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
if (_cinematicMode)
|
|||
|
{
|
|||
|
//_scriptCha.StopControl();
|
|||
|
_cinematicMode = false;
|
|||
|
}
|
|||
|
if (_startTime > 0f)
|
|||
|
{
|
|||
|
if (Time.unscaledTime - _startTime < _startLerp)
|
|||
|
{
|
|||
|
transform.position = Vector3.Lerp(transform.position, _originPos, Time.unscaledDeltaTime * 3f);
|
|||
|
transform.localScale = Vector3.Lerp(transform.localScale, _originScale, Time.unscaledDeltaTime * 5f);
|
|||
|
return;
|
|||
|
}
|
|||
|
if (Time.unscaledTime - _startTime < _endLerp)
|
|||
|
{
|
|||
|
Time.timeScale = _prevTimescale;
|
|||
|
transform.localScale = Vector3.Lerp(transform.localScale, _originScale * 10f, Time.unscaledDeltaTime * 0.5f);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Time.timeScale = 1f;
|
|||
|
_scriptCam.Reset();
|
|||
|
//_scriptCha.StartControl();
|
|||
|
this.GetComponent<Renderer>().enabled = false;
|
|||
|
_startTime = 0f;
|
|||
|
transform.localScale = _originScale * 10f;
|
|||
|
transform.position = new Vector3(-2f, 1f, 0f);
|
|||
|
this.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|