public AsyncState RunGame(MemoryGameModel gameModel) { // game login entry point return(Planner.Chain() .AddAction(memoryCardDeal.SetImages, gameModel.images) .AddAction(memoryCardDeal.SetDifficultyController, gameModel.GetController()) .AddAction(memoryCardDeal.SetAudioManager, audioManager) .AddFunc(memoryCardDeal.CardDealing, gameModel.numberOfCardPairs) .AddFunc(tutorialHand.StartTutorial) .AddAction(() => { if (gameModel.helpCount != 0) { helpButton.gameObject.SetActive(true); helpButton.onClick.AddListener(() => audioManager.Play("HelpEffect")); memoryCardDeal.MaxHelpCount = gameModel.helpCount; memoryCardDeal.HelpButton = helpButton; } }) .AddAwait(AwaitFunc) ); }
private AsyncState GameCircle() { var asyncChain = Planner.Chain(); asyncChain.AddAction(Debug.Log, "game started"); asyncChain.AddFunc(progress.ShowProgressBar); asyncChain.AddAction(() => progress.NumberOfRounds = defaultGameModel.numberOfRounds); for (var i = 0; i < defaultGameModel.numberOfRounds; i++) { asyncChain .AddAction(defaultGameModel.SetDifficultyController, difficultyController) .AddAction(() => defaultGameModel.GetController().HandleHP()) .AddFunc(controller.RunGame, defaultGameModel) .AddFunc(progress.IncrementProgress) ; } asyncChain.AddFunc(progress.CloseProgressBar); asyncChain.AddAction(Debug.Log, "game finished"); return(asyncChain); }