void ForceShowHint(E_Hint hintId, float delay = -1.0f) { if (m_CurrentHint == hintId) { return; } SetHintVisibility(m_CurrentHint, false); m_CurrentHint = hintId; SetHintTimer(delay < 0.0f ? m_InitialHintDelay : delay); }
protected override void OnViewHide() { DestroyTweener(); StopHintTimer(); m_CurrentHint = E_Hint.Max; m_PreviousHint = E_Hint.Max; UnbindControls(); base.OnViewHide(); }
void BindControls() { for (int idx = 0; idx < m_Hints.Length; ++idx) { if (m_Hints[idx].HintButton == null) { continue; } if (m_Hints[idx].LinkedButton == null) { continue; } // store hint id for later use in lambdas E_Hint hintId = m_Hints[idx].BindHintId; // register delegate to hint button GuiBaseUtils.RegisterButtonDelegate(m_Hints[idx].HintButton, null, (inside) => { if (inside == true) { SetHintVisibility(hintId, false); } }); // register delegate to linked button GuiBaseUtils.RegisterButtonDelegate3(m_Hints[idx].LinkedButton, (widget, evt) => { SetHintVisibility(m_CurrentHint, false); }, null, null); // setup offset Vector2 offset = m_Hints[idx].Offset; offset = m_Hints[idx].LinkedButton.transform.position; offset.x = m_Hints[idx].LinkedButton.Widget.GetOrigPos().x - offset.x; offset.y = m_Hints[idx].LinkedButton.Widget.GetOrigPos().y - offset.y; m_Hints[idx].Offset = offset; // hide hint SetHintVisibility(hintId, false); } }
HintInfo GetHintInfo(E_Hint hintId) { return(System.Array.Find(m_Hints, (obj) => { return obj.BindHintId == hintId ? true : false; })); }
void SetHintVisibility(E_Hint hintId, bool state) { if (state == true) { if (GuiOptions.showHints == false) { return; } if (BuildInfo.Version.Stage == BuildInfo.Stage.Beta) { return; } } HintInfo info = GetHintInfo(hintId); if (info == null) { return; } if (info.HintButton == null) { return; } info.HintButton.Widget.Show(state, true); if (state == true) { if (m_HintSound != null) { MFGuiManager.Instance.PlayOneShot(m_HintSound); } m_CurrentHint = hintId; GUIBase_Widget widget = info.HintButton.Widget; Transform trans = widget.transform; Vector3 origin = widget.GetOrigPos(); origin.y -= info.Offset.y; // animate transparency Tweener.TweenFromTo(widget, "m_FadeAlpha", 0.0f, 1.0f, 0.2f, Tween.Easing.Quad.EaseIn, (tween, finished) => { GUIBase_Widget[] children = widget.GetComponentsInChildren <GUIBase_Widget>(); foreach (var child in children) { child.FadeAlpha = widget.FadeAlpha; } }); // animate position Tweener.TweenFromTo(this, "m_HintTweenY", origin.y + 25.0f, origin.y, 0.15f, Tween.Easing.Sine.EaseInOut, (tween, finished) => { trans.position = new Vector3(trans.position.x, m_HintTweenY, trans.position.z); if (finished == true) { Tweener.TweenFromTo(this, "m_HintTweenY", origin.y + 5.0f, origin.y, 0.15f, Tween.Easing.Sine.EaseInOut, (tween1, finished1) => { trans.position = new Vector3(trans.position.x, m_HintTweenY, trans.position.z); }); } }); } else if (m_CurrentHint == hintId) { m_PreviousHint = m_CurrentHint; m_CurrentHint = E_Hint.Max; Tweener.StopTweens(true); } }
void ShowHint() { if (UserGuide.InitialSequenceFinished == false) { // wait until all initial dialogs hide SetHintTimer(m_InitialHintDelay); return; } if (UserGuideAction_ResetResearch.NotifyUser == true) { SetHintTimer(m_InitialHintDelay); return; } if (m_CanShowHints == false || string.IsNullOrEmpty(m_LastVisibleScreen) == false) { // do not display hint while help is displayed SetHintTimer(m_PreviousHint == E_Hint.Max ? m_InitialHintDelay : m_NextHintDelay); return; } bool isMainMenu = GuiFrontendMain.IsVisible; // deduce next hint E_Hint hintId = m_CurrentHint; bool isRandom = false; if (hintId == E_Hint.Max) { if (isMainMenu == true && m_PreviousHint == E_Hint.Max && m_CurrentHint == E_Hint.Max) { // we want to display premium hint as the first hint ever hintId = E_Hint.PremiumBuy; } else { // randomly select one of hints isRandom = true; do { hintId = (E_Hint)Random.Range(0, (int)E_Hint.Max); } while (hintId == m_PreviousHint); } } switch (hintId) { case E_Hint.PremiumBuy: if (isMainMenu == true) { if (CloudUser.instance.isPremiumAccountActive == true) { System.TimeSpan time = CloudUser.instance.GetPremiumAccountEndDateTime() - CloudDateTime.UtcNow; hintId = time.TotalDays < 1 ? E_Hint.PremiumRenew : E_Hint.Max; } } else { hintId = E_Hint.Max; } break; case E_Hint.PremiumRenew: if (isMainMenu == true) { if (CloudUser.instance.isPremiumAccountActive == false) { hintId = E_Hint.PremiumBuy; } else { System.TimeSpan time = CloudUser.instance.GetPremiumAccountEndDateTime() - CloudDateTime.UtcNow; if (time.TotalDays > 1) { hintId = E_Hint.Max; } } } else { hintId = E_Hint.Max; } break; case E_Hint.Player: if (isMainMenu == false) { hintId = E_Hint.Max; } break; case E_Hint.Xp: //if (... some clever condition here ...) { hintId = E_Hint.Max; } break; case E_Hint.Gold: if (isRandom == true && ShopDataBridge.Instance.PlayerGold > 0) { hintId = E_Hint.Max; } break; case E_Hint.Money: if (isRandom == true && ShopDataBridge.Instance.PlayerMoney > 0) { hintId = E_Hint.Max; } break; case E_Hint.Chips: //if (... some clever condition here ...) { hintId = E_Hint.Max; } break; default: break; } // hide current hint if needed if (m_CurrentHint != hintId) { SetHintVisibility(m_CurrentHint, false); } // show new hint SetHintVisibility(hintId, true); // set new timer SetHintTimer(m_NextHintDelay); }