add project files
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class CamController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public Camera cam;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("smoothTime")]
|
||||
private float _smoothTime = 0.2f;
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("houseSmoothTime")]
|
||||
private float _houseSmoothTime = 0.2f;
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("followTargetOnX")]
|
||||
private bool _followTargetOnX;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("smoothFogDuration")]
|
||||
private float _smoothFogDuration = 0.5f;
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("houseFogStartDist")]
|
||||
private float _houseFogStartDist = 50f;
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("houseFogEndDist")]
|
||||
private float _houseFogEndDist = 50f;
|
||||
[SerializeField]
|
||||
private Animator anim;
|
||||
|
||||
private Player followTarget;
|
||||
|
||||
private Vector3 _posVelocity;
|
||||
|
||||
private float _fogEndDistanceBefore;
|
||||
|
||||
private float _fogStartDistanceBefore;
|
||||
|
||||
public void Warmup()
|
||||
{
|
||||
base.transform.position = followTarget.transform.position;
|
||||
anim.SetBool("HouseMode", value: false);
|
||||
anim.SetBool("RoomMode", value: false);
|
||||
anim.SetTrigger("Reset");
|
||||
anim.SetFloat("CamNew", 0f);
|
||||
anim.SetBool("HouseMode", value: false);
|
||||
}
|
||||
|
||||
public void SetTarget(Player followTarget)
|
||||
{
|
||||
this.followTarget = followTarget;
|
||||
}
|
||||
|
||||
public void Go()
|
||||
{
|
||||
anim.SetTrigger("Go");
|
||||
}
|
||||
|
||||
public void Win(bool best)
|
||||
{
|
||||
anim.SetBool("BestWin", best);
|
||||
anim.SetTrigger("Win");
|
||||
}
|
||||
|
||||
public void GameOver()
|
||||
{
|
||||
anim.SetTrigger("GameOver");
|
||||
}
|
||||
|
||||
public void Revive()
|
||||
{
|
||||
anim.SetTrigger("Revive");
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (followTarget == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Transform target = followTarget.movePlayer.toMove.transform;
|
||||
float smooth = _smoothTime;
|
||||
Vector3 targetPos = target.position;
|
||||
if (!_followTargetOnX)
|
||||
{
|
||||
targetPos.x = 0f;
|
||||
}
|
||||
base.transform.position = Vector3.SmoothDamp(base.transform.position, targetPos, ref _posVelocity, smooth, float.PositiveInfinity, Time.deltaTime);
|
||||
base.transform.rotation = followTarget.transform.rotation;
|
||||
}
|
||||
|
||||
private IEnumerator SmoothChangeFogRoutine(bool show)
|
||||
{
|
||||
float from = RenderSettings.fogEndDistance;
|
||||
float to = show ? _houseFogEndDist : _fogEndDistanceBefore;
|
||||
for (float t = 0f; t < _smoothFogDuration; t += Time.deltaTime)
|
||||
{
|
||||
RenderSettings.fogEndDistance = Mathf.Lerp(from, to, t / _smoothFogDuration);
|
||||
yield return null;
|
||||
}
|
||||
RenderSettings.fogEndDistance = to;
|
||||
}
|
||||
|
||||
public void ShopCam(string trigger)
|
||||
{
|
||||
anim.ResetTrigger("ExitShop");
|
||||
anim.SetTrigger(trigger);
|
||||
}
|
||||
|
||||
public void ExitShop()
|
||||
{
|
||||
anim.SetTrigger("ExitShop");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user