CultivationOfBrewing-2/Assets/Scripts/LiveSceneManger.cs

106 lines
2.6 KiB
C#

using Cysharp.Threading.Tasks;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public enum rayObj
{
None,
,
,
,
}
public class LiveSceneManger : MonoBehaviour
{
public static LiveSceneManger Instance;
//任务头顶按钮
public Button TipBtn;
////正常植株相机
//public Camera CameraZC;
////病株相机
//public Camera CameraBZ;
public CameraOrbit A;
public CameraOrbit B;
public rayObj rayObj = rayObj.None;
public UI_GraphicRextualPanel rextualPanel;
//教师动画
public Animator TeacherAni;
public UI_MenuBar MenuBar;
// Start is called before the first frame update
private void Awake()
{
Instance = this;
A.enabled = false;
B.enabled = false;
}
void Start()
{
TipBtn.onClick.AddListener(() =>
{
TipBtn.gameObject.SetActive(false);
Bootstrap.Instance.uiManager.ShowPanel<UI_GraphicRextualPanel>(this, E_UI_Layer.Top, (panel) =>
{
Debug.Log("UI_MenuBar");
});
});
}
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
bool raycast = Physics.Raycast(ray, out hit);
if (raycast)
{
if (hit.collider.gameObject.name.Equals("教师"))
{
//教师
Teacher();
}
}
}
}
private async void Teacher()
{
rayObj = rayObj.;
TeacherAni.SetBool("伸手", true);
Debug.Log("点到老师了");
await UniTask.Delay(50);
MenuBar.BagBtn.gameObject.SetActive(true);
}
///// <summary>
///// 根据标签或组件判断类型
///// </summary>
///// <param name="collider"></param>
///// <returns></returns>
///// <exception cref="System.Exception"></exception>
//private rayObj GetInteractableType(Collider collider)
//{
// if (collider.gameObject.name.Equals("教师")) return rayObj.教师;
// if (collider.gameObject.name.Equals("正常高粱")) return rayObj.正常高粱;
// if (collider.gameObject.name.Equals("病株")) return rayObj.病株;
// if (collider.gameObject.name.Equals("玉米")) return rayObj.玉米;
// // 或者根据组件判断
// // if (collider.GetComponent<TrailerComponent>() != null) return InteractableType.Trailer;
// // 默认返回或抛出异常
// throw new System.Exception("Unknown interactable type");
//}
}