forked from zxl/LaboratoryProtection
54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
using Cysharp.Threading.Tasks;
|
|
|
|
using PMaker.DependencyInjection;
|
|
using PMaker.Extension;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
|
|
using UnityEngine;
|
|
|
|
public class FirstPlayerController : SingletonMonobehaviour
|
|
{
|
|
public FirstPersonLogic personLogic;
|
|
public Transform[] allPos;
|
|
|
|
private void Reset()
|
|
{
|
|
this.personLogic = GameObject.FindObjectOfType<FirstPersonLogic>();
|
|
allPos = this.transform.Children().ToArray();
|
|
}
|
|
|
|
[Button]
|
|
[HideInEditorMode]
|
|
public void MoveTo(int index)
|
|
{
|
|
var pos = allPos[index];
|
|
personLogic.Position = pos.position;
|
|
personLogic.FacingAngle = pos.eulerAngles;
|
|
}
|
|
|
|
public void MoveTo(string name)
|
|
{
|
|
var pos = allPos.First(_ => _.name == name);
|
|
personLogic.Position = pos.position;
|
|
personLogic.FacingAngle = pos.eulerAngles;
|
|
}
|
|
}
|
|
|
|
public static class BaseBehaviourExtensionFirstPlayerController
|
|
{
|
|
public static void MoveTo(this BaseBehaviour baseBehaviour, int index)
|
|
{
|
|
var controller = IoC.GetSingleton<FirstPlayerController>();
|
|
controller.MoveTo(index);
|
|
}
|
|
public static void MoveTo(this BaseBehaviour baseBehaviour, string name)
|
|
{
|
|
var controller = IoC.GetSingleton<FirstPlayerController>();
|
|
controller.MoveTo(name);
|
|
}
|
|
} |