public static void AddDialog(outki.UIWidget widget, EventHandler evt) { DialogInstance dlg = new DialogInstance(); dlg.Template = widget; dlg.Renderer = null; dlg.EventHandler = evt; m_dialogs.Add(dlg); }
public void AvatarChangeButton() { DialogInstance _avatarDialogInstance = DialogManager.Instance.Show("ProfileChangeAvatarDialog"); Button galleryButton = GameObjectHelper.GetChildComponentOnNamedGameObject <Button> (_avatarDialogInstance.Content, "GalleryButton"); Button cameraButton = GameObjectHelper.GetChildComponentOnNamedGameObject <Button> (_avatarDialogInstance.Content, "CameraButton"); galleryButton.onClick.AddListener(() => { #if UNITY_EDITOR PickImageEditor(); #endif #if UNITY_IOS IOSCamera.Instance.PickImage(ISN_ImageSource.Library); #endif #if UNITY_ANDROID AndroidCamera.Instance.GetImageFromGallery(); #endif _avatarDialogInstance.Done(); }); cameraButton.onClick.AddListener(() => { #if UNITY_EDITOR PickImageEditor(); #endif #if UNITY_IOS IOSCamera.Instance.PickImage(ISN_ImageSource.Camera); #endif #if UNITY_ANDROID AndroidCamera.Instance.GetImageFromCamera(); #endif _avatarDialogInstance.Done(); }); }
public void Invite() { GameObject _buttonObject = GameObject.Find("PurchaseButton"); if (_buttonObject == null) { return; } GameObject originalParent = _buttonObject.transform.parent.gameObject; Vector3 originalPosition = _buttonObject.transform.position; InviteController.Instance.Show(() => { _inviteButtonObject = null; GameObjectUtils.MoveObjectTo(_buttonObject, originalParent, originalPosition); }); _inviteButtonObject = InviteController.Instance.gameObject; DialogInstance _inviteDialogInstance = InviteController.Instance.GetComponent <DialogInstance>(); GameObjectUtils.MoveObjectTo(_buttonObject, _inviteDialogInstance.Target); }
public void HideObject() { GameObject dialog = GameObjectUtils.GetParentWithComponentNamedGameObject <DialogInstance> (gameObject); DialogInstance dialogInstance = null; if (dialog != null) { dialogInstance = dialog.GetComponent <DialogInstance> (); } StartCoroutine(CoRoutines.DelayedCallback(0.3f, () => { if (dialogInstance != null) { dialogInstance.Done(); } else { gameObject.SetActive(false); } })); }
public void CodeModel_PointsFor() { ICodeModel codeModel = new CodeModel(); var item = new WaterfallDialog("dialog-id"); var activity = MessageFactory.Text("hi"); var context = new TurnContext(new TestAdapter(), activity); var dialogs = new DialogSet(); dialogs.Add(item); var dc = new DialogContext(dialogs, context, new DialogState()); var instance = new DialogInstance { Id = "dialog-id" }; dc.Stack.Add(instance); var codePoints = codeModel.PointsFor(dc, item, "more"); Assert.Equal(item, codePoints[0].Item); }
public override Task EndDialogAsync(ITurnContext turnContext, DialogInstance instance, DialogReason reason, CancellationToken cancellationToken = default) { RestoreParentGenerator(turnContext); return(base.EndDialogAsync(turnContext, instance, reason, cancellationToken)); }
public ActivityIdMiddlewareTests() { _testStorage = new TestStorage(); _mockNext = new Mock<NextDelegate>(); _conversationState = new ConversationState(_testStorage); _testUserState = new UserState(_testStorage); _mockUserState = new Mock<UserState>(); _testCurrentActivityDialog = new DialogInstance { Id = "TestactivityId" }; _mockConversationDialogState = new Mock<IStatePropertyAccessor<Microsoft.Bot.Builder.Dialogs.DialogState>>(); _feedbackBotStateRepository = new FeedbackBotStateRepository(_conversationState, _testUserState); _feedbackBotStateRepository.ConversationDialogState = _mockConversationDialogState.Object; _mockTurnContext = new Mock<ITurnContext>(); _mockTurnContext .Setup(m => m.TurnState) .Returns(new TurnContextStateCollection()); DialogState testState = new DialogState(new List<DialogInstance> { new DialogInstance { Id = "TestactivityId" } }); var testDialogState = new DialogState(new List<DialogInstance> { { new DialogInstance { Id = Guid.NewGuid().ToString(), State = new Dictionary<string, object>{ { "DialogState", new DialogState(new List<DialogInstance> { _testCurrentActivityDialog } ) } } } } }); _mockConversationDialogState .Setup(m => m.GetAsync(_mockTurnContext.Object, It.IsAny<Func<DialogState>>(), It.IsAny<CancellationToken>())) .ReturnsAsync(testDialogState); _testActivityList = new List<Activity>(); // set up the test activity with some random text and known ChannelId and ConversationId _testActivity = new Activity { Id = Guid.NewGuid().ToString(), Type = ActivityTypes.Message, Text = Guid.NewGuid().ToString(), ChannelId = "Test", Conversation = new ConversationAccount() { Id = "TestConversation" } }; _testActivityList.Add(_testActivity); _mockTurnContext .Setup(m => m.Activity) .Returns(_testActivity); _mockTurnContext .Setup(m => m.OnSendActivities(It.IsAny<SendActivitiesHandler>())) .Callback<SendActivitiesHandler>(async (handler) => { await handler.Invoke(_mockTurnContext.Object, _testActivityList, () => Task.FromResult(new List<ResourceResponse>().ToArray())); }); _sut = new ActivityIdMiddleware(_feedbackBotStateRepository); }
protected override Task OnEndDialogAsync(ITurnContext context, DialogInstance instance, DialogReason reason, CancellationToken cancellationToken = default) { // Capture the end reason for assertions. EndReason = reason; return(base.OnEndDialogAsync(context, instance, reason, cancellationToken)); }
/// <summary> /// Called when the dialog should re-prompt the user for input. /// </summary> /// <param name="turnContext">The context object for this turn.</param> /// <param name="instance">State information for this dialog.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects /// or threads to receive notice of cancellation.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public override Task RepromptDialogAsync(ITurnContext turnContext, DialogInstance instance, CancellationToken cancellationToken = default) { LoadDialogOptions(turnContext, instance); return(base.RepromptDialogAsync(turnContext, instance, cancellationToken)); }
/// <summary> /// Called when the dialog is ending. /// </summary> /// <param name="turnContext">The context object for this turn.</param> /// <param name="instance">State information associated with the instance of this dialog on the dialog stack.</param> /// <param name="reason">Reason why the dialog ended.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects /// or threads to receive notice of cancellation.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public override Task EndDialogAsync(ITurnContext turnContext, DialogInstance instance, DialogReason reason, CancellationToken cancellationToken = default) { LoadDialogOptions(turnContext, instance); return(base.EndDialogAsync(turnContext, instance, reason, cancellationToken)); }
protected virtual Task OnRepromptDialogAsync(TurnContext turnContext, DialogInstance instance, CancellationToken cancellationToken = default(CancellationToken)) { return(Task.CompletedTask); }
/// <summary> /// Callback when the free prize dialog is closed. You may override this in your own subclasses, but be sure to call this base class instance. /// </summary> /// <param name="dialogInstance"></param> public virtual void ShowFreePrizeDone(DialogInstance dialogInstance) { IsShowingFreePrizeDialog = false; }
public override async Task EndDialogAsync(ITurnContext turnContext, DialogInstance instance, DialogReason reason, CancellationToken cancellationToken = default(CancellationToken)) { await turnContext.SendActivityAsync(MessageFactory.Text("*** WaterfallDialog End ***")); await base.EndDialogAsync(turnContext, instance, reason, cancellationToken); }
protected override Task OnRepromptDialogAsync(ITurnContext turnContext, DialogInstance instance, CancellationToken cancellationToken = default(CancellationToken)) { return(base.OnRepromptDialogAsync(turnContext, instance, cancellationToken)); }
private void OnDialogOkClicked(DialogInstance dialogInstance) { LevelNavigator.NavigateTo("01_Title"); }
protected override void GameSetup() { DialogInstance = GetComponent <DialogInstance>(); Assert.IsNotNull(DialogInstance.Target, "Ensure that you have set the script execution order of dialog instance in settings (see help for details)."); }
public virtual void Show(bool isWon, float time, int points = 0, ChallengeManager.GameStates gameState = ChallengeManager.GameStates.Leaved, ChallengeManager.GameStateMessage message = null) { _multiplayer = GameSparksManager.Instance.GetGameMode() == GameMode.Multi; _buttonPurchaseObject = GameObject.Find("PurchaseButton"); if (_buttonPurchaseObject != null && !_multiplayer) { _inviteOriginalParent = _buttonPurchaseObject.transform.parent.gameObject; _inviteOriginalPosition = _buttonPurchaseObject.transform.position; _inviteButtonObject = gameObject; DialogInstance _inviteDialogInstance = gameObject.GetComponent <DialogInstance>(); GameObjectUtils.MoveObjectToAtIndex(_buttonPurchaseObject, _inviteDialogInstance.Target, 1); } pointsView = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "PointsView", true); shareView = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "SharingView", true); multiplayerView = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "MultiplayerPointsView", true); if (_multiplayer) { pointsView.SetActive(false); multiplayerView.SetActive(true); if (gameState == ChallengeManager.GameStates.Won || gameState == ChallengeManager.GameStates.Draw) { ButtonUtils.PlayWinSound(); } else { ButtonUtils.PlayLoseSound(); } } else { pointsView.SetActive(true); multiplayerView.SetActive(false); ButtonUtils.PlayWinSound(); } var currentLevel = GameManager.Instance.Levels.Selected; int coins = 0; bool firstTimePlayed = _multiplayer ? true : currentLevel.ProgressBest < 0.9f; LevelManager.Instance.EndLevel(); this.Coins = coins; if (firstTimePlayed && !_multiplayer) { currentLevel.AddPoints(points); currentLevel.ProgressBest = 1.0f; } if (_multiplayer && gameState == ChallengeManager.GameStates.Lost) { points *= -1; } GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Dialog", true), false); Assert.IsTrue(LevelManager.IsActive, "Ensure that you have a LevelManager component attached to your scene."); if (coins > 0 && !_multiplayer) { // add coins for this level currentLevel.AddCoins(coins); GameManager.Instance.Player.AddCoins(coins); } GameManager.Instance.Player.AddPoints(points); // update the player coins if necessary if (((UpdatePlayerCoins == CopyType.Always) || (UpdatePlayerCoins == CopyType.OnWin && isWon)) && !_multiplayer) { GameManager.Instance.Player.AddCoins(currentLevel.Coins); } // show won / lost game objects as appropriate GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Lost", true), !isWon); // see if the world or game is won and also if we should unlock the next world / level GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "GameWon", true), false); GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "WorldWon", true), false); GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "LevelWon", true), false); GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Won", true), false); GameObject levelName = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "LevelName", true); if (_multiplayer) { levelName.GetComponent <Text>().text = LocaliseText.Get("LevelCompleted.Match"); } else { levelName.GetComponent <Text>().text = LocaliseText.Format("LevelCompleted.LevelName", currentLevel.Number); } GameObjectHelper.SafeSetActive(levelName, true); if (!_multiplayer && isWon) { GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Won", true), true); // process and update game state - do this last so we can check some bits above. GameHelper.ProcessCurrentLevelComplete(); } // set some text based upon the result UIHelper.SetTextOnChildGameObject(DialogInstance.gameObject, "AchievementText", LocaliseText.Format(LocalisationBase + ".Achievement", currentLevel.Score, currentLevel.Name)); // setup stars var starsGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Stars", true); GameObjectHelper.SafeSetActive(starsGameObject, ShowStars); if (ShowStars && !_multiplayer) { Assert.IsNotNull(starsGameObject, "GameOver->ShowStars is enabled, but could not find a 'Stars' gameobject. Disable the option or fix the structure."); starsGameObject.SetActive(ShowStars); var newStarsWon = GetNewStarsWon(); currentLevel.StarsWon |= newStarsWon; var star1WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star1", true); var star2WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star2", true); var star3WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star3", true); StarWon(currentLevel.StarsWon, newStarsWon, star1WonGameObject, 1, coins); StarWon(currentLevel.StarsWon, newStarsWon, star2WonGameObject, 2, coins); StarWon(currentLevel.StarsWon, newStarsWon, star3WonGameObject, 4, coins); GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(starsGameObject, "StarWon", true), newStarsWon != 0); } // set time var timeGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Time", true); GameObjectHelper.SafeSetActive(timeGameObject, ShowTime); if (!_multiplayer && ShowTime) { TimeSpan timeSpan = TimeSpan.FromSeconds(time); string timeText = LocaliseText.Format("LevelCompleted.Time", timeSpan.Minutes, timeSpan.Seconds); Assert.IsNotNull(timeGameObject, "GameOver->ShowTime is enabled, but could not find a 'Time' gameobject. Disable the option or fix the structure."); UIHelper.SetTextOnChildGameObject(timeGameObject, "TimeResult", timeText, true); } if (!_multiplayer && currentLevel.TimeBest < 0.05) { // save only first time played currentLevel.TimeBest = time; } // set coins if (ShowCoins && coins > 0) { var coinsGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Coins", true); GameObjectHelper.SafeSetActive(coinsGameObject, ShowCoins); Assert.IsNotNull(coinsGameObject, "GameOver->ShowCoins is enabled, but could not find a 'Coins' gameobject. Disable the option or fix the structure."); UIHelper.SetTextOnChildGameObject(coinsGameObject, "CoinsResult", coins.ToString(), true); } if (!_multiplayer) { if (firstTimePlayed) { GameObject DoubleButton = GameObjectHelper.GetChildNamedGameObject(pointsView, "DoubleButton", true); DoubleButton.SetActive(Reachability.Instance.IsReachable()); } else { GameObject ShareButton = GameObjectHelper.GetChildNamedGameObject(pointsView, "ShareButton", true); ShareButton.SetActive(true); } } // set score var scoreGameObject = GameObjectHelper.GetChildNamedGameObject(_multiplayer ? multiplayerView : pointsView, "Score", true); GameObjectHelper.SafeSetActive(scoreGameObject, ShowScore); if (!firstTimePlayed) { GameObjectHelper.SafeSetActive(scoreGameObject, false); } if (!_multiplayer && firstTimePlayed) { GameObject adsObject = GameObjectHelper.GetChildNamedGameObject(pointsView, "Ads", true); Text unlockText = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(pointsView, "UnlockText", true); if (LevelController.Instance.LastLevelInPack(currentLevel)) { Pack pack = LevelController.Instance.PackForLevel(currentLevel); Pack nextPack = LevelController.Packs().GetItem(pack.Number + 1); if (nextPack) { nextPack.LoadData(); adsObject.SetActive(false); unlockText.gameObject.SetActive(true); unlockText.text = LocaliseText.Format("LevelCompleted.LastLevelInPack", LocaliseText.Get(nextPack.JsonData.GetString("name"))); } } if (LevelController.Instance.LastLevelInRank(currentLevel)) { Rank rank = LevelController.Instance.RankForLevel(currentLevel); Rank nextRank = LevelController.Ranks().GetItem(rank.Number + 1); if (nextRank) { nextRank.LoadData(); adsObject.SetActive(false); unlockText.gameObject.SetActive(true); unlockText.text = LocaliseText.Format("LevelCompleted.LastLevelInRank", LocaliseText.Get(nextRank.JsonData.GetString("name"))); } } } if (ShowScore) { Assert.IsNotNull(scoreGameObject, "GameOver->ShowScore is enabled, but could not find a 'Score' gameobject. Disable the option or fix the structure."); UIHelper.SetTextOnChildGameObject(scoreGameObject, "ScoreResult", LocaliseText.Format("LevelCompleted.Score", "0"), true); AnimateScoreText(points); } if (_multiplayer) { var resultStateObject = GameObjectHelper.GetChildNamedGameObject(multiplayerView, "ResultState", true); GameObjectHelper.SafeSetActive(resultStateObject, true); string text = ""; switch (gameState) { case ChallengeManager.GameStates.Won: text = LocaliseText.Get("Game.YouWon"); break; case ChallengeManager.GameStates.Lost: text = LocaliseText.Get("Game.YouLost"); break; case ChallengeManager.GameStates.Draw: text = LocaliseText.Get("Game.ItsDrawn"); break; } resultStateObject.GetComponent <Text>().text = text; } if (!_multiplayer) { UpdateNeededCoins(); LevelController.Instance.PackProgressCompleted(currentLevel); UnlockNextLevel(); // int StartupLevels = ((CustomGameManager)CustomGameManager.Instance).StartupLevels; if (StartupLevels == currentLevel.Number) { GameObject adsObject = GameObjectHelper.GetChildNamedGameObject(pointsView, "Ads", true); Text adsText = adsObject.GetComponent <Text>(); adsText.text = LocaliseText.Get("Text.PlayedAllLevels"); adsText.fontSize = 39; adsText.resizeTextForBestFit = false; if (!Debug.isDebugBuild) { Flurry.Flurry.Instance.LogEvent("Game_LastLevel", new Dictionary <string, string>() { { "Level", currentLevel.Number.ToString() } }); Fabric.Answers.Answers.LogCustom("Game_LastLevel", new Dictionary <string, object>() { { "Level", currentLevel.Number.ToString() } }); } } } if (!_multiplayer && firstTimePlayed) { JSONObject pointsData = new JSONObject(); pointsData.Add("Level", currentLevel.Number.ToString()); pointsData.Add("Language", LocaliseText.Language); pointsData.Add("RealLanguage", LanguageUtils.RealLanguage(LocaliseText.Language)); pointsData.Add("Time", time.ToString()); pointsData.Add("UsedHints", GameController.Instance.usedHintsCount); pointsData.Add("UserCoins", GameManager.Instance.Player.Coins); pointsData.Add("Words", JsonUtils.ListToArray(GameController.Instance.GetFoundWords())); pointsData.Add("Date", DateTimeUtils.DateTimeToISO8601(UnbiasedTime.Instance.UTCNow())); GameSparksManager.Instance.SendPoints(points, "LevelComplete", pointsData); } // GameObject completeTextGameObject = GameObjectHelper.GetChildNamedGameObject(_multiplayer ? multiplayerView : pointsView, "CompleteText", true); // save game state. GameManager.Instance.Player.UpdatePlayerPrefs(); if (!_multiplayer) { currentLevel.UpdatePlayerPrefs(); } PreferencesFactory.Save(); GameObject NameContainer = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "NameContainer", true); GameObject LevelName = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "LevelName", true); GameObject Results = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "Results", true); GameObject Buttons = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "Buttons", true); GameObject CloseButton = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "Close", true); GameObject parent = DialogInstance.Content.transform.parent.gameObject; Vector3 currentScale = parent.transform.localScale; parent.transform.DOScale(new Vector3(0, 0, 0), 0.0f); NameContainer.transform.localScale = new Vector3(0, 0, 0); LevelName.transform.localScale = new Vector3(0, 0, 0); Results.transform.localScale = new Vector3(0, 0, 0); Buttons.transform.localScale = new Vector3(0, 0, 0); completeTextGameObject.transform.localScale = new Vector3(0, 0, 0); CloseButton.GetComponent <Image>().color = new Color(1, 1, 1, 0); //show dialog DialogInstance.Show(); parent.transform.DOScale(currentScale, 1.0f).SetEase(Ease.OutElastic); NameContainer.transform.DOScale(new Vector3(1, 1, 1), 1.5f).SetDelay(0.1f).SetEase(Ease.OutElastic); LevelName.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.2f).SetEase(Ease.OutElastic); Results.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.2f).SetEase(Ease.OutElastic); Buttons.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.2f).SetEase(Ease.OutElastic); completeTextGameObject.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.35f).SetEase(Ease.OutElastic); CloseButton.GetComponent <Image>().DOFade(1, 0.5f).SetDelay(0.7f); GameObject Light = GameObjectHelper.GetChildNamedGameObject(completeTextGameObject, "Light", true); Light.transform.DOLocalRotate(new Vector3(0, 0, -360), 10, RotateMode.LocalAxisAdd).SetLoops(-1).SetEase(Ease.Linear); //TODO bug - as we increase TimesPlayedForRatingPrompt on both game start (GameManager) and level finish we can miss this comparison. if (GameManager.Instance.TimesPlayedForRatingPrompt == TimesPlayedBeforeRatingPrompt) { GameFeedback gameFeedback = new GameFeedback(); gameFeedback.GameFeedbackAssumeTheyLikeOptional(); } #if UNITY_ANALYTICS // record some analytics on the level played if (!_multiplayer) { var values = new Dictionary <string, object> { { "score", currentLevel.Score }, { "Coins", coins }, { "time", time }, { "level", currentLevel.Number } }; Analytics.CustomEvent("LevelCompleted", values); } #endif #if UNITY_EDITOR if (!_multiplayer) { GameSparksManager.Instance.SyncProgressCoroutine(); } #endif #if !UNITY_EDITOR AdColonyManager.Instance.RequestAd(); AdColonyManager.Instance.RequestAd(Constants.AdColonyDoubleCoins); LoadInterstitialAd(); LoadAdmobRewarderVideo(); #endif // co routine to periodic updates of display (don't need to do this every frame) if (!Mathf.Approximately(PeriodicUpdateDelay, 0)) { StartCoroutine(PeriodicUpdate()); } }
/// <summary> /// Callback from assusme they like feedback windows. /// </summary> /// <param name="instance"></param> void RateCallback(DialogInstance instance) { // and based upon the dialog action switch (instance.DialogResult) { case DialogInstance.DialogResultType.Ok: case DialogInstance.DialogResultType.Yes: OpenRatingPage(); break; case DialogInstance.DialogResultType.Custom: GameManager.Instance.TimesPlayedForRatingPrompt = 0; break; case DialogInstance.DialogResultType.No: break; } }
/// <summary> /// Callback from feedback window where we are unsure if they like. /// </summary> /// <param name="instance"></param> void LikeCallback(DialogInstance instance) { // and based upon the dialog action switch (instance.DialogResult) { case DialogInstance.DialogResultType.Yes: OpenRatingPage(); break; case DialogInstance.DialogResultType.No: DialogManager.Instance.Show(titleKey: "GameFeedback.FeedbackTitle", text2Key: "GameFeedback.Unsure.No"); break; } }
public void ClaimAwards() { // if ( _awards.ContainsKey ("unlockedLevels") ) { // bool unlocked = LevelController.Instance.UnlockNextPack (); // // if ( unlocked ) { // MyDebug.Log ("Award: Unlocked levels: Unlock next pack"); // } // // if ( !unlocked ) { // LevelController.GenerateMoreLevels (); // // int levels = LevelController.TotalLevels (); // LevelController.UnlockLevel ((levels - LevelController.levelsPerPage) + 1); // // MyDebug.Log ("Award: Unlocked levels: Unlock additional levels: " + levels); // } // } if (_awards.ContainsKey("noAds")) { PreferencesFactory.SetInt(Constants.KeyNoAds, 1); MyDebug.Log("Award: No Ads: " + PreferencesFactory.GetInt(Constants.KeyNoAds)); } if (_awards.ContainsKey("coins")) { GameManager.Instance.Player.AddCoins((int)_awards.GetNumber("coins")); MyDebug.Log("Award: Coins: " + (int)_awards.GetNumber("coins")); } if (_awards.ContainsKey("unlockLevel")) { Level level = GameManager.Instance.Levels.GetItem((int)_awards.GetNumber("unlockLevel")); if (level != null) { level.IsUnlocked = true; level.UpdatePlayerPrefs(); Pack pack = LevelController.Instance.PackForLevel(level); if (pack != null) { LevelController.Instance.UnlockPack(pack); } GameManager.Instance.Levels.Selected = level; } } if (_awards.ContainsKey("unlockPack")) { Pack pack = ((CustomGameManager)CustomGameManager.Instance).Packs.GetItem((int)_awards.GetNumber("unlockPack")); if (pack != null) { LevelController.Instance.UnlockPack(pack); } } if (_awards.ContainsKey("unlockAll")) { LevelController.Instance.UnlockAll(); } GameManager.Instance.Player.UpdatePlayerPrefs(); PreferencesFactory.Save(); _awards = null; DialogInstance dialogInstance = gameObject.GetComponent <DialogInstance> (); dialogInstance.Done(); }
/// <summary> /// Show a free prize dialog that gives the user coins. We default to the standard General Message window, adding any additional /// content as setup in the FreePrizeManager configuration. /// </summary> public DialogInstance ShowFreePrizeDialog(Action <DialogInstance> doneCallback = null) { // only allow the free prize dialog to be shown once. if (IsShowingFreePrizeDialog) { return(null); } IsShowingFreePrizeDialog = true; _prizeIsProcessed = false; dialogInstance = DialogManager.Instance.Create(ContentPrefab, null, null, null, runtimeAnimatorController: ContentAnimatorController); Sprite sprite = null; string text = BonusText(); if (prizeIsCoins && this.PrizeItems > 0) { sprite = Resources.Load <Sprite>("Images/coins"); } string DateLastFreePrizeTakeString = PreferencesFactory.GetString(Constants.KeyDateLastFreePrizeTake); DateTime DateLastFreePrizeTake = UnbiasedTime.Instance.Now(); if (!DateLastFreePrizeTakeString.Equals("")) { DateLastFreePrizeTake = DateTime.Parse(DateLastFreePrizeTakeString); } int DaysInRow = PreferencesFactory.GetInt(Constants.KeyFreePrizeTakeDaysInRow, 1); if (DateLastFreePrizeTake.AddDays(1).Date == UnbiasedTime.Instance.Now().Date) { DaysInRow += 1; PreferencesFactory.SetInt(Constants.KeyFreePrizeTakeDaysInRow, DaysInRow); } else { // reset DaysInRow = 1; PreferencesFactory.SetInt(Constants.KeyFreePrizeTakeDaysInRow, DaysInRow); } GameObject Days = GameObjectHelper.GetChildNamedGameObject(dialogInstance.gameObject, "Days", true); for (int i = 0; i < Constants.DailyBonusItems.Length; i++) { int prizeValue = Constants.DailyBonusItems[i]; string dayText = string.Format("Day{0}", (i + 1)); GameObject day = GameObjectHelper.GetChildNamedGameObject(Days, dayText, true); if (!day) { continue; } Text t = GameObjectHelper.GetChildNamedGameObject(day, "Text", true).GetComponent <Text>(); t.text = prizeValue.ToString(); if (DaysInRow - 1 > i) { GameObject image = GameObjectHelper.GetChildNamedGameObject(day, "Image", true); GameObjectHelper.SafeSetActive(image, true); } // if ( DaysInRow-1 == i) { // GameObject today = GameObjectHelper.GetChildNamedGameObject(day, "Today", true); // GameObjectHelper.SafeSetActive (today, true); // // GameObject dayNumber = GameObjectHelper.GetChildNamedGameObject(day, "DayNumber", true); // GameObjectHelper.SafeSetActive (dayNumber, false); // } if (DaysInRow == (i + 1)) { // add daily bonus this.PrizeItems += prizeValue; GameObject claimButton = GameObjectHelper.GetChildNamedGameObject(dialogInstance.Content, "ClaimButton", true); Text claimText = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(claimButton, "Text", true); if (prizeIsPoints) { claimText.text = LocaliseText.Format("FreePrize.ClaimPoints", this.PrizeItems); } if (prizeIsCoins) { claimText.text = LocaliseText.Format("FreePrize.ClaimButton", this.PrizeItems); } } } dialogInstance.Show(title: LocaliseText.Get("FreePrize.Title"), text: text, text2Key: "FreePrize.Text2", doneCallback: (DialogInstance _dialogInstance) => { if (doneCallback != null) { doneCallback(_dialogInstance); } ShowFreePrizeDone(_dialogInstance); }, dialogButtons: ContentShowsButtons ? DialogInstance.DialogButtonsType.Custom : DialogInstance.DialogButtonsType.Ok); GameObject ImageCoins = GameObjectHelper.GetChildNamedGameObject(dialogInstance.gameObject, "ph_Image", true); ImageCoins.SetActive(false); if (this.PrizeItems > 0 && prizeIsCoins && sprite != null) { ImageCoins.SetActive(true); ImageCoins.GetComponent <Image>().sprite = sprite; } StartNewCountdown(); if (!Debug.isDebugBuild) { Fabric.Answers.Answers.LogContentView("FreePrize", "Dialog"); } #if !UNITY_EDITOR AdColonyManager.Instance.RequestAd(Constants.AdColonyDoubleDailyBonus); LoadAdmobRewarderVideo(); #endif return(dialogInstance); }
protected override Task OnEndDialogAsync(ITurnContext context, DialogInstance instance, DialogReason reason, CancellationToken cancellationToken = default(CancellationToken)) { return(base.OnEndDialogAsync(context, instance, reason, cancellationToken)); }
protected virtual Task OnEndDialogAsync(TurnContext context, DialogInstance instance, DialogReason reason, CancellationToken cancellationToken = default(CancellationToken)) { return(Task.CompletedTask); }