Files
plugin-library/Assets/Domain/Main/HotUpdate/PointController.cs

80 lines
2.7 KiB
C#
Raw Normal View History

2025-05-23 18:26:47 +08:00
using System;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using Main;
using Stary.Evo;
2025-07-02 10:05:26 +08:00
using Stary.Evo.AudioCore;
2025-05-23 18:26:47 +08:00
using UnityEngine;
using YooAsset;
namespace Main
{
public class PointController : MonoBehaviour, IController
{
public ZoneController ZoneController;
private SphereCollider sphereCollider;
2025-07-02 10:05:26 +08:00
private TextMesh textMesh;
2025-05-23 18:26:47 +08:00
private IUnRegister _onTriggerEnterUnRegister;
private IUnRegister _onTriggerExitUnRegister;
public void Init(ZoneController ZoneController, PointData pointData)
{
this.ZoneController = ZoneController;
2025-07-02 10:05:26 +08:00
textMesh = this.transform.GetComponentInChildren<TextMesh>();
textMesh.text = pointData.desc;
2025-05-23 18:26:47 +08:00
name = pointData.name;
//根据数据设置zone 碰撞盒
transform.localPosition = pointData.position;
transform.localRotation = Quaternion.Euler(pointData.rotation);
transform.localScale = pointData.scale;
sphereCollider = this.transform.GetOrAddComponent<SphereCollider>();
2025-07-02 10:05:26 +08:00
_onTriggerEnterUnRegister = sphereCollider.OnTriggerEnterEvent(OnPointTriggerEnterEvent);
2025-05-23 18:26:47 +08:00
this.gameObject.SetActive(false);
}
2025-07-02 10:05:26 +08:00
public async void OnPointTriggerEnterEvent(Collider collider)
2025-05-23 18:26:47 +08:00
{
if (collider.gameObject.CompareTag("MainCamera"))
{
2025-07-02 10:05:26 +08:00
ZoneController.OpenPoint(this);
var package=YooAssets.TryGetPackage("Main");
var handle=package.LoadAssetAsync<AudioClip>(R.Res.Main.audios.au_effect_element_pop_mp3);
await handle.WithCancellation(this.GetCancellationTokenOnDestroy());
AudioCoreManager.PlaySFX(new AudioData()
{
clip = handle.GetAssetObject<AudioClip>()
});
HybridClREntrance entrance= FindObjectOfType<HybridClREntrance>();
if (entrance != null)
{
entrance.OpenDomain(this.name,OpenDomainType.DEFAULT);
}
else
{
Debug.LogError("UnityEvo:HybridClREntrance is null");
}
ZoneController.BoundingEvent(false);
Debug.Log($"【{name}】OnPointTriggerEnterEvent");
2025-05-23 18:26:47 +08:00
}
}
2025-07-02 10:05:26 +08:00
2025-05-23 18:26:47 +08:00
public IArchitecture GetArchitecture()
{
return MainArchitecture.Interface;
}
}
2025-07-02 10:05:26 +08:00
2025-05-23 18:26:47 +08:00
public class PointColliderEntity
{
public string Name { get; set; }
public bool IsTrigger { get; set; }
public SphereCollider PointCollider { get; set; }
public Func<Collider> EntorComplete { get; set; }
}
}