48 lines
876 B
C#
48 lines
876 B
C#
using UnityEngine;
|
|
|
|
public class HeadFlashlight : MonoBehaviour
|
|
{
|
|
public Light light;
|
|
|
|
private PlayerMain mPlayer;
|
|
|
|
private Vector3 lightStartRotation;
|
|
|
|
private void Start()
|
|
{
|
|
lightStartRotation = light.transform.localEulerAngles;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!ScriptsHandler.Instance)
|
|
{
|
|
return;
|
|
}
|
|
if ((bool)mPlayer)
|
|
{
|
|
switch (mPlayer.m_CameraTypeView)
|
|
{
|
|
case PlayerMain.CameraTypeView.FirstPerson:
|
|
light.transform.localEulerAngles = mPlayer.currentCameraView.transform.localEulerAngles;
|
|
break;
|
|
case PlayerMain.CameraTypeView.ThirdPerson:
|
|
light.transform.localEulerAngles = lightStartRotation;
|
|
break;
|
|
}
|
|
}
|
|
else if (!mPlayer)
|
|
{
|
|
mPlayer = ScriptsHandler.Instance.m_PlayerMain;
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if ((bool)ScriptsHandler.Instance)
|
|
{
|
|
mPlayer = ScriptsHandler.Instance.m_PlayerMain;
|
|
}
|
|
}
|
|
}
|