NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/State/BaseLevelState.cs

97 lines
2.8 KiB
C#
Raw Normal View History

using System;
2024-11-22 14:25:49 +08:00
using AOT.PostProcess.ColorFade;
using Cysharp.Threading.Tasks;
2023-08-22 19:08:45 +08:00
using Framework;
2024-07-01 13:08:37 +08:00
using Gameplay.Guide;
2024-11-14 14:22:30 +08:00
using LTGame;
2023-08-22 19:08:45 +08:00
using TGS;
using UnityEngine;
namespace Gameplay.Level
{
2024-11-14 14:22:30 +08:00
public abstract class BaseLevelState : NBaseState
2023-08-22 19:08:45 +08:00
{
protected Level _level;
2024-11-14 14:22:30 +08:00
public BaseLevelState(Level level, int stateId) : base(stateId)
2023-08-22 19:08:45 +08:00
{
_level = level;
}
2024-11-22 14:25:49 +08:00
protected async void _WaitBlackOut()
{
if (GlobalFadeManager.instance.fadeProgress <= 0.5f)
{
return;
}
GlobalFadeManager.instance.FadeOut(0.5f);
await UniTask.WaitForSeconds(0.5f);
}
2023-08-22 19:08:45 +08:00
public override void Run(float dt)
{
// 暂停状态下不执行
if (_level.IsPause()) return;
base.Run(dt);
}
2024-11-14 14:22:30 +08:00
protected override void _OnEnter(NBaseState exitState,
object param)
2023-08-22 19:08:45 +08:00
{
}
2024-11-14 14:22:30 +08:00
protected override void _OnRunning()
2023-08-22 19:08:45 +08:00
{
2024-11-14 14:22:30 +08:00
2023-08-22 19:08:45 +08:00
}
2024-11-14 14:22:30 +08:00
protected override void _OnExit(NBaseState exitState,
object param)
2023-08-22 19:08:45 +08:00
{
}
protected abstract void _OnCellClick(TerrainGridSystem tgs, int cellIndex, int buttonIndex);
protected abstract void _OnClick(Vector2 screenPosition);
2024-07-01 13:08:37 +08:00
2024-11-18 15:41:48 +08:00
public void ClickFromScreen(Vector2 screenPos)
{
_OnClick(screenPos);
}
2024-07-01 13:08:37 +08:00
/// <summary>
/// 检查能否点击地板
/// </summary>
protected void CheckCellClick(TerrainGridSystem tgs, int cellIndex, int buttonIndex)
{
if (GuideManager.Instance.IsGuiding && // 在新手引导中
2024-07-03 14:07:54 +08:00
GuideManager.Instance.IsControlFloor && // 是否控制地板点击
2024-07-01 13:08:37 +08:00
GuideManager.Instance.FloorIndex != cellIndex) // 点击的不是指定地板
{
2024-10-16 13:39:24 +08:00
EventManager.Instance.Send(EventManager.EventName.ToFightModelDragSuc, false);
2024-07-01 13:08:37 +08:00
return;
}
2024-10-16 13:39:24 +08:00
EventManager.Instance.Send(EventManager.EventName.Guide_ClickFloor, cellIndex);
2024-07-01 16:19:07 +08:00
2024-07-11 15:09:44 +08:00
DebugUtil.LogG($"用户点击格子:{cellIndex}");
2024-07-01 13:08:37 +08:00
_OnCellClick(tgs, cellIndex, buttonIndex);
2024-12-27 11:51:27 +08:00
// _TestCode(cellIndex);
}
private void _TestCode(int cellIndex)
{
var blockData = _level.Map.GetBlockData(cellIndex);
if (blockData == null)
{
DebugUtil.LogError("Block data is null");
return;
}
DebugUtil.Log("blockProperty:" + blockData.GetTerrainTypeProperty().crossLevel);
_level.Map.GetRuntimeBlockProperty(cellIndex, out var runtimeBlockProperty);
DebugUtil.Log("runtimeBlockProperty:" + runtimeBlockProperty.crossLevel);
2024-07-01 13:08:37 +08:00
}
2023-08-22 19:08:45 +08:00
}
}