2024-04-09 13:22:52 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using Game.RayCast;
|
|
|
|
|
using Game.Room;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Random = UnityEngine.Random;
|
|
|
|
|
|
|
|
|
|
namespace Game;
|
|
|
|
|
|
|
|
|
|
[Procedure(ProcedureType.GameSceneKillPlayerProcedure)]
|
|
|
|
|
class GameSceneKillPlayerProcedure : ProcedureBase
|
|
|
|
|
{
|
|
|
|
|
private float maxTime = 10f;
|
|
|
|
|
GameSceneMainUI sceneMainUI;
|
|
|
|
|
|
|
|
|
|
public override void OnEnter()
|
|
|
|
|
{
|
|
|
|
|
base.OnEnter();
|
|
|
|
|
|
|
|
|
|
EventManager.Instance.Subscribe(InputObjectFinishEventArgs.EventId, this.InputObjectFinishEvent);
|
2024-04-09 18:16:37 +08:00
|
|
|
|
UniTask.Create(this.OpenWarningTips);
|
|
|
|
|
}
|
2024-04-09 13:22:52 +08:00
|
|
|
|
|
2024-04-09 18:16:37 +08:00
|
|
|
|
async UniTask OpenWarningTips()
|
|
|
|
|
{
|
2024-04-09 13:22:52 +08:00
|
|
|
|
sceneMainUI = Game.uiManager.GetUI<GameSceneMainUI>(UIType.GameSceneMainUI);
|
2024-04-09 18:16:37 +08:00
|
|
|
|
await this.sceneMainUI.WaitTimeCloseTips();
|
2024-04-09 13:22:52 +08:00
|
|
|
|
|
|
|
|
|
UniTask.Create(this.WaitKillFinish);
|
2024-04-09 18:16:37 +08:00
|
|
|
|
// UniTask.Create(this.WaitTimeGoNext);
|
|
|
|
|
isFinish = false;
|
2024-04-09 13:22:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async UniTask WaitKillFinish()
|
|
|
|
|
{
|
2024-04-09 18:16:37 +08:00
|
|
|
|
string content = $"恐龙出没!";
|
|
|
|
|
sceneMainUI.UpdateMessage(content);
|
2024-04-09 13:22:52 +08:00
|
|
|
|
|
2024-04-09 18:16:37 +08:00
|
|
|
|
var allRoom = Game.roomManager.GetAllRandomRoom();
|
2024-04-09 13:22:52 +08:00
|
|
|
|
await Game.bossManager.MoveToKillPlayerAsync(allRoom, default);
|
2024-04-09 18:16:37 +08:00
|
|
|
|
|
2024-04-09 13:22:52 +08:00
|
|
|
|
Game.bossManager.DeleteBoss();
|
2024-04-09 18:16:37 +08:00
|
|
|
|
isFinish = true;
|
2024-04-09 13:22:52 +08:00
|
|
|
|
|
2024-04-09 18:16:37 +08:00
|
|
|
|
float jinBei = 0;
|
|
|
|
|
foreach (var room in allRoom)
|
2024-04-09 13:22:52 +08:00
|
|
|
|
{
|
2024-04-09 18:16:37 +08:00
|
|
|
|
jinBei += room.roomData.jinbei;
|
2024-04-09 13:22:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-09 18:16:37 +08:00
|
|
|
|
Debug.Log($"杀掉了随机房间玩家,金贝数量总和为:{jinBei}");
|
|
|
|
|
|
|
|
|
|
//TODO:
|
|
|
|
|
UniTask.Create(async () => { await Game.roomManager.QuitAllRoomAsync(default); });
|
|
|
|
|
// await this.sceneMainUI.WaitTimeCloseTips();
|
2024-04-09 13:22:52 +08:00
|
|
|
|
|
2024-04-09 18:16:37 +08:00
|
|
|
|
Game.procedureManager.ChangeProcedure(ProcedureType.GameSceneSettlementProcedure);
|
2024-04-09 13:22:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-09 18:16:37 +08:00
|
|
|
|
private bool isFinish;
|
|
|
|
|
|
|
|
|
|
// async UniTask WaitTimeGoNext()
|
|
|
|
|
// {
|
|
|
|
|
// float time = 0f;
|
|
|
|
|
// while (true)
|
|
|
|
|
// {
|
|
|
|
|
// time += Time.deltaTime;
|
|
|
|
|
// string content = $"({(int)time}) 恐龙出没!";
|
|
|
|
|
// sceneMainUI.UpdateMessage(content);
|
|
|
|
|
// if (isFinish || time >= this.maxTime)
|
|
|
|
|
// {
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// await UniTask.Yield();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// await UniTask.Delay(1000);
|
|
|
|
|
// Game.procedureManager.ChangeProcedure(ProcedureType.GameSceneSettlementProcedure);
|
|
|
|
|
// }
|
|
|
|
|
|
2024-04-09 13:22:52 +08:00
|
|
|
|
private void InputObjectFinishEvent(object sender, GameEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var args = e as InputObjectFinishEventArgs;
|
|
|
|
|
// var inputData = args.data as MouseInputData;
|
|
|
|
|
// var roomInfo = inputData.go.GetComponent<RoomInfo>();
|
|
|
|
|
|
|
|
|
|
Debug.Log("未到选择房间时间!");
|
|
|
|
|
// 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, this.InputObjectFinishEvent);
|
|
|
|
|
}
|
|
|
|
|
}
|