/// <summary> /// Actor tooltip /// </summary> /// <returns></returns> IEnumerator ShowActiveActorTooltip() { //delay before tooltip kicks in yield return(new WaitForSeconds(mouseOverDelay)); //activate tool tip if mouse still over actor text if (onMouseFlag == true) { //do once while (GameManager.i.tooltipActorScript.CheckTooltipActive() == false) { GlobalSide side = GameManager.i.sideScript.PlayerSide; Actor actor = GameManager.i.dataScript.GetCurrentActor(actorSlotID, side); if (actor != null) { ActorTooltipData data = actor.GetTooltipData(parent.transform.position); GameManager.i.tooltipActorScript.SetTooltip(data, actorSlotID); } else { Debug.LogWarningFormat("Invalid actor (Null) for actorSlotID {0}", actorSlotID); } yield return(null); } //fade in float alphaCurrent; while (GameManager.i.tooltipActorScript.GetOpacity() < 1.0) { alphaCurrent = GameManager.i.tooltipActorScript.GetOpacity(); alphaCurrent += Time.deltaTime / mouseOverFade; GameManager.i.tooltipActorScript.SetOpacity(alphaCurrent); yield return(null); } } }
/// <summary> /// Initialise actor Tool tip /// </summary> /// <param name="name">Name of Node, eg. 'Downtown Manhattan'</param> /// <param name="arrayOfStats">Give stats as Ints[3] in order Stability - Support - Security</param> /// <param name="trait">place target info here, a blank list if none</param> /// <param name="pos">Position of tooltip originator -> note as it's a UI element transform will be in screen units, not world units</param> public void SetTooltip(ActorTooltipData data, int actorSlotID) { bool isResistance = true; if (GameManager.i.sideScript.PlayerSide.level == 1) { isResistance = false; } //open panel at start tooltipActorCanvas.gameObject.SetActive(true); tooltipActorObject.SetActive(true); //set opacity to zero (invisible) SetOpacity(0f); //set state of all items in tooltip window actorName.gameObject.SetActive(true); actorStatus.gameObject.SetActive(false); actorConditions.gameObject.SetActive(false); actorStats.gameObject.SetActive(true); actorQualities.gameObject.SetActive(true); actorTrait.gameObject.SetActive(true); actorAction.gameObject.SetActive(true); actorSecrets.gameObject.SetActive(true); dividerTop.gameObject.SetActive(true); dividerMiddleUpper.gameObject.SetActive(false); dividerMiddleLower.gameObject.SetActive(false); dividerBottom.gameObject.SetActive(true); if (isResistance == true) { dividerGear.gameObject.SetActive(true); } else { dividerGear.gameObject.SetActive(false); } dividerSecrets.gameObject.SetActive(true); if (data.actor != null) { //Header actorName.text = string.Format("{0}<b><size=120%>{1}</size>{2}{3}{4}{5}</b>{6}", colourArc, data.actor.arc.name, colourEnd, "\n", colourName, data.actor.actorName, colourEnd); //Status (ignore for the default 'Active' Condition) if (data.actor.Status != ActorStatus.Active) { //activate UI components actorStatus.gameObject.SetActive(true); dividerMiddleUpper.gameObject.SetActive(true); switch (data.actor.Status) { case ActorStatus.Inactive: switch (data.actor.inactiveStatus) { case ActorInactive.LieLow: int numOfTurns = GameManager.i.actorScript.maxStatValue - data.actor.GetDatapoint(ActorDatapoint.Invisibility2); if (data.actor.isLieLowFirstturn == true) { numOfTurns++; } actorStatus.text = string.Format("{0}<b>LYING LOW</b>{1}{2}Back in {3} turn{4}", colourNeutral, colourEnd, "\n", numOfTurns, numOfTurns != 1 ? "s" : ""); break; case ActorInactive.Breakdown: actorStatus.text = string.Format("{0}<b>BREAKDOWN (Stress)</b>{1}{2}Back next turn", colourNeutral, colourEnd, "\n"); break; } break; case ActorStatus.Captured: actorStatus.text = string.Format("{0}<b>CAPTURED</b>{1}{2}Whereabouts unknown", colourBad, colourEnd, "\n"); break; default: actorStatus.text = string.Format("{0}<b>{1}</b>{2}", colourNeutral, data.actor.Status.ToString().ToUpper(), colourEnd); break; } } //Conditions if (data.actor.CheckNumOfConditions() > 0) { List <Condition> listOfConditions = data.actor.GetListOfConditions(); if (listOfConditions != null) { dividerMiddleLower.gameObject.SetActive(true); actorConditions.gameObject.SetActive(true); StringBuilder builderCondition = new StringBuilder(); foreach (Condition condition in listOfConditions) { if (builderCondition.Length > 0) { builderCondition.AppendLine(); } switch (condition.type.name) { case "Good": builderCondition.AppendFormat("{0}{1}{2}", colourGood, condition.tag, colourEnd); break; case "Bad": builderCondition.AppendFormat("{0}{1}{2}", colourBad, condition.tag, colourEnd); break; case "Neutral": builderCondition.AppendFormat("{0}{1}{2}", colourNeutral, condition.tag, colourEnd); break; default: Debug.LogError(string.Format("Invalid condition.type.name \"{0}\"", condition.type.name)); break; } /*//Blackmail condition has a timer * switch(condition.tag) * { * case "BLACKMAILER": * builderCondition.AppendFormat("{0} {1}{2}", colourBad, data.actor.blackmailTimer, colourEnd); * break; * }*/ } actorConditions.text = builderCondition.ToString(); } else { Debug.LogWarning("Invalid listOfConditions (Null)"); } } //trait if (data.trait != null) { //Trait actorTrait.text = string.Format("<size=120%>{0}</size>", data.trait.tagFormatted); //trait description (replaces Action) actorAction.text = data.trait.description; } else { Debug.LogWarningFormat("Invalid trait (Null) for \"{0}\", {1}, ID {2}", data.actor.actorName, data.actor.arc.name, data.actor.actorID); } } else { Debug.LogWarning("Invalid Actor (Null)"); } /*//action * if (data.action != null) * { actorAction.text = string.Format("{0}<b>{1}</b>{2}", colourAction, data.action.tag, colourEnd); } * else { Debug.LogWarning(string.Format("Actor \"{0}\" has an invalid Action (Null)", data.actor.actorName)); }*/ /*//qualities -> EDIT no longer used as replaced by a single text field for both qualities and stars combined (below) * int numOfQualities = GameManager.instance.actorScript.numOfQualities; * if (data.arrayOfQualities.Length > 0) * { * StringBuilder builder = new StringBuilder(); * for (int i = 0; i < numOfQualities; i++) * { * if (i > 0) { builder.AppendLine(); } * builder.AppendFormat("{0}{1}{2}", colourQuality, data.arrayOfQualities[i], colourEnd); * } * actorQualities.text = builder.ToString(); * }*/ //Stats -> only takes the first three Qualities, eg. "Connections, Motivation, Invisibility" int dataStats; int numOfQualities = GameManager.i.actorScript.numOfQualities; if (data.arrayOfStats.Length > 0 || data.arrayOfStats.Length < numOfQualities) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < numOfQualities; i++) { dataStats = data.arrayOfStats[i]; if (i > 0) { builder.AppendLine(); } builder.AppendFormat("{0} {1}<pos=57%>{2}", arrayOfIcons[i], data.arrayOfQualities[i], GameManager.i.guiScript.GetNormalStars(dataStats)); } actorStats.text = builder.ToString(); } //Gear if (isResistance == true) { if (data.gear != null) { //if gear held for <= grace period then show as Grey (can't be requested), otherwise yellow if (data.actor.GetGearTimer() <= gracePeriod) { actorGear.text = string.Format("{0}Gear{1}{2}{3}{4}{5}", colourAlert, colourEnd, "\n", colourGrey, data.gear.tag, colourEnd); } else { actorGear.text = string.Format("<b>{0}Gear{1}{2}{3}{4}{5}</b>", colourAlert, colourEnd, "\n", colourNeutral, data.gear.tag, colourEnd); } } else { actorGear.text = string.Format("{0}<size=95%>No Gear</size>{1}", colourGrey, colourEnd); } } //Secrets if (data.listOfSecrets != null && data.listOfSecrets.Count > 0) { StringBuilder builder = new StringBuilder(); builder.AppendFormat("{0}Secrets{1}", colourAlert, colourEnd); foreach (string secret in data.listOfSecrets) { builder.AppendFormat("{0}<b>{1}{2}{3}</b>", "\n", colourNeutral, secret, colourEnd); } actorSecrets.text = builder.ToString(); } else { actorSecrets.text = string.Format("{0}<size=95%>No Secrets</size>{1}", colourGrey, colourEnd); } //Coordinates -> You need to send World (object.transform) coordinates Vector3 worldPos = data.tooltipPos; //update required to get dimensions as tooltip is dynamic Canvas.ForceUpdateCanvases(); rectTransform = tooltipActorObject.GetComponent <RectTransform>(); float height = rectTransform.rect.height; float width = rectTransform.rect.width; //base y pos at zero (bottom of screen). Adjust up from there. worldPos.y += height + offset + 100; //position of tooltip varies according to slotID as don't want to mask the city map switch (data.actor.slotID) { case 0: case 1: worldPos.x -= 250.0f; break; case 2: case 3: worldPos.x += 50.0f; break; default: Debug.LogWarningFormat("Unrecognised data.actor.slotID \"{0}\"", data.actor.slotID); worldPos.x -= width / 10; break; } /*worldPos.y += height + offset + 100; * worldPos.x -= width / 10;*/ //width if (worldPos.x + width / 2 >= Screen.width) { worldPos.x -= width / 2 + worldPos.x - Screen.width; } else if (worldPos.x - width / 2 <= 0) { worldPos.x += width / 2 - worldPos.x; } //set new position tooltipActorObject.transform.position = worldPos; Debug.LogFormat("[UI] TooltipActor.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; } } }