Files
ft/Client/Assets/Scripts/UI/PinballUncountable/PinballUncountableAct.cs
2026-06-29 21:18:33 +08:00

83 lines
2.6 KiB
C#

using asap.core;
using GameCore;
using UnityEngine;
using Cinemachine;
using PinballUncountable;
using UniRx;
public class PinballUncountableAct : AGameAct
{
[SerializeField] private Canvas worldSpaceUI;
[SerializeField] private CinemachineVirtualCamera cam;
[SerializeField] private PinballUncountablePlaySystem replaySystem;
[SerializeField] private PinballUncountableSceneCanvasView sceneCanvasView;
[SerializeField] private PinballUncountableDome dome;
private async void Awake()
{
var manager = GContext.container.Resolve<Manager>();
manager.EventAggregator.GetEvent<EventOnClickSceneButton>().Subscribe(OnClickButton).AddTo(this);
GContext.container.Resolve<IDeferredRewardStashService>().Reset();
worldSpaceUI.worldCamera = Camera.main;
var go = await UIManager.Instance.ShowUINotLoading(UITypes.PinballUncountablePanel);
var panel = go.GetComponent<PinballUncountablePanel>();
panel.TryStartGuide(new EventInitGuide { TargetNode = sceneCanvasView.TargetNode });
manager.EventAggregator.GetEvent<EventBlockKick>().Subscribe(OnBlockKick).AddTo(this);
}
#if UNITY_EDITOR
// [SerializeField] private ushort id;
// [SerializeField] private int testNum;
// private void Update()
// {
// if (Input.GetKeyDown(KeyCode.N))
// {
// ShiftCamera();
// }
// if (Input.GetKeyDown(KeyCode.P))
// {
// replaySystem.PlayId(id);
// }
// if (Input.GetKeyDown(KeyCode.T))
// {
// var idx = GContext.container.Resolve<Manager>().TableContext.GetEquivelantIndexFromScore(testNum);
// Debug.Log($"[PinballUncountable] test reward idx: {idx}]");
// }
// }
#endif
public void ShiftCamera(EventShiftCamera evt = null)
{
// Debug.Log("Cam Shift");
cam.m_Lens.Orthographic = false;
if (Camera.main == null)
return;
if (Camera.main.TryGetComponent<CinemachineBrain>(out var brain))
brain.ManualUpdate();
}
[SerializeField] private bool blockKick = false;
private void OnBlockKick(EventBlockKick e)
{
blockKick = e.Block;
}
private void OnClickButton(EventOnClickSceneButton e)
{
var manager = GContext.container.Resolve<Manager>();
var ids = manager.TableContext.GetTrajectoryArrayFromEntranceIndex(e.EntranceIdx, e.Multiplier);
dome.Kick(blockKick);
replaySystem.Play(ids);
}
protected override void OnDestroy() { }
private void OnDisable()
{
ShiftCamera();
}
}