void ClickAction() { _button.onClick = _originalButtonEvent; int _persistentCount = _button.onClick.GetPersistentEventCount(); for (int i = 0; i < _persistentCount; i++) { _button.onClick.SetPersistentListenerState(i, UnityEngine.Events.UnityEventCallState.EditorAndRuntime); } _button.onClick.Invoke(); // disable again for (int i = 0; i < _persistentCount; i++) { _button.onClick.SetPersistentListenerState(i, UnityEngine.Events.UnityEventCallState.Off); } if (gameObject.activeInHierarchy == false) { _disabled = false; _button.onClick = _buttonEvent; } else { StartCoroutine(CoRoutines.DelayedCallback(0.25f, () => { _disabled = false; _button.onClick = _buttonEvent; })); } }
void Click() { if (_disabled) { return; } _disabled = true; if (_animator != null) { if (Constants.DelayButtonClickAction > 0.05f) { StartCoroutine(CoRoutines.DelayedCallback(Constants.DelayButtonClickAction, ClickAction)); } else { ClickAction(); } } else { ClickAction(); } }
void Animate(GameObject _ladybug, float delay = 0.0f) { StartCoroutine(CoRoutines.DelayedCallback(delay, () => { Animate(_ladybug); })); }
void Animate(GameObject _ladybug) { Vector3 pos = RandomPosition(); _ladybug.transform.DORotateQuaternion(Quaternion.LookRotation(Vector3.forward, pos - _ladybug.transform.position), 0.5f).SetEase(Ease.Linear); Animator anim = _ladybug.transform.GetChild(0).GetComponent <Animator>(); StartCoroutine(CoRoutines.DelayedCallback(0.5f, () => { anim.SetTrigger("Prepare"); })); StartCoroutine(CoRoutines.DelayedCallback(1f, () => { anim.SetTrigger("Fly"); _ladybug.transform.DOMove(pos, 2f).SetEase(Ease.Linear).OnComplete(() => { anim.SetTrigger("Idle"); StartCoroutine(CoRoutines.DelayedCallback(2.5f, () => { Animate(_ladybug, Random.Range(1f, 10f)); })); }); })); }
public override void OnClick() { Assert.IsTrue(CustomFreePrizeManager.IsActive, "You need to add the FreePrizeManager to the scene."); StartCoroutine(CoRoutines.DelayedCallback(Constants.DelayButtonClickAction, () => { CustomFreePrizeManager.Instance.ShowFreePrizeDialog(); })); }
public void CloseButton() { ChallengeManager.Instance.SetOnChallengeDetected(null); LeaveLoby(); StartCoroutine(CoRoutines.DelayedCallback(Constants.DelayButtonClickAction, () => { GameManager.LoadSceneWithTransitions("Menu"); })); }
public void HideBalloon() { if (balloon == null || balloon.activeInHierarchy == false) { return; } balloon.transform.DOScale(new Vector3(0, 0, 0), 1f).SetEase(Ease.OutElastic); StartCoroutine(CoRoutines.DelayedCallback(1.5f, DisableBalloon)); }
/// <summary> /// Complete the dialog /// </summary> public void Done() { // show / transition in and when done call coroutine float transitionTime = 0; #if BEAUTIFUL_TRANSITIONS //if (TransitionHelper.ContainsTransition(gameObject)) //{ transitionTime = TransitionHelper.GetTransitionOutTime(TransitionHelper.TransitionOut(gameObject)); //} #endif StartCoroutine(CoRoutines.DelayedCallback(transitionTime, DoneFinished)); }
public void SignUp() { if (PlayerPrefs.HasKey(Constants.KeyRedirectAfterSignIn)) { PlayerPrefs.SetInt(Constants.KeyRedirectAfterSignUp, PlayerPrefs.GetInt(Constants.KeyRedirectAfterSignIn)); } Close(); StartCoroutine(CoRoutines.DelayedCallback(Constants.DelayButtonClickAction, () => { SettingsContainer.Instance.SignUp(); })); }
// Use this for initialization void Start() { _scrollSnap = GameObjectHelper.GetChildComponentOnNamedGameObject <HorizontalScrollSnap>(gameObject, "ScrollView", true); _nextButton = GameObjectHelper.GetChildNamedGameObject(gameObject, "NextButton", true); container = gameObject; // AddBanner(); GameManager.SafeAddListener <BannerLoadedMessage>(BannerLoadedHandler); GameManager.SafeAddListener <VideoAdShowingMessage>(VideoAdShowingHandler); StartCoroutine(CoRoutines.DelayedCallback(0.5f, BonusCoins)); ((CustomGameManager)GameManager.Instance).ResetDefaultSound(); if (!Debug.isDebugBuild) { FlurryIOS.LogPageView(); FlurryAndroid.OnPageView(); Fabric.Answers.Answers.LogContentView("Levels", "Screen"); } _rankSignGameObject = GameObjectHelper.GetChildNamedGameObject(packsContainer, "Sign", true); _rankSignText = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(_rankSignGameObject, "RankName", true); _ranksVerticalScroll = GameObjectHelper.GetChildComponentOnNamedGameObject <CustomVerticalScrollSnap>(packsContainer, "ScrollView", true); PrepareRankForLevel(GameManager.Instance.Levels.Selected); _ranksVerticalScroll.StartingScreen = LevelController.Ranks().Items.Length - (_currentRank.Number - 1) - 1; if (PreferencesFactory.GetInt(Constants.KeyShowSelectedPack) > 0 && GameManager.Instance.Levels.Selected != null) { PreferencesFactory.DeleteKey(Constants.KeyShowSelectedPack); GoToLevel(GameManager.Instance.Levels.Selected); } #if !UNITY_EDITOR AdColonyManager.Instance.RequestAd(); // request ads to cache for CustomLevelButton.cs #endif }
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); } })); }
void Start() { _button = GetComponent <Button>(); _animator = GetComponent <Animator>(); // add delay because when button is Instantiated from prefab there is delay to add listeners StartCoroutine(CoRoutines.DelayedCallback(0.5f, () => { int _persistentCount = _button.onClick.GetPersistentEventCount(); // first disable all persistent clicks for (int i = 0; i < _persistentCount; i++) { _button.onClick.SetPersistentListenerState(i, UnityEngine.Events.UnityEventCallState.Off); } _originalButtonEvent = _button.onClick; _buttonEvent = new Button.ButtonClickedEvent(); _buttonEvent.AddListener(Click); _button.onClick = _buttonEvent; })); }
private void Start() { if (!GameSparksManager.IsTokenAvailable()) { GameSparksManager.Instance.AnonymousLogin(); } GameManager.SafeAddListener <FacebookProfilePictureMessage> (FacebookProfilePictureHandler); if (!_showInfo) { StartCoroutine(CoRoutines.DelayedCallback(0.35f, GetMonthlyScores)); MontlyButton.GetComponent <ButtonHover>().selected = true; TotalButton.GetComponent <ButtonHover>().selected = false; RewardsButton.GetComponent <ButtonHover>().selected = false; } if (!Debug.isDebugBuild) { Flurry.Flurry.Instance.LogEvent("Leaderboard"); Fabric.Answers.Answers.LogContentView("Leaderboard", "Dialog"); } }
bool OnShareLinkHandler(BaseMessage message) { GameManager.SafeRemoveListener <FacebookShareLinkMessage> (OnShareLinkHandler); FacebookShareLinkMessage msg = message as FacebookShareLinkMessage; if (msg.Result == FacebookShareLinkMessage.ResultType.OK) { if (InviteController.InviteBonusCoins()) { StartCoroutine(CoRoutines.DelayedCallback(2f, Continue)); } else { Continue(); } } else { Continue(); } return(true); }
public override void OnClick() { StartCoroutine(CoRoutines.DelayedCallback(Constants.DelayButtonClickAction, () => { GameManager.SafeQueueMessage(new SettingsOpenMessage()); })); }
///// <summary> ///// Show the dialog instance substituting in passed values and running any transitions. ///// </summary> ///// <param name="title"></param> ///// <param name="text"></param> ///// <param name="text2"></param> ///// <param name="sprite"></param> ///// <param name="doneCallback"></param> ///// <param name="destroyOnClose"></param> ///// <param name="dialogButtons"></param> //public void Show(LocalisableText title, LocalisableText text, LocalisableText text2 = null, Sprite sprite = null, // Action<DialogInstance> doneCallback = null, bool destroyOnClose = true, // DialogButtonsType dialogButtons = DialogButtonsType.Custom) //{ // var tTitle = title == null ? null : title.GetValue(); // var tText = title == null ? null : text.GetValue(); // var tText2 = title == null ? null : text2.GetValue(); // Show(title: tTitle, text: tText, text2: tText2, sprite: sprite, doneCallback: doneCallback, destroyOnClose: destroyOnClose, dialogButtons: dialogButtons); //} /// <summary> /// Show the dialog instance substituting in passed values and running any transitions. /// </summary> /// <param name="title"></param> /// <param name="titleKey"></param> /// <param name="text"></param> /// <param name="textKey"></param> /// <param name="text2"></param> /// <param name="text2Key"></param> /// <param name="sprite"></param> /// <param name="doneCallback"></param> /// <param name="destroyOnClose"></param> /// <param name="dialogButtons"></param> /// <param name="buttonText"></param> public void Show(string title = null, string titleKey = null, string text = null, string textKey = null, string text2 = null, string text2Key = null, Sprite sprite = null, Action <DialogInstance> doneCallback = null, bool destroyOnClose = true, DialogButtonsType dialogButtons = DialogButtonsType.Custom, LocalisableText[] buttonText = null) { GameObject childGameObject; _dialogButtons = dialogButtons; DoneCallback = doneCallback; _destroyOnClose = destroyOnClose; // increase open count - not thread safe, but should be ok! Assert.IsTrue(DialogManager.IsActive, "Ensure that you have added a DialogManager component to your scene before showing a dialog!"); DialogManager.Instance.Count++; IsShown = true; // default result DialogResult = DialogResultType.Ok; if (!string.IsNullOrEmpty(titleKey)) { title = GlobalLocalisation.GetText(titleKey); } if (title != null) { UIHelper.SetTextOnChildGameObject(gameObject, "ph_Title", title, true); } if (sprite != null) { UIHelper.SetSpriteOnChildGameObject(gameObject, "ph_Image", sprite, true); } else { childGameObject = GameObjectHelper.GetChildNamedGameObject(gameObject, "ph_Image", true); if (childGameObject != null) { childGameObject.SetActive(false); } } if (!string.IsNullOrEmpty(textKey)) { text = GlobalLocalisation.GetText(textKey); } if (text != null) { UIHelper.SetTextOnChildGameObject(gameObject, "ph_Text", text, true); } else { childGameObject = GameObjectHelper.GetChildNamedGameObject(gameObject, "ph_Text", true); if (childGameObject != null) { childGameObject.SetActive(false); } } if (!string.IsNullOrEmpty(text2Key)) { text2 = GlobalLocalisation.GetText(text2Key); } if (text2 != null) { UIHelper.SetTextOnChildGameObject(gameObject, "ph_Text2", text2, true); } else { childGameObject = GameObjectHelper.GetChildNamedGameObject(gameObject, "ph_Text2", true); if (childGameObject != null) { childGameObject.SetActive(false); } } GameObject okButton, cancelButton; switch (_dialogButtons) { case DialogButtonsType.Ok: okButton = GameObjectHelper.GetChildNamedGameObject(gameObject, "OkButton", true); if (okButton != null) { okButton.SetActive(true); } else { Assert.IsNotNull(_textTemplateButton, "If using Ok buttons, ensure the Dialog a GameObject named OkButton or a GameObject named TextButton that is a template for text buttons"); var button = CreateTextButton(LocalisableText.CreateLocalised("Button.Ok")); button.GetComponent <Button>().onClick.AddListener(() => DoneOk()); } break; case DialogButtonsType.OkCancel: okButton = GameObjectHelper.GetChildNamedGameObject(gameObject, "OkButton", true); cancelButton = GameObjectHelper.GetChildNamedGameObject(gameObject, "CancelButton", true); if (okButton != null && cancelButton != null) { okButton.SetActive(true); cancelButton.SetActive(true); } else { Assert.IsNotNull(_textTemplateButton, "If using OkCancel buttons, ensure the Dialog has GameObjects named OkButton and CancelButton or a GameObject named TextButton that is a template for text buttons"); var button = CreateTextButton(LocalisableText.CreateLocalised("Button.Ok")); button.GetComponent <Button>().onClick.AddListener(() => DoneOk()); button = CreateTextButton(LocalisableText.CreateLocalised("Button.Cancel")); button.GetComponent <Button>().onClick.AddListener(() => DoneCancel()); } break; case DialogButtonsType.Cancel: cancelButton = GameObjectHelper.GetChildNamedGameObject(gameObject, "CancelButton", true); if (cancelButton != null) { cancelButton.SetActive(true); } else { Assert.IsNotNull(_textTemplateButton, "If using a Cancel button, ensure the Dialog a GameObject named CancelButton or a GameObject named TextButton that is a template for text buttons"); var button = CreateTextButton(LocalisableText.CreateLocalised("Button.Cancel")); button.GetComponent <Button>().onClick.AddListener(() => DoneCancel()); } break; case DialogButtonsType.YesNo: var yesButton = GameObjectHelper.GetChildNamedGameObject(gameObject, "YesButton", true); var noButton = GameObjectHelper.GetChildNamedGameObject(gameObject, "NoButton", true); if (yesButton != null && noButton != null) { yesButton.SetActive(true); noButton.SetActive(true); } else { Assert.IsNotNull(_textTemplateButton, "If using YesNo buttons, ensure the Dialog has GameObjects named YesButton and NoButton or a GameObject named TextButton that is a template for text buttons"); var button = CreateTextButton(LocalisableText.CreateLocalised("Button.Yes")); button.GetComponent <Button>().onClick.AddListener(() => DoneYes()); button = CreateTextButton(LocalisableText.CreateLocalised("Button.No")); button.GetComponent <Button>().onClick.AddListener(() => DoneNo()); } break; case DialogButtonsType.Text: Assert.IsNotNull(_textTemplateButton, "If using Text buttons, ensure the Dialog has a GameObject named TextButton that is a template for text buttons"); Assert.IsNotNull(buttonText, "If using Text buttons, ensure you pass a valid array of localisable texts into the show method."); var counter = 0; foreach (var localisableText in buttonText) { var button = CreateTextButton(localisableText); var counter1 = counter; button.GetComponent <Button>().onClick.AddListener(() => DoneCustom(counter1)); counter++; } break; } // show / transition in and when done call coroutine float transitionTime = 0; Target.SetActive(true); #if BEAUTIFUL_TRANSITIONS //if (TransitionHelper.ContainsTransition(gameObject)) //{ transitionTime = TransitionHelper.GetTransitionInTime(TransitionHelper.TransitionIn(gameObject)); //} #endif StartCoroutine(CoRoutines.DelayedCallback(transitionTime, ShowFinished)); }
public void Close() { StartCoroutine(CoRoutines.DelayedCallback(Constants.DelayButtonClickAction, () => { GameManager.LoadSceneWithTransitions("Menu"); })); }
/// <summary> /// Show the dialog instance substituting in passed values and running any transitions. /// </summary> /// <param name="title"></param> /// <param name="titleKey"></param> /// <param name="text"></param> /// <param name="textKey"></param> /// <param name="text2"></param> /// <param name="text2Key"></param> /// <param name="sprite"></param> /// <param name="doneCallback"></param> /// <param name="destroyOnClose"></param> /// <param name="dialogButtons"></param> public void Show(string title = null, string titleKey = null, string text = null, string textKey = null, string text2 = null, string text2Key = null, Sprite sprite = null, Action <DialogInstance> doneCallback = null, bool destroyOnClose = true, DialogButtonsType dialogButtons = DialogButtonsType.Custom) { GameObject childGameObject; _dialogButtons = dialogButtons; DoneCallback = doneCallback; _destroyOnClose = destroyOnClose; // increase open count - not thread safe, but should be ok! Assert.IsTrue(DialogManager.IsActive, "Ensure that you have added a DialogManager component to your scene before showing a dialog!"); DialogManager.Instance.Count++; IsShown = true; // default result DialogResult = DialogResultType.Ok; if (titleKey != null) { title = LocaliseText.Get(titleKey); } if (title != null) { UIHelper.SetTextOnChildGameObject(gameObject, "ph_Title", title, true); } if (sprite != null) { UIHelper.SetSpriteOnChildGameObject(gameObject, "ph_Image", sprite, true); } else { childGameObject = GameObjectHelper.GetChildNamedGameObject(gameObject, "ph_Image", true); if (childGameObject != null) { childGameObject.SetActive(false); } } if (textKey != null) { text = LocaliseText.Get(textKey); } if (text != null) { UIHelper.SetTextOnChildGameObject(gameObject, "ph_Text", text, true); } else { childGameObject = GameObjectHelper.GetChildNamedGameObject(gameObject, "ph_Text", true); if (childGameObject != null) { childGameObject.SetActive(false); } } if (text2Key != null) { text2 = LocaliseText.Get(text2Key); } if (text2 != null) { UIHelper.SetTextOnChildGameObject(gameObject, "ph_Text2", text2, true); } else { childGameObject = GameObjectHelper.GetChildNamedGameObject(gameObject, "ph_Text2", true); if (childGameObject != null) { childGameObject.SetActive(false); } } switch (_dialogButtons) { case DialogButtonsType.Ok: GameObjectHelper.GetChildNamedGameObject(gameObject, "OkButton", true).SetActive(true); break; case DialogButtonsType.OkCancel: GameObjectHelper.GetChildNamedGameObject(gameObject, "OkButton", true).SetActive(true); GameObjectHelper.GetChildNamedGameObject(gameObject, "CancelButton", true).SetActive(true); break; case DialogButtonsType.Cancel: GameObjectHelper.GetChildNamedGameObject(gameObject, "CancelButton", true).SetActive(true); break; case DialogButtonsType.YesNo: GameObjectHelper.GetChildNamedGameObject(gameObject, "YesButton", true).SetActive(true); GameObjectHelper.GetChildNamedGameObject(gameObject, "NoButton", true).SetActive(true); break; } // show / transition in and when done call coroutine float transitionTime = 0; Target.SetActive(true); #if BEAUTIFUL_TRANSITIONS //if (TransitionHelper.ContainsTransition(gameObject)) //{ transitionTime = TransitionHelper.GetTransitionInTime(TransitionHelper.TransitionIn(gameObject)); //} #endif StartCoroutine(CoRoutines.DelayedCallback(transitionTime, ShowFinished)); }
public void RefreshChallengesList() { if (_refreshCoroutine != null) { StopCoroutine(_refreshCoroutine); } _challenges.Clear(); var requestData = new GSRequestData(); requestData.AddString("Language", LanguageUtils.RealLanguage(LocaliseText.Language)); var eligibilityCriteria = new GSRequestData(); GSData _d = new GSData(new Dictionary <string, object>() { { "Language", LanguageUtils.RealLanguage(LocaliseText.Language) } }); eligibilityCriteria.AddObject("segments", _d); new FindChallengeRequest() .SetAccessType("PUBLIC") .SetShortCode(new List <string> { Constants.ChallengeShortCode }) .SetScriptData(requestData) .SetEligibility(eligibilityCriteria) .Send((secondResponse) => { var publicChallenges = secondResponse.ChallengeInstances; if (publicChallenges == null || !publicChallenges.Any()) { var challengesData = secondResponse.ScriptData; if (challengesData == null) { return; } var dataList = secondResponse.ScriptData.GetGSDataList("challenges"); if (dataList != null) { if (dataList.Count > 0) { var enumerator = dataList.GetEnumerator(); while (enumerator.MoveNext()) { var current = enumerator.Current; if (current != null) { string username = null; string userId = null; var challengeId = current.GetString("challengeId"); var scriptData = current.GetGSData("scriptData"); if (scriptData != null) { } var challenger = current.GetGSData("challenger"); if (challenger != null) { username = challenger.GetString("name"); userId = challenger.GetString("id"); if (userId == PreferencesFactory.GetString(Constants.ProfileUserId)) { continue; } } var ch = new Challenge { ChallengeId = challengeId, UserName = username, UserId = userId, AvatarUploadId = "", ExternalIds = null }; _challenges.Add(ch); } } enumerator.Dispose(); } } } List <string> _ignoreChallangeIds = new List <string>(); var ignoreList = secondResponse.ScriptData.GetGSDataList("ignoreChallanges"); if (ignoreList != null) { var challengesIgnoreEnum = ignoreList.GetEnumerator(); while (challengesIgnoreEnum.MoveNext()) { var challenge = challengesIgnoreEnum.Current; _ignoreChallangeIds.Add(challenge.GetString("challengeId")); } } if (publicChallenges != null) { var challengesEnum = publicChallenges.GetEnumerator(); while (challengesEnum.MoveNext()) { var challenge = challengesEnum.Current; if (_ignoreChallangeIds.Contains(challenge.ChallengeId)) { continue; } var scriptData = challenge.ScriptData; var showInList = true; if (scriptData != null) { var k = scriptData.GetBoolean("showInList"); if (k != null) { showInList = (bool)k; } } if (showInList) { var username = challenge.Challenger.Name; var userId = challenge.Challenger.Id; if (userId == PreferencesFactory.GetString(Constants.ProfileUserId)) { continue; } var ch = new Challenge { ChallengeId = challenge.ChallengeId, UserName = username, UserId = userId, AvatarUploadId = challenge.ScriptData.GetString("avatarUploadId"), ExternalIds = challenge.Challenger.ExternalIds }; _challenges.Add(ch); } } challengesEnum.Dispose(); if (_onChallengeDetected != null) { _onChallengeDetected.OnChallengesListeFetched(_challenges); } } if (ShouldGetChallengesList) { _refreshCoroutine = CoRoutines.DelayedCallback(_challengeRefreshRate, RefreshChallengesList); StartCoroutine(_refreshCoroutine); } }); }
// Use this for initialization void Start() { Branch.initSession(CallbackWithBranchUniversalObject); int show = PreferencesFactory.GetInt(Constants.KeyShowBannerOnMainMenuScreen, 0); container = GameObject.Find("Container"); if (PreferencesFactory.GetInt(Constants.KeyNoAds, 0) == 1) { show = 0; // disable ads } _rewardShareButton = GameObjectHelper.GetChildNamedGameObject(gameObject, "RewardButton", true); if (_rewardShareButton != null && RewardsShareHelper.WillReward()) { ShowRewardShareButton(); } #if !UNITY_EDITOR // delay request until AdColony is configured StartCoroutine(CoRoutines.DelayedCallback(1.5f, () => { AdColonyManager.Instance.RequestAd(); })); #endif if (show > 0) // show banner only when return to main screen, not cold start { AddBanner(); PreferencesFactory.DeleteKey(Constants.KeyShowBannerOnMainMenuScreen); int CountClicks = PreferencesFactory.GetInt(Constants.KeyCountMainMenuClicks); PreferencesFactory.SetInt(Constants.KeyCountMainMenuClicks, CountClicks + 1); // if (CountClicks > 0 && CountClicks % Constants.ShowAdsPerTime == 0 && Reachability.Instance.IsReachable ()) { // Loading.Instance.Show (); // AdColonyManager.Instance.SetCallback (BannerMainMenuClosed); // AdColonyManager.Instance.PlayAd(AdColonyManager.Instance.AdForZoneId()); //} } else // show banner on cold start { ColdStart = true; int CountMainMenuColdStart = PreferencesFactory.GetInt(Constants.KeyCountMainMenuColdStart); PreferencesFactory.SetInt(Constants.KeyCountMainMenuColdStart, CountMainMenuColdStart + 1); } GameManager.SafeAddListener <BannerLoadedMessage> (BannerLoadedHandler); GameManager.SafeAddListener <VideoAdShowingMessage> (VideoAdShowingHandler); ((CustomGameManager)GameManager.Instance).ResetDefaultSound(); if (!Debug.isDebugBuild) { FlurryIOS.LogPageView(); FlurryAndroid.OnPageView(); Fabric.Answers.Answers.LogContentView("Menu", "Screen"); } StartCoroutine(CoRoutines.DelayedCallback(0.5f, () => { CheckForPrize(); })); GameSparksManager.Instance.SetGameMode(GameMode.Single); AnimatePig(); }
public void CloseButton() { StartCoroutine(CoRoutines.DelayedCallback(Constants.DelayButtonClickAction, SettingsClose)); }