68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using Game.Pathfinding;
|
|
using JetBrains.Annotations;
|
|
using UnityEngine;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using Cysharp.Threading.Tasks;
|
|
using Game.RayCast;
|
|
using Game.Room;
|
|
|
|
namespace Game
|
|
{
|
|
[Procedure(ProcedureType.GameSceneLogicProcedure)]
|
|
class GameSceneLogicProcedure : ProcedureBase
|
|
{
|
|
private float maxTime = 10f;
|
|
GameSceneMainUI sceneMainUI;
|
|
|
|
public override void OnEnter()
|
|
{
|
|
base.OnEnter();
|
|
|
|
EventManager.Instance.Subscribe(InputObjectFinishEventArgs.EventId, InputObjectFinishEvent);
|
|
EventManager.Instance.FireNow(this, new BossStartMoveEventArgs(false));
|
|
|
|
sceneMainUI = Game.uiManager.GetUI<GameSceneMainUI>(UIType.GameSceneMainUI);
|
|
UniTask.Create(WaitTimeGoNext);
|
|
}
|
|
|
|
async UniTask WaitTimeGoNext()
|
|
{
|
|
float time = 0;
|
|
while (true)
|
|
{
|
|
time += Time.deltaTime;
|
|
string content = $"({(int)(this.maxTime - time)}) 恐龙即将出现!";
|
|
sceneMainUI.UpdateMessage(content);
|
|
|
|
if (time >= this.maxTime)
|
|
{
|
|
break;
|
|
}
|
|
|
|
await UniTask.Yield();
|
|
}
|
|
|
|
Game.procedureManager.ChangeProcedure(ProcedureType.GameSceneKillPlayerProcedure);
|
|
}
|
|
|
|
private void InputObjectFinishEvent(object sender, GameEventArgs e)
|
|
{
|
|
if (Game.playerManager.currentPlayer.isMoving) return;
|
|
|
|
var args = e as InputObjectFinishEventArgs;
|
|
var inputData = args.data as MouseInputData;
|
|
var roomInfo = inputData.go.GetComponent<RoomInfo>();
|
|
|
|
Game.roomManager.SetCurrentRoom(roomInfo.roomType);
|
|
UniTask.Create(async () => { await Game.roomManager.JoinRoomAsync(roomInfo.roomType, Game.playerManager.currentPlayer, new CancellationToken()); });
|
|
}
|
|
|
|
public override void OnLeave()
|
|
{
|
|
base.OnLeave();
|
|
EventManager.Instance.Unsubscribe(InputObjectFinishEventArgs.EventId, InputObjectFinishEvent);
|
|
}
|
|
}
|
|
} |