private async Task Win() { bool finished = false; var items = _encounterSet.GetItemReward(); var expReward = GetExpReward(); var goldReward = _encounterSet.GetGoldReward(); await QueueActionAndAwait(() => { battleCanvas.StopBattleMusic(); battleCanvas.RewardPanel.ShowRewardPanel(expReward, goldReward, items); var rewardPanelClosedEvent = battleCanvas.RewardPanel.RewardPanelClosed; void CloseDialog() { finished = true; rewardPanelClosedEvent.RemoveListener(CloseDialog); } rewardPanelClosedEvent.AddListener(CloseDialog); }); while (!finished) { await Task.Delay(5); } await QueueActionAndAwait(() => { CommitWin(expReward, goldReward, items); Cleanup(); }); }