forked from zxl/LaboratoryProtection
138 lines
3.9 KiB
C#
138 lines
3.9 KiB
C#
//using Lazy;
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
using PMaker.DependencyInjection;
|
|
|
|
using UnityEngine;
|
|
|
|
namespace Rainier
|
|
{
|
|
public class PlayerLogicR : SingletonMonobehaviour
|
|
{
|
|
public Transform player;
|
|
public Transform cameraRig;
|
|
public Transform pivot;
|
|
|
|
|
|
private void Reset()
|
|
{
|
|
var playerNew = GameObject.Find("Player");
|
|
player = playerNew.transform.Find("FirstViewPlayer");
|
|
cameraRig = playerNew.transform.Find("ThirdViewCameras/FreeLookCameraRig");
|
|
pivot = playerNew.transform.Find("ThirdViewCameras/FreeLookCameraRig/Pivot");
|
|
}
|
|
|
|
public Vector3 Position
|
|
{
|
|
get => this.player.localPosition;
|
|
set
|
|
{
|
|
this.player.localPosition = value;
|
|
Teleport();
|
|
}
|
|
}
|
|
|
|
public Vector3 FacingAngle
|
|
{
|
|
get
|
|
{
|
|
return new Vector3()
|
|
{
|
|
x = this.pivot.transform.localRotation.x,
|
|
y = this.player.transform.localRotation.y,
|
|
};
|
|
}
|
|
|
|
set
|
|
{
|
|
this.pivot.transform.localRotation = Quaternion.Euler(value.x, 0.0f, 0.0f);
|
|
this.player.transform.localRotation = Quaternion.Euler(0.0f, value.y, 0.0f);
|
|
this.Teleport();
|
|
}
|
|
}
|
|
|
|
public async void Teleport()
|
|
{
|
|
//这个直接抄就行,参数不要动
|
|
player.GetComponent<Animator>().enabled = false;
|
|
await UniTask.Delay(100);
|
|
player.GetComponent<Animator>().enabled = true;
|
|
FreeLookCam.instance.m_LookAngle = player.eulerAngles.y;
|
|
FreeLookCam.instance.m_TiltAngle = pivot.localEulerAngles.x;
|
|
FreeLookCam.instance.pCFWC.m_OriginalDist = 1.5f;
|
|
}
|
|
|
|
public void SetPlayerMove(bool value)
|
|
{
|
|
if (value)
|
|
{
|
|
ThirdViewControl.instance.StartAnimator();
|
|
|
|
//ThirdViewControl.instance.playerState = PlayerControlState.playerControl;
|
|
}
|
|
else
|
|
{
|
|
ThirdViewControl.instance.StopAnimator();
|
|
ThirdViewControl.instance.playerState = PlayerControlState.anim;
|
|
}
|
|
this.SetInit();
|
|
}
|
|
|
|
public void SetPlayer(bool value)
|
|
{
|
|
if (value)
|
|
{
|
|
ThirdViewControl.instance.playerState = PlayerControlState.playerControl;
|
|
|
|
}
|
|
else
|
|
{
|
|
ThirdViewControl.instance.playerState = PlayerControlState.noUse;
|
|
}
|
|
this.SetInit();
|
|
}
|
|
|
|
public void SetAnim(string name)
|
|
{
|
|
//ThirdViewControl.instance.GetComponent<CameraAnim>().GoGoGo(name, () => {
|
|
// //FreeLookCam.instance.m_LookAngle = this.FacingAngle.y;
|
|
// Teleport();
|
|
//});
|
|
}
|
|
|
|
public void SetPlayerAnim(string name)
|
|
{
|
|
var anim = ThirdViewControl.instance.GetComponent<Animator>();
|
|
anim.Play(name);
|
|
}
|
|
|
|
public void SetInit()
|
|
{
|
|
var anim = ThirdViewControl.instance.GetComponent<Animator>();
|
|
anim.SetFloat("Forward", 0, 0.1f, Time.deltaTime);
|
|
anim.SetFloat("Turn", 0, 0.1f, Time.deltaTime);
|
|
//this.Async(async () => {
|
|
// await UniTask.Delay(10, cancellationToken: this.GetCancellationTokenOnDestroy());
|
|
// anim.SetFloat("Forward", 0, 0.1f, Time.deltaTime);
|
|
// anim.SetFloat("Turn", 0, 0.1f, Time.deltaTime);
|
|
//});
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void Show()
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
}
|
|
|
|
public void SetActive(bool value)
|
|
{
|
|
this.gameObject.SetActive(value);
|
|
}
|
|
}
|
|
}
|