/// <summary> /// Show generic tooltip /// </summary> /// <returns></returns> IEnumerator ShowTooltip() { //delay before tooltip kicks in yield return(new WaitForSeconds(mouseOverDelay)); //activate tool tip if mouse still over button if (onMouseFlag == true && GameManager.i.inputScript.ModalState == ModalState.Normal) { //do once Vector3 screenPos = transform.position; screenPos.y -= 55; while (GameManager.i.tooltipGenericScript.CheckTooltipActive() == false) { tooltipHeader = GameManager.i.turnScript.GetActionsTooltip(); tooltipMain = GameManager.i.turnScript.GetActionAdjustmentTooltip(); tooltipDetails = GameManager.i.turnScript.GetSecurityMeasureTooltip(); GenericTooltipData data = new GenericTooltipData() { screenPos = screenPos, main = tooltipMain, header = tooltipHeader, details = tooltipDetails }; GameManager.i.tooltipGenericScript.SetTooltip(data); yield return(null); } /*//fade in * float alphaCurrent; * while (GameManager.instance.tooltipGenericScript.GetOpacity() < 1.0) * { * alphaCurrent = GameManager.instance.tooltipGenericScript.GetOpacity(); * alphaCurrent += Time.deltaTime / mouseOverFade; * GameManager.instance.tooltipGenericScript.SetOpacity(alphaCurrent); * yield return null; * }*/ } }
IEnumerator ShowRenownTooltip() { //delay before tooltip kicks in yield return(new WaitForSeconds(mouseOverDelay)); GenericTooltipData data = null; //activate tool tip if mouse still over button if (onMouseFlag == true) { //do once while (GameManager.i.tooltipGenericScript.CheckTooltipActive() == false) { data = GameManager.i.actorScript.GetPowerPlayerTooltip(); data.screenPos = transform.position; if (data != null) { GameManager.i.tooltipGenericScript.SetTooltip(data); } yield return(null); } //fade in if (data != null) { float alphaCurrent; while (GameManager.i.tooltipGenericScript.GetOpacity() < 1.0) { alphaCurrent = GameManager.i.tooltipGenericScript.GetOpacity(); alphaCurrent += Time.deltaTime / mouseOverFade; GameManager.i.tooltipGenericScript.SetOpacity(alphaCurrent); yield return(null); } } } }
IEnumerator ShowGenericTooltip() { //delay before tooltip kicks in yield return(new WaitForSeconds(mouseOverDelay)); //activate tool tip if mouse still over button if (onMouseFlag == true) { //take into account any user supplied position adjustments (by default will be '0') Vector3 position = transform.position; position.x += x_offset; position.y += y_offset; while (GameManager.i.tooltipGenericScript.CheckTooltipActive() == false) { GenericTooltipData data = new GenericTooltipData() { screenPos = position, main = tooltipMain, header = tooltipHeader, details = tooltipDetails, tooltipType = tooltipType }; GameManager.i.tooltipGenericScript.SetTooltip(data); yield return(null); } /*//fade in * float alphaCurrent; * while (GameManager.instance.tooltipGenericScript.GetOpacity() < 1.0) * { * alphaCurrent = GameManager.instance.tooltipGenericScript.GetOpacity(); * alphaCurrent += Time.deltaTime / mouseOverFade; * GameManager.instance.tooltipGenericScript.SetOpacity(alphaCurrent); * yield return null; * }*/ } }
/// <summary> /// Initialise Actor and Player related tooltips /// NOTE: Using custom Generic Tooltips here rather than Help Tooltips due to sequencing issues at startup /// </summary> public void InitialiseTooltips() { //player mood UI playerMoodTooltip.tooltipHeader = "Mood"; playerMoodTooltip.tooltipMain = string.Format("{0} {1}", GameManager.i.guiScript.opinionIcon, GameManager.Formatt("0 to 3 Stars", ColourType.neutralText)); string details = string.Format("You will become STRESSED if your mood goes below zero"); playerMoodTooltip.tooltipDetails = GameManager.Formatt(details, ColourType.moccasinText); playerMoodTooltip.y_offset = 100; //player stressed UI playerStressedTooltip.tooltipHeader = GameManager.Formatt("Stressed", ColourType.badText); playerStressedTooltip.tooltipMain = GameManager.Formatt("Mood falls below Zero", ColourType.neutralText); details = "You can take Stress Leave or Lie Low (Right Click Player pic) to remove. You run the risk of suffering a BREAKDOWN"; playerStressedTooltip.tooltipDetails = GameManager.Formatt(details, ColourType.moccasinText); playerStressedTooltip.y_offset = 100; //actor compatibility GenericTooltipData data = GameManager.i.guiScript.GetCompatibilityTooltip(); if (data != null) { for (int i = 0; i < 4; i++) { GenericTooltipUI tooltip = arrayOfCompatibilityTooltips[i]; if (tooltip != null) { tooltip.tooltipHeader = data.header; tooltip.tooltipMain = data.main; tooltip.tooltipDetails = data.details; tooltip.tooltipType = GenericTooltipType.ActorInfo; tooltip.x_offset = 100; tooltip.y_offset = 20; } else { Debug.LogWarningFormat("Invalid arrayOfCompatibilityTooltip[{0}] (Null)", i); } } } else { Debug.LogWarningFormat("Invalid GenericTooltipData (Null) for Compatibility tooltip"); } }
/// <summary> /// Show generic tooltip /// </summary> /// <returns></returns> IEnumerator ShowTooltip() { //delay before tooltip kicks in yield return(new WaitForSeconds(mouseOverDelay)); playerSide = GameManager.i.sideScript.PlayerSide; //activate tool tip if mouse still over button if (onMouseFlag == true) { //do once Vector3 screenPos = transform.position; screenPos.y -= 55; while (GameManager.i.tooltipGenericScript.CheckTooltipActive() == false) { tooltipHeader = string.Format("{0} <size=115%>Approval</size>", GameManager.i.hqScript.GetHqName(playerSide)); tooltipMain = GameManager.i.hqScript.GetHqApprovalLevel(playerSide); tooltipDetails = GameManager.i.hqScript.GetHqDetails(playerSide, true); GenericTooltipData data = new GenericTooltipData() { screenPos = screenPos, main = tooltipMain, header = tooltipHeader, details = tooltipDetails }; GameManager.i.tooltipGenericScript.SetTooltip(data); yield return(null); } /*//fade in * float alphaCurrent; * while (GameManager.instance.tooltipGenericScript.GetOpacity() < 1.0) * { * alphaCurrent = GameManager.instance.tooltipGenericScript.GetOpacity(); * alphaCurrent += Time.deltaTime / mouseOverFade; * GameManager.instance.tooltipGenericScript.SetOpacity(alphaCurrent); * yield return null; * }*/ } }
/// <summary> /// Show generic tooltip /// </summary> /// <returns></returns> IEnumerator ShowTooltip() { //delay before tooltip kicks in yield return(new WaitForSeconds(mouseOverDelay)); //activate tool tip if mouse still over button if (onMouseFlag == true && GameManager.i.inputScript.ModalState == ModalState.Normal) { //do once Vector3 screenPos = transform.position; screenPos.x -= 280; screenPos.y -= 90; while (GameManager.i.tooltipGenericScript.CheckTooltipActive() == false && GameManager.i.guiScript.CheckIsBlocked() == false) { tooltipHeader = string.Format("{0}{1}", GameManager.i.cityScript.GetCityNameFormatted(), GameManager.i.cityScript.GetCityArcFormatted()); tooltipMain = GameManager.i.cityScript.GetCityDescriptionFormatted(); tooltipDetails = GameManager.i.cityScript.GetCityDetails(); GenericTooltipData data = new GenericTooltipData() { screenPos = screenPos, main = tooltipMain, header = tooltipHeader, details = tooltipDetails }; GameManager.i.tooltipGenericScript.SetTooltip(data); yield return(null); } /*//fade in * float alphaCurrent; * while (GameManager.instance.tooltipGenericScript.GetOpacity() < 1.0) * { * alphaCurrent = GameManager.instance.tooltipGenericScript.GetOpacity(); * alphaCurrent += Time.deltaTime / mouseOverFade; * GameManager.instance.tooltipGenericScript.SetOpacity(alphaCurrent); * yield return null; * }*/ } }
/// <summary> /// Initialise Generic Tool tip. General Purpose. Can take one to three text segments and auto divides them as necessary. /// Unique to the Generic tool tip, colours are set by the calling method /// </summary> public void SetTooltip(GenericTooltipData data) { //open panel at start tooltipGenericCanvas.gameObject.SetActive(true); tooltipGenericObject.SetActive(true); genericText.gameObject.SetActive(true); genericHeader.gameObject.SetActive(false); genericDetail.gameObject.SetActive(false); dividerTop.gameObject.SetActive(false); dividerBottom.gameObject.SetActive(false); /*//set opacity to zero (invisible) * SetOpacity(0f);*/ //set state of all items in tooltip window genericText.text = data.main; //header if (string.IsNullOrEmpty(data.header) == false) { genericHeader.text = data.header; genericHeader.gameObject.SetActive(true); dividerTop.gameObject.SetActive(true); } //details if (string.IsNullOrEmpty(data.details) == false) { genericDetail.text = data.details; genericDetail.gameObject.SetActive(true); dividerBottom.gameObject.SetActive(true); } //type tooltipType = data.tooltipType; //update rectTransform to get a correct height as it changes every time with the dynamic menu resizing depending on number of buttons Canvas.ForceUpdateCanvases(); rectTransform = tooltipGenericObject.GetComponent <RectTransform>(); //get dimensions of dynamic tooltip float width = rectTransform.rect.width; float height = rectTransform.rect.height; float halfWidth = width * 0.5f; //place tooltip adjacent to the button data.screenPos.y -= height / 4; if (data.screenPos.y + height >= Screen.height) { data.screenPos.y -= (data.screenPos.y + height - Screen.height) + offset; } //to the right if (data.screenPos.x + width >= Screen.width) { data.screenPos.x -= (width * 2 + data.screenPos.x - Screen.width); /*data.screenPos.x -= (data.screenPos.x + width - Screen.width - width / 4);*/ } /*else if (screenPos.x - width <= 0) * { screenPos.x += width - screenPos.x; }*/ //minimum position of tooltip from Left Hand side is half width else if (data.screenPos.x <= halfWidth) { data.screenPos.x = halfWidth; } else { data.screenPos.x += width / 4; } //never applies, dead code //set new position tooltipGenericObject.transform.position = data.screenPos; Debug.LogFormat("[UI] TooltipGeneric.cs -> SetTooltip{0}", "\n"); }
/// <summary> /// tooltip coroutine /// </summary> /// <returns></returns> private IEnumerator ShowTooltip() { float alphaCurrent; //delay before tooltip kicks in yield return(new WaitForSeconds(mouseOverDelay)); //activate tool tip if mouse still over node if (onMouseFlag == true) { switch (menuType) { case ActionMenuType.Node: case ActionMenuType.NodeGear: //need to regularly update node details, rather than just at game start nodeObject = GameManager.i.dataScript.GetNodeObject(nodeID); if (nodeObject != null) { node = nodeObject.GetComponent <Node>(); } //do once while (GameManager.i.tooltipNodeScript.CheckTooltipActive() == false) { List <string> activeList = new List <string>(); switch (GameManager.i.turnScript.currentSide.level) { case 1: //Authority activeList = GameManager.i.dataScript.GetActiveContactsAtNodeAuthority(nodeID); break; case 2: activeList = GameManager.i.dataScript.GetActiveContactsAtNodeResistance(nodeID); break; } List <EffectDataTooltip> effectsList = node.GetListOfOngoingEffectTooltips(); List <string> targetList = GameManager.i.targetScript.GetTargetTooltip(node.targetName, node.isTargetKnown); List <string> teamList = new List <string>(); List <Team> listOfTeams = node.GetListOfTeams(); if (listOfTeams.Count > 0) { foreach (Team team in listOfTeams) { teamList.Add(string.Format("{0} team", team.arc.name)); } } //adjust position prior to sending (rectTransform is in World units) Vector3 positionNode = rectTransform.position; positionNode.x += 150; positionNode.y -= 125; positionNode = Camera.main.ScreenToWorldPoint(positionNode); NodeTooltipData nodeTooltip = new NodeTooltipData() { nodeName = node.nodeName, type = string.Format("{0} ID {1}", node.Arc.name, nodeID), arrayOfStats = new int[] { node.Stability, node.Support, node.Security }, listOfContactsCurrent = activeList, listOfEffects = effectsList, listOfTeams = teamList, listOfTargets = targetList, tooltipPos = positionNode }; GameManager.i.tooltipNodeScript.SetTooltip(nodeTooltip); yield return(null); } //fade in while (GameManager.i.tooltipNodeScript.GetOpacity() < 1.0) { alphaCurrent = GameManager.i.tooltipNodeScript.GetOpacity(); alphaCurrent += Time.deltaTime / mouseOverFade; GameManager.i.tooltipNodeScript.SetOpacity(alphaCurrent); yield return(null); } break; case ActionMenuType.Gear: Gear gear = GameManager.i.dataScript.GetGear(gearName); if (gear != null) { GenericTooltipDetails details = GameManager.i.gearScript.GetGearTooltip(gear); if (details != null) { //do once while (GameManager.i.tooltipGenericScript.CheckTooltipActive() == false) { //adjust position prior to sending Vector3 positionGear = rectTransform.position; GenericTooltipData data = new GenericTooltipData() { screenPos = positionGear, main = details.textMain, header = details.textHeader, details = details.textDetails }; GameManager.i.tooltipGenericScript.SetTooltip(data); yield return(null); //fade in while (GameManager.i.tooltipGenericScript.GetOpacity() < 1.0) { alphaCurrent = GameManager.i.tooltipGenericScript.GetOpacity(); alphaCurrent += Time.deltaTime / mouseOverFade; GameManager.i.tooltipGenericScript.SetOpacity(alphaCurrent); yield return(null); } } } } break; case ActionMenuType.Actor: GlobalSide side = GameManager.i.sideScript.PlayerSide; Actor actor = GameManager.i.dataScript.GetCurrentActor(actorSlotID, side); if (actor != null) { //do once while (GameManager.i.tooltipActorScript.CheckTooltipActive() == false) { //adjust position prior to sending Vector3 positionActor = rectTransform.position; positionActor.x += 70; positionActor.y -= 100; ActorTooltipData actorTooltip = actor.GetTooltipData(positionActor); GameManager.i.tooltipActorScript.SetTooltip(actorTooltip, actor.slotID); yield return(null); //fade in while (GameManager.i.tooltipActorScript.GetOpacity() < 1.0) { alphaCurrent = GameManager.i.tooltipActorScript.GetOpacity(); alphaCurrent += Time.deltaTime / mouseOverFade; GameManager.i.tooltipActorScript.SetOpacity(alphaCurrent); yield return(null); } } } break; case ActionMenuType.Player: //do once while (GameManager.i.tooltipPlayerScript.CheckTooltipActive() == false) { //adjust position prior to sending Vector3 positionPlayer = rectTransform.position; positionPlayer.x += 70; positionPlayer.y -= 100; GameManager.i.tooltipPlayerScript.SetTooltip(positionPlayer); yield return(null); //fade in while (GameManager.i.tooltipPlayerScript.GetOpacity() < 1.0) { alphaCurrent = GameManager.i.tooltipPlayerScript.GetOpacity(); alphaCurrent += Time.deltaTime / mouseOverFade; GameManager.i.tooltipPlayerScript.SetOpacity(alphaCurrent); yield return(null); } } break; } } }