74 lines
2.6 KiB
C#
74 lines
2.6 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.Dinosaurs;
|
|
using Game.RayCast;
|
|
using Game.Room;
|
|
|
|
namespace Game
|
|
{
|
|
[Procedure(ProcedureType.GameSceneLogicProcedure)]
|
|
class GameSceneLogicProcedure : ProcedureBase
|
|
{
|
|
private float maxTime = 10f;
|
|
GameSceneMainUI sceneMainUI;
|
|
private DinosaursGameManager _dinosaursGameManager;
|
|
|
|
public override void OnEnter()
|
|
{
|
|
base.OnEnter();
|
|
EventManager.Instance.Subscribe(BackHallSSceneEventArgs.EventId, this.BackHallSceneEvent);
|
|
EventManager.Instance.Subscribe(AddRobotEventArgs.EventId, this.AddRobotEvent);
|
|
EventManager.Instance.Subscribe(DeleteAllRobotEventArgs.EventId, this.DeleteAllRobotEvent);
|
|
|
|
_dinosaursGameManager = new DinosaursGameManager();
|
|
sceneMainUI = Game.uiManager.GetUI<GameSceneMainUI>(UIType.GameSceneMainUI);
|
|
this.sceneMainUI.SetDinosaursGame(this._dinosaursGameManager);
|
|
|
|
_dinosaursGameManager.Init();
|
|
_dinosaursGameManager.StartGame();
|
|
}
|
|
|
|
public override void OnUpdate(float dateTime)
|
|
{
|
|
base.OnUpdate(dateTime);
|
|
_dinosaursGameManager.UpdateGame(dateTime);
|
|
}
|
|
|
|
private void DeleteAllRobotEvent(object sender, GameEventArgs e)
|
|
{
|
|
this._dinosaursGameManager.robotManager.DeleteAllRobot();
|
|
}
|
|
|
|
private void AddRobotEvent(object sender, GameEventArgs e)
|
|
{
|
|
this._dinosaursGameManager.robotManager.CreateRobot();
|
|
}
|
|
|
|
private void BackHallSceneEvent(object sender, GameEventArgs e)
|
|
{
|
|
if (!_dinosaursGameManager.playerManager.currentPlayer.IsCanDelete)
|
|
return;
|
|
Game.uiManager.CloseAll();
|
|
|
|
// TODO
|
|
Game.resourceManager.UnloadSceneAsync(AssetConstPath.Assets_GameRes_Scene_Game);
|
|
_dinosaursGameManager.Dispose();
|
|
|
|
Game.uiManager.ShowUI(UIType.HallSceneMainUI);
|
|
Game.procedureManager.ChangeProcedure(ProcedureType.HallSceneMainLogicProcedure);
|
|
}
|
|
|
|
public override void OnLeave()
|
|
{
|
|
base.OnLeave();
|
|
EventManager.Instance.Unsubscribe(BackHallSSceneEventArgs.EventId, this.BackHallSceneEvent);
|
|
EventManager.Instance.Unsubscribe(AddRobotEventArgs.EventId, this.AddRobotEvent);
|
|
EventManager.Instance.Unsubscribe(DeleteAllRobotEventArgs.EventId, this.DeleteAllRobotEvent);
|
|
}
|
|
}
|
|
} |