/// <summary> /// 显示游戏UI,并指定本地玩家 /// </summary> /// <param name="localPlayer"></param> private void displayGameUI(THHPlayer localPlayer) { //本地玩家用UI _ui.display(_ui.Game); getManager <TableManager>().setGame(game, localPlayer); _ui.Game.Table.setGame(game, localPlayer); }
private void Update() { if (gameTask != null) { if (!game.isRunning || gameTask.IsCompleted || gameTask.IsCanceled || gameTask.IsFaulted) { game.Dispose(); game = null; gameTask = null; _ui.display(_ui.MainMenu); } } }
protected override void onAwake() { base.onAwake(); Main main = ui.getObject <Main>(); main.MainMenu.ManMachineButtonButtonBlack.asButton.onClick.set(() => { main.display(main.Game); game.startLocalGame(); }); main.MainMenu.NetworkButtonButtonBlack.asButton.onClick.set(() => { main.display(main.NetworkingPage); network.displayLANPanel(); }); main.display(main.Loading); }
public void startGame() { game = new THHGame(_option, getManager <CardManager>().GetCardDefines()) { answers = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>(), triggers = new GameObject(nameof(TriggerManager)).AddComponent <TriggerManager>(), logger = new UnityLogger() }; (game.answers as AnswerManager).game = game; THHPlayer localPlayer = game.createPlayer(1, "本地玩家", game.getCardDefine(_deck[0]) as MasterCardDefine, _deck.Skip(1).Select(id => game.getCardDefine(id))); THHPlayer aiPlayer = game.createPlayer(2, "AI", game.getCardDefine(_deck[0]) as MasterCardDefine, _deck.Skip(1).Select(id => game.getCardDefine(id))); //本地玩家用UI _ui.display(_ui.Game); _ui.Game.Table.setGame(game, localPlayer); //AI玩家用AI new AI(game, aiPlayer); game.triggers.onEventAfter += onEventAfter; gameTask = game.run(); }
public void startGame() { game = new THHGame(_option, getManager <CardManager>().GetCardDefines()) { answers = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>(), triggers = new GameObject(nameof(TriggerManager)).AddComponent <TriggerManager>(), time = new GameObject(nameof(TimeManager)).AddComponent <TimeManager>(), logger = new UnityLogger() }; (game.answers as AnswerManager).game = game; //检查卡组合法性 if (game.getCardDefine(_deck[0]) == null) { UberDebug.LogError("非法角色ID" + _deck[0] + "被替换为灵梦"); _deck[0] = game.getCardDefine <Reimu>().id; } for (int i = 1; i < _deck.Length; i++) { if (game.getCardDefine(_deck[i]) == null) { UberDebug.LogError("非法随从ID" + _deck[i] + "被替换为小野菊"); _deck[i] = game.getCardDefine <RashFairy>().id; } } THHPlayer localPlayer = game.createPlayer(1, "本地玩家", game.getCardDefine(_deck[0]) as MasterCardDefine, _deck.Skip(1).Select(id => game.getCardDefine(id))); THHPlayer aiPlayer = game.createPlayer(2, "AI", game.getCardDefine(_deck[0]) as MasterCardDefine, _deck.Skip(1).Select(id => game.getCardDefine(id))); //本地玩家用UI _ui.display(_ui.Game); _ui.Game.Table.setGame(game, localPlayer); //AI玩家用AI new AI(game, aiPlayer); game.triggers.onEventAfter += onEventAfter; gameTask = game.run(); }
protected void Update() { if (_loadCardTask == null) { return; } if (_loadCardTask.IsCompleted) { UIManager ui = getManager <UIManager>(); Main main = ui.getObject <Main>(); main.display(main.MainMenu); _loadCardTask = null; } else if (_loadCardTask.IsFaulted || _loadCardTask.IsCanceled) { UIManager ui = getManager <UIManager>(); ui.getObject <Dialog>().display("游戏资源加载失败!请重新启动游戏", () => Application.Quit()); _loadCardTask = null; } }