public void Awake() { /*picture0.GetComponent<ActorSpriteTooltipUI>().actorSlotID = 0; * picture1.GetComponent<ActorSpriteTooltipUI>().actorSlotID = 1; * picture2.GetComponent<ActorSpriteTooltipUI>().actorSlotID = 2; * picture3.GetComponent<ActorSpriteTooltipUI>().actorSlotID = 3;*/ //Canvas Group references canvas0 = Actor0.GetComponent <CanvasGroup>(); canvas1 = Actor1.GetComponent <CanvasGroup>(); canvas2 = Actor2.GetComponent <CanvasGroup>(); canvas3 = Actor3.GetComponent <CanvasGroup>(); canvasPlayer = ActorPlayer.GetComponent <CanvasGroup>(); //actor arc type help actor0TypeTooltip = type0.GetComponent <GenericTooltipUI>(); actor1TypeTooltip = type1.GetComponent <GenericTooltipUI>(); actor2TypeTooltip = type2.GetComponent <GenericTooltipUI>(); actor3TypeTooltip = type3.GetComponent <GenericTooltipUI>(); Debug.Assert(actor0TypeTooltip != null, "Invalid actor0TypeTooltip (Null)"); Debug.Assert(actor1TypeTooltip != null, "Invalid actor1TypeTooltip (Null)"); Debug.Assert(actor2TypeTooltip != null, "Invalid actor2TypeTooltip (Null)"); Debug.Assert(actor3TypeTooltip != null, "Invalid actor3TypeTooltip (Null)"); //mood help playerMoodTooltip = moodStars.GetComponent <GenericTooltipUI>(); playerStressedTooltip = playerStressed.GetComponent <GenericTooltipUI>(); Debug.Assert(playerMoodTooltip != null, "Invalid playerMoodHelp (Null)"); Debug.Assert(playerStressedTooltip != null, "Invalid playerStressedHelp (Null)"); //compatibility Debug.Assert(compatibility0 != null, "Invalid compatibility0 (Null)"); Debug.Assert(compatibility1 != null, "Invalid compatibility1 (Null)"); Debug.Assert(compatibility2 != null, "Invalid compatibility2 (Null)"); Debug.Assert(compatibility3 != null, "Invalid compatibility3 (Null)"); }
private void SubInitialiseSessionStart() { hackingDetected = string.Format("Hacking Attempt{0}<b>DETECTED</b>", "\n"); tabBottomText.text = string.Format("Hacking Status{0}<b>UNKNOWN</b>", "\n"); //tabs topTabTooltip = tabTopMouse.GetComponent <GenericTooltipUI>(); bottomTabTooltip = tabBottomMouse.GetComponent <GenericTooltipUI>(); sideTabTooltip = tabSideMouse.GetComponent <GenericTooltipUI>(); topTaskTooltip = subTopPanel.GetComponent <GenericTooltipUI>(); middleTaskTooltip = subMiddlePanel.GetComponent <GenericTooltipUI>(); bottomTaskTooltip = subBottomPanel.GetComponent <GenericTooltipUI>(); Debug.Assert(topTabTooltip != null, "Invalid topTabTooltip (Null)"); Debug.Assert(bottomTabTooltip != null, "Invalid bottomTabPanelTooltip (Null)"); Debug.Assert(sideTabTooltip != null, "Invalid sideTabTooltip (Null)"); Debug.Assert(topTaskTooltip != null, "Invalid topTaskTooltip (Null)"); Debug.Assert(middleTaskTooltip != null, "Invalid middleTaskTooltip (Null)"); Debug.Assert(bottomTaskTooltip != null, "Invalid bottomTaskTooltip (Null)"); //initialise tooltips topTaskTooltip.Initialise(); middleTaskTooltip.Initialise(); bottomTabTooltip.Initialise(); //buttons cancelInteraction = cancelButton.GetComponent <ButtonInteraction>(); proceedInteraction = proceedButton.GetComponent <ButtonInteraction>(); Debug.Assert(cancelInteraction != null, "Invalid cancelInteraction (Null)"); Debug.Assert(proceedInteraction != null, "Invalid proceedInteraction (Null)"); cancelInteraction.SetButton(EventType.AIDisplayClose); proceedInteraction.SetButton(EventType.AIDisplayPanelOpen); }
/// <summary> /// private subMethod to Initialise UI components /// </summary> private void InitialiseComponents() { colourIconDormant = GameManager.i.uiScript.IconDormant; colourIconActiveGood = GameManager.i.uiScript.IconActiveGood; colourIconActiveBad = GameManager.i.uiScript.IconActiveBad; colourNumber = Color.white; //tooltips tipCommendation = commendations.tooltip.GetComponent <GenericTooltipUI>(); tipBlackmark = blackmarks.tooltip.GetComponent <GenericTooltipUI>(); tipInvestigation = investigations.tooltip.GetComponent <GenericTooltipUI>(); tipInnocence = innocence.tooltip.GetComponent <GenericTooltipUI>(); tipUnhappy = unhappy.tooltip.GetComponent <GenericTooltipUI>(); tipConflict = conflicts.tooltip.GetComponent <GenericTooltipUI>(); tipBlackmail = blackmail.tooltip.GetComponent <GenericTooltipUI>(); tipDoom = doom.tooltip.GetComponent <GenericTooltipUI>(); Debug.Assert(tipCommendation != null, "Invalid tipCommendation (Null)"); Debug.Assert(tipBlackmark != null, "Invalid tipBlackmark (Null)"); Debug.Assert(tipInvestigation != null, "Invalid tipInvestigation (Null)"); Debug.Assert(tipInnocence != null, "Invalid tipInnocence (Null)"); Debug.Assert(tipUnhappy != null, "Invalid tipUnhappy (Null)"); Debug.Assert(tipConflict != null, "Invalid tipConflict (Null)"); Debug.Assert(tipBlackmail != null, "Invalid tipBlackmail (Null)"); Debug.Assert(tipDoom != null, "Invalid tipDoom (Null)"); //Set UI element colours Color color = GameManager.i.uiScript.TopBarBackground; topBarMainPanel.color = new Color(color.r, color.g, color.b, 0.65f); topBarLeft.color = new Color(color.r, color.g, color.b, 0.65f); topBarRight.color = new Color(color.r, color.g, color.b, 0.65f); //Set icon colours -> Dormant color = colourIconDormant; commendations.textIcon.color = new Color(color.r, color.g, color.b, opacityHigh); blackmarks.textIcon.color = new Color(color.r, color.g, color.b, opacityHigh); investigations.textIcon.color = new Color(color.r, color.g, color.b, opacityHigh); innocence.textIcon.color = new Color(color.r, color.g, color.b, opacityHigh); unhappy.textIcon.color = new Color(color.r, color.g, color.b, opacityHigh); conflicts.textIcon.color = new Color(color.r, color.g, color.b, opacityHigh); blackmail.textIcon.color = new Color(color.r, color.g, color.b, opacityHigh); doom.textIcon.color = new Color(color.r, color.g, color.b, opacityHigh); //Set number colour (white) and opacity -> Status color = colourNumber; unhappy.textData.color = new Color(color.r, color.g, color.b, opacityHigh); conflicts.textData.color = new Color(color.r, color.g, color.b, opacityHigh); blackmail.textData.color = new Color(color.r, color.g, color.b, opacityHigh); doom.textData.color = new Color(color.r, color.g, color.b, opacityHigh); //icon symbols commendations.textIcon.text = GameManager.i.guiScript.commendationChar.ToString(); blackmarks.textIcon.text = GameManager.i.guiScript.blackmarkChar.ToString(); investigations.textIcon.text = GameManager.i.guiScript.investigateChar.ToString(); innocence.textIcon.text = GameManager.i.guiScript.innocenceChar.ToString(); unhappy.textIcon.text = GameManager.i.guiScript.unhappyChar.ToString(); conflicts.textIcon.text = GameManager.i.guiScript.conflictChar.ToString(); blackmail.textIcon.text = GameManager.i.guiScript.blackmailChar.ToString(); doom.textIcon.text = GameManager.i.guiScript.doomChar.ToString(); }
private void Awake() { //close button event buttonInteraction = buttonClose.GetComponent <ButtonInteraction>(); if (buttonInteraction != null) { buttonInteraction.SetButton(EventType.CityInfoClose); } else { Debug.LogError("Invalid buttonInteraction Cancel (Null)"); } //tooltips districtTooltip = subPanelLeft.GetComponent <GenericTooltipUI>(); organisationTooltip = miniPanelBottom.GetComponent <GenericTooltipUI>(); factionTooltip = miniPanelMiddle.GetComponent <GenericTooltipUI>(); mayorTooltip = miniPanelTop.GetComponent <GenericTooltipUI>(); }
/// <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"); } }
private void SubInitialiseAll() { //toggle components to ready state turnCanvas.gameObject.SetActive(false); turnObject.SetActive(true); turnImage.gameObject.SetActive(true); turnText.gameObject.SetActive(true); //help help = turnImage.GetComponent <GenericTooltipUI>(); if (help != null) { help.tooltipHeader = string.Format("<size=120%>{0}</size>", GameManager.Formatt("New Turn", ColourType.salmonText)); help.tooltipMain = string.Format("When you are ready, press {0} or <b>Click this button</b> for the next turn", GameManager.Formatt("ENTER", ColourType.neutralText)); help.x_offset = 25; help.y_offset = 50; } else { Debug.LogError("Invalid GenericTooltipUI (Null) for NewTurnUI"); } }
private void SubInitialiseSessionStart() { //tooltip tooltip = sideTabImage.GetComponent <GenericTooltipUI>(); Debug.Assert(tooltip != null, "Invalid GenericTooltipUI component tooltip (Null)"); tooltip.isIgnoreClick = true; tooltip.testTag = "AISideTabUI"; tooltip.tooltipMain = "We haven't yet broken the AI's Security systems"; tooltip.tooltipDetails = "Resistance HQ expect to do so by <b>NEXT TURN</b>"; //data topText.text = "AI"; bottomText.text = "-"; hackingStatus = HackingStatus.Initialising; myCoroutine = null; isFading = false; //set alert flasher to zero opacity tempColour = alertFlasher.color; tempColour.a = 0.0f; alertFlasher.color = tempColour; //set to Active isActive = true; //Set all components SetAllStatus(isActive); }
private void Awake() { reviewWaitTimerDefault = reviewWaitTime; //Review button event buttonInteractionReview = buttonReview.GetComponent <ButtonInteraction>(); if (buttonInteractionReview != null) { buttonInteractionReview.SetButton(EventType.ReviewStart); } else { Debug.LogError("Invalid buttonInteraction Review (Null)"); } //Exit button event buttonInteractionExit = buttonExit.GetComponent <ButtonInteraction>(); if (buttonInteractionExit != null) { buttonInteractionExit.SetButton(EventType.ReviewCloseUI); } else { Debug.LogError("Invalid buttonInteraction Exit (Null)"); } //help tooltips tooltipHelpOpen = buttonHelpOpen.GetComponent <GenericHelpTooltipUI>(); tooltipHelpClose = buttonHelpClose.GetComponent <GenericHelpTooltipUI>(); tooltipOutcomeLeft = outcomeLeft.GetComponent <GenericHelpTooltipUI>(); tooltipOutcomeRight = outcomeRight.GetComponent <GenericHelpTooltipUI>(); Debug.Assert(tooltipHelpOpen != null, "Invalid tooltipHelpOpen (Null)"); Debug.Assert(tooltipHelpClose != null, "Invalid tooltipHelpClose (Null)"); Debug.Assert(tooltipOutcomeLeft != null, "Invalid tooltipOutcomeLeft (Null)"); Debug.Assert(tooltipOutcomeRight != null, "Invalid tooltipOutcomeRight (Null)"); //inventory interaction & tooltip arrays set up int numOfOptions = arrayOfOptions.Length; arrayOfInteractions = new ReviewInteraction[numOfOptions]; arrayOfTooltipsSprites = new GenericTooltipUI[numOfOptions]; arrayOfTooltipsTitles = new GenericTooltipUI[numOfOptions]; arrayOfTooltipsResults = new GenericTooltipUI[numOfOptions]; for (int i = 0; i < numOfOptions; i++) { if (arrayOfOptions[i] != null) { //interaction ReviewInteraction interaction = arrayOfOptions[i].GetComponent <ReviewInteraction>(); if (interaction != null) { arrayOfInteractions[i] = interaction; //tooltip -> sprite (attached to game object to prevent tooltip component masking gameobject interaction component which is needed for click detection for menu's) GenericTooltipUI tooltipSprite = interaction.tooltipSprite.GetComponent <GenericTooltipUI>(); if (tooltipSprite != null) { arrayOfTooltipsSprites[i] = tooltipSprite; } else { Debug.LogErrorFormat("Invalid GenericTooltipUI for arrayOfReviewOptions[{0}] (Null)", i); } //tooltip -> title GenericTooltipUI tooltipTitle = interaction.tooltipTitle.GetComponent <GenericTooltipUI>(); if (tooltipTitle != null) { arrayOfTooltipsTitles[i] = tooltipTitle; } else { Debug.LogErrorFormat("Invalid GenericTooltipUI for arrayOTooltipsTitle[{0}] (Null)", i); } //tooltip -> result GenericTooltipUI tooltipResult = interaction.tooltipResult.GetComponent <GenericTooltipUI>(); if (tooltipResult != null) { arrayOfTooltipsResults[i] = tooltipResult; } else { Debug.LogErrorFormat("Invalid GenericTooltipUI for interaction.tooltipResult \"{0}\" (Null)", i); } } else { Debug.LogErrorFormat("Invalid InventoryInteraction for arrayOfInventoryOptions[{0}] (Null)", i); } } else { Debug.LogErrorFormat("Invalid arrayOfInventoryOptions[{0}] (Null)", i); } } }
/// <summary> /// Session start /// </summary> private void SubInitialiseSessionStart() { //inventory interaction & tooltip arrays set up int numOfOptions = arrayOfInventoryOptions.Length; Debug.AssertFormat(numOfOptions == GameManager.i.guiScript.maxInventoryOptions, "Mismatch on Option numbers (is {0}, should be {1})", numOfOptions, GameManager.i.guiScript.maxInventoryOptions); //cancel button event buttonInteraction = buttonCancel.GetComponent <ButtonInteraction>(); if (buttonInteraction != null) { buttonInteraction.SetButton(EventType.InventoryCloseUI); } else { Debug.LogError("Invalid buttonInteraction Cancel (Null)"); } //help button help = buttonHelp.GetComponent <GenericHelpTooltipUI>(); if (help == null) { Debug.LogError("Invalid help script (Null)"); } //initialise arrays arrayOfInteractions = new InventoryInteraction[numOfOptions]; arrayOfTooltipsSprites = new GenericTooltipUI[numOfOptions]; arrayOfTooltipsStars = new GenericTooltipUI[numOfOptions]; arrayOfTooltipsCompatibility = new GenericTooltipUI[numOfOptions]; arrayOfTooltipsTexts = new GenericTooltipUI[numOfOptions]; for (int i = 0; i < numOfOptions; i++) { if (arrayOfInventoryOptions[i] != null) { //interaction InventoryInteraction interaction = arrayOfInventoryOptions[i].GetComponent <InventoryInteraction>(); if (interaction != null) { arrayOfInteractions[i] = interaction; //tooltip -> sprite (attached to game object to prevent tooltip component masking gameobject interaction component which is needed for click detection for menu's) GenericTooltipUI tooltipSprite = arrayOfInventoryOptions[i].GetComponent <GenericTooltipUI>(); if (tooltipSprite != null) { arrayOfTooltipsSprites[i] = tooltipSprite; } else { Debug.LogErrorFormat("Invalid GenericTooltipUI for arrayOfInventoryOptions[{0}] (Null)", i); } //tooltip -> stars (bottomText, optional) GenericTooltipUI tooltipStars = interaction.tooltipStars.GetComponent <GenericTooltipUI>(); if (tooltipStars != null) { arrayOfTooltipsStars[i] = tooltipStars; } else { Debug.LogErrorFormat("Invalid GenericTooltipUI for interaction.tooltipStars \"{0}\" (Null)", i); } //tooltip -> compatibility (topText, optional) GenericTooltipUI tooltipCompatibility = interaction.tooltipCompatibility.GetComponent <GenericTooltipUI>(); if (tooltipCompatibility != null) { arrayOfTooltipsCompatibility[i] = tooltipCompatibility; } else { Debug.LogErrorFormat("Invalid GenericTooltipUI for interaction.tooltipCompatibility \"{0}\" (Null)", i); } //tooltip -> texts (upperText, optional) GenericTooltipUI tooltipText = interaction.tooltipText.GetComponent <GenericTooltipUI>(); if (tooltipText != null) { arrayOfTooltipsTexts[i] = tooltipText; } else { Debug.LogErrorFormat("Invalid GenericTooltipUI for interaction.tooltipText \"{0}\" (Null)", i); } } else { Debug.LogErrorFormat("Invalid InventoryInteraction for arrayOfInventoryOptions[{0}] (Null)", i); } } else { Debug.LogErrorFormat("Invalid arrayOfInventoryOptions[{0}] (Null)", i); } } //toggle main objects inventoryCanvas.gameObject.SetActive(false); modalPanelObject.SetActive(true); modalInventoryObject.SetActive(true); modalHeaderObject.SetActive(true); }
/// <summary> /// Initialise and Activate Team Picker (insert ANY TEAM) /// </summary> public void SetTeamPicker(ModalActionDetails details) { StringBuilder builder = new StringBuilder(); CanvasGroup teamCanvasGroup; TeamInteraction teamInteract; string textTooltip; GameManager.i.guiScript.SetIsBlocked(true); modalTeamObject.SetActive(true); modalPanelObject.SetActive(true); //confirm button should be switched off at the start buttonConfirm.gameObject.SetActive(false); canvasGroup.alpha = 100; //Set up texts topText.text = string.Format("{0}Select {1}{2}ANY{3}{4} Team{5}", colourDefault, colourEnd, colourEffect, colourEnd, colourDefault, colourEnd); Node node = GameManager.i.dataScript.GetNode(details.nodeID); if (node != null) { //track core data needed to resolve Insert team action teamNode = node; teamActorSlotID = details.actorDataID; Actor actor = GameManager.i.dataScript.GetCurrentActor(teamActorSlotID, GameManager.i.globalScript.sideAuthority); int numTeams = node.CheckNumOfTeams(); builder.AppendFormat("{0}{1} \"{2}\", {3} Team{4} present{5}", colourNormal, node.Arc.name, node.nodeName, numTeams, numTeams != 1 ? "s" : "", colourEnd); //teams at node if (numTeams > 0) { List <Team> listOfTeams = node.GetListOfTeams(); if (listOfTeams != null) { if (listOfTeams.Count > 0) { builder.AppendFormat("{0} ({1}{2}", colourNormal, colourEnd, colourTeam); int counter = 0; foreach (Team team in listOfTeams) { builder.Append(team.arc.name); counter++; if (counter < listOfTeams.Count) { builder.Append(", "); } } builder.AppendFormat("{0}{1}){2}", colourEnd, colourNormal, colourEnd); } } else { Debug.LogError("Invalid listOfTeams (Null)"); } } //Actor if (actor != null) { builder.AppendLine(); string colourNumbers = colourGood; if (actor.CheckNumOfTeams() == actor.GetDatapoint(ActorDatapoint.Ability2)) { colourNumbers = colourBad; } builder.AppendFormat("{0}, {1} of {2}{3}{4} has deployed {5}{6}{7} of {8}{9}{10} teams", actor.actorName, GameManager.i.metaScript.GetAuthorityTitle(), colourActor, actor.arc.name, colourEnd, colourNumbers, actor.CheckNumOfTeams(), colourEnd, colourNumbers, actor.GetDatapoint(ActorDatapoint.Ability2), colourEnd); } else { Debug.LogError(string.Format("Invalid actor (Null) from ActorSlotID {0}", teamActorSlotID)); } } else { Debug.LogError(string.Format("Invalid node (Null) for details.NodeID {0}", details.nodeID)); } middleText.text = builder.ToString(); // // - - - Teams - - - // //Get list of team Arcs int teamID, numOfTeams; string teamType = "Unknown"; List <int> listOfTeamArcIDs = GameManager.i.dataScript.GetTeamArcIDs(); //all lists are keyed off this one, index-wise List <int> listOfTeamIDs = new List <int>(); //place teamID of first available team in reserve pool of that type List <string> listOfTeamTooltipsMain = new List <string>(); //holds tooltip for team options, one for each team Arc, main text List <string> listOfTeamTooltipsHeader = new List <string>(); //tooltip header ("CORPORATE") List <string> listOfTeamTooltipsDetails = new List <string>(); //breakdown of team type details { if (listOfTeamArcIDs != null || listOfTeamArcIDs.Count > 0) { //loop team Arcs for (int arcIndex = 0; arcIndex < listOfTeamArcIDs.Count; arcIndex++) { textTooltip = "Unknown"; teamID = GameManager.i.dataScript.GetTeamInPool(TeamPool.Reserve, arcIndex); if (teamID == -1) { textTooltip = "No teams of this type are currently in the Reserve Pool"; } //if a team of that type is available (teamID > -1) check if a duplicate team already exists at node else { if (node.CheckTeamPresent(arcIndex) > -1) { //change teamID to -1 (invalid team as you can't insert a team of a type already present at the node) teamID = -1; textTooltip = "A team of this type is already present at the Node"; } } //add to list listOfTeamIDs.Add(teamID); //tooltip data if (teamID > -1) { //get team Team team = GameManager.i.dataScript.GetTeam(teamID); if (team != null) { textTooltip = string.Format("{0} {1} is available and awaiting deployment", team.arc.name, team.teamName); //default team tooltip header teamType = team.arc.name; } else { Debug.LogError(string.Format("Invalid Team (Null) for teamID {0}", teamID)); } } else { teamType = GameManager.i.dataScript.GetTeamArc(arcIndex).name; } //header tooltip text listOfTeamTooltipsHeader.Add(string.Format("{0}{1}{2}", colourSide, teamType, colourEnd)); //main tooltip text listOfTeamTooltipsMain.Add(textTooltip); //details tooltip text numOfTeams = GameManager.i.dataScript.CheckTeamInfo(arcIndex, TeamInfo.Total); StringBuilder builderDetails = new StringBuilder(); builderDetails.AppendFormat("{0}{1} {2} team{3}{4}", colourEffect, numOfTeams, teamType, numOfTeams != 1 ? "s" : "", colourEnd); builderDetails.AppendLine(); numOfTeams = GameManager.i.dataScript.CheckTeamInfo(arcIndex, TeamInfo.Reserve); builderDetails.AppendFormat("{0}{1} in Reserve{2}", colourEffect, numOfTeams, colourEnd); builderDetails.AppendLine(); numOfTeams = GameManager.i.dataScript.CheckTeamInfo(arcIndex, TeamInfo.OnMap); builderDetails.AppendFormat("{0}{1} Deployed{2}", colourEffect, numOfTeams, colourEnd); builderDetails.AppendLine(); numOfTeams = GameManager.i.dataScript.CheckTeamInfo(arcIndex, TeamInfo.InTransit); builderDetails.AppendFormat("{0}{1} in Transit{2}", colourEffect, numOfTeams, colourEnd); listOfTeamTooltipsDetails.Add(builderDetails.ToString()); } } else { Debug.LogError("Invalid listOfTeamArcIDs (Null or Empty)"); } } //loop list of Teams and deactivate those that aren't valid picks int limit = arrayOfTeamOptions.Length; for (int teamIndex = 0; teamIndex < listOfTeamIDs.Count; teamIndex++) { //get option canvas teamCanvasGroup = arrayOfTeamOptions[teamIndex].GetComponent <CanvasGroup>(); //get TeamInteraction component teamInteract = arrayOfTeamOptions[teamIndex].GetComponent <TeamInteraction>(); if (teamIndex < limit) { if (listOfTeamIDs[teamIndex] == -1) { if (teamCanvasGroup != null) { //deactivate option teamCanvasGroup.alpha = 0.25f; teamCanvasGroup.interactable = false; } else { Debug.LogError(string.Format("Invalid teamCanvasGroup (Null) for listOfTeamIDs[\"{0}\"]", teamIndex)); } if (teamInteract != null) { //deactivate team selection teamInteract.isActive = false; teamInteract.teamID = -1; } else { Debug.LogError(string.Format("Invalid teamInteract (Null) for listOfTeamIDs[\"{0}\"]", teamIndex)); } } else { if (teamCanvasGroup != null) { //activate option teamCanvasGroup.alpha = 1.0f; teamCanvasGroup.interactable = true; } else { Debug.LogError(string.Format("Invalid teamCanvasGroup (Null) for listOfTeamIDs[\"{0}\"]", teamIndex)); } if (teamInteract != null) { //Activate team selection teamInteract.isActive = true; teamInteract.teamID = listOfTeamIDs[teamIndex]; } else { Debug.LogError(string.Format("Invalid teamInteract (Null) for listOfTeamIDs[\"{0}\"]", teamIndex)); } } //add tooltip GenericTooltipUI optionTooltip = arrayOfTeamOptions[teamIndex].GetComponent <GenericTooltipUI>(); optionTooltip.tooltipHeader = listOfTeamTooltipsHeader[teamIndex]; optionTooltip.tooltipMain = listOfTeamTooltipsMain[teamIndex]; optionTooltip.tooltipDetails = listOfTeamTooltipsDetails[teamIndex]; optionTooltip.x_offset = 50; } else { Debug.LogWarning(string.Format("teamIndex \"{0}\" has exceeded limit \"{1}\"", teamIndex, limit)); } } //set states ModalStateData package = new ModalStateData() { mainState = ModalSubState.TeamPicker }; GameManager.i.inputScript.SetModalState(package); Debug.LogFormat("[UI] ModalTeamPicker.cs -> SetTeamPicker{0}", "\n"); }
/// <summary> /// Sets up Generic picker window /// </summary> private void SetGenericPicker(GenericPickerDetails details) { //close Node tooltip safety check GameManager.i.tooltipNodeScript.CloseTooltip("ModalGenericPicker.cs -> SetGenericPicker"); //open Generic picker bool errorFlag = false; CanvasGroup genericCanvasGroup; //set modal status GameManager.i.guiScript.SetIsBlocked(true); //activate main panel modalPanelObject.SetActive(true); //header activated only if text provided if (string.IsNullOrEmpty(details.textHeader) == false) { modalHeader.gameObject.SetActive(true); headerText.text = details.textHeader; } else { modalHeader.gameObject.SetActive(false); } //activate dialogue window modalPickerCanvas.gameObject.SetActive(true); modalGenericObject.SetActive(true); //confirm button should be switched off at the start buttonConfirm.gameObject.SetActive(false); //back button only switched on if it has a valid underlying eventType if (backReturnEvent == EventType.None) { buttonBack.gameObject.SetActive(false); } else { buttonBack.gameObject.SetActive(true); } //halt execution, until picker is processed, if indicated if (details.isHaltExecution == true) { GameManager.i.turnScript.haltExecution = true; } //canvasGroup.alpha = 100; //populate dialogue if (details != null) { if (details.arrayOfOptions.Length > 0) { //initialise data nodeIDSelected = details.nodeID; actorSlotIDSelected = details.actorSlotID; datapoint = details.data; optionIDSelected = -1; optionNameSelected = ""; //set help List <HelpData> listOfHelpData = GameManager.i.helpScript.GetHelpData(details.help0, details.help1, details.help2, details.help3); if (listOfHelpData != null && listOfHelpData.Count > 0) { buttonHelp.gameObject.SetActive(true); help.SetHelpTooltip(listOfHelpData, 150, 200); } else { buttonHelp.gameObject.SetActive(false); } //assign sprites, texts, optionID's and tooltips for (int i = 0; i < details.arrayOfOptions.Length; i++) { if (arrayOfGenericOptions[i] != null) { GenericInteraction interaction = arrayOfInteractions[i]; if (interaction != null) { //there are 'maxOptions' options but not all of them may be used if (details.arrayOfOptions[i] != null) { //get option canvas genericCanvasGroup = arrayOfGenericOptions[i].GetComponent <CanvasGroup>(); if (genericCanvasGroup != null) { //activate option arrayOfGenericOptions[i].SetActive(true); //populate data interaction.optionImage.sprite = details.arrayOfOptions[i].sprite; interaction.displayText.text = details.arrayOfOptions[i].text; interaction.imageInteraction.data.optionID = details.arrayOfOptions[i].optionID; interaction.imageInteraction.data.optionName = details.arrayOfOptions[i].optionName; interaction.imageInteraction.data.optionNested = details.arrayOfOptions[i].optionText; interaction.imageInteraction.data.actorSlotID = details.actorSlotID; //option Active or Not? if (details.arrayOfOptions[i].isOptionActive == true) { //activate option genericCanvasGroup.alpha = 1.0f; genericCanvasGroup.interactable = true; interaction.imageInteraction.isActive = true; } else { //deactivate option genericCanvasGroup.alpha = 0.25f; genericCanvasGroup.interactable = false; interaction.imageInteraction.isActive = false; } //tooltip -> Image GenericTooltipUI tooltipImage = arrayOfImageTooltips[i]; if (details.arrayOfImageTooltips[i] != null) { tooltipImage.tooltipHeader = details.arrayOfImageTooltips[i].textHeader; tooltipImage.tooltipMain = details.arrayOfImageTooltips[i].textMain; tooltipImage.tooltipDetails = details.arrayOfImageTooltips[i].textDetails; } else { //default values tooltipImage.tooltipHeader = ""; tooltipImage.tooltipMain = ""; tooltipImage.tooltipDetails = ""; } //tooltip -> Text GenericTooltipUI tooltipText = arrayOfTextTooltips[i]; if (details.arrayOfTextTooltips[i] != null) { tooltipText.tooltipHeader = details.arrayOfTextTooltips[i].textHeader; tooltipText.tooltipMain = details.arrayOfTextTooltips[i].textMain; tooltipText.tooltipDetails = details.arrayOfTextTooltips[i].textDetails; } else { //default values tooltipText.tooltipHeader = ""; tooltipText.tooltipMain = ""; tooltipText.tooltipDetails = ""; } } else { Debug.LogError(string.Format("Invalid genericCanvasGroup for arrayOfGenericOptions[{0}]", i)); } } else { arrayOfGenericOptions[i].SetActive(false); } } else { //error -> Null Interaction data Debug.LogError(string.Format("Invalid arrayOfGenericOptions[\"{0}\"] genericData (Null)", i)); errorFlag = true; break; } } else { //error -> Null array Debug.LogError(string.Format("Invalid arrayOfGenericOptions[\"{0}\"] (Null)", i)); errorFlag = true; break; } } //register return event for reference once user confirms a choice defaultReturnEvent = details.returnEvent; } } else { //error -> null parameter Debug.LogError("Invalid GenericPickerDetails (Null)"); errorFlag = true; } //if a problem then generate an outcome window instead if (errorFlag == true) { modalPickerCanvas.gameObject.SetActive(false); /*modalGenericObject.SetActive(false);*/ //create an outcome window to notify player ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails(); outcomeDetails.textTop = "There has been a SNAFU"; outcomeDetails.textBottom = "Heads, toes and other limbswill be removed"; outcomeDetails.side = details.side; EventManager.i.PostNotification(EventType.OutcomeOpen, this, outcomeDetails, "ModalGenericPicker.cs -> SetGenericPicker"); } //all good, generate else { //texts topText.text = details.textTop; middleText.text = details.textMiddle; bottomText.text = details.textBottom; //set game state ModalStateData package = new ModalStateData(); package.mainState = ModalSubState.GenericPicker; package.pickerState = details.subState; GameManager.i.inputScript.SetModalState(package); Debug.LogFormat("[UI] ModalGenericPicker.cs -> SetGenericPicker{0}", "\n"); } }
private void SubInitialiseSessionStart() { maxOptions = GameManager.i.guiScript.maxPickerOptions; Debug.Assert(maxOptions == 3, "Invalid maxOptions (must be 3)"); //arrays arrayOfInteractions = new GenericInteraction[maxOptions]; arrayOfImageTooltips = new GenericTooltipUI[maxOptions]; arrayOfTextTooltips = new GenericTooltipUI[maxOptions]; //confirm button event buttonConfirmInteraction = buttonConfirm.GetComponent <ButtonInteraction>(); if (buttonConfirmInteraction != null) { buttonConfirmInteraction.SetButton(EventType.ConfirmGenericChoice); } else { Debug.LogError("Invalid buttonInteraction Confirm (Null)"); } //cancel button event buttonCancelInteraction = buttonCancel.GetComponent <ButtonInteraction>(); if (buttonCancelInteraction != null) { buttonCancelInteraction.SetButton(EventType.CancelButtonGeneric); } else { Debug.LogError("Invalid buttonInteraction Confirm (Null)"); } //help button help = buttonHelp.GetComponent <GenericHelpTooltipUI>(); if (help == null) { Debug.LogError("Invalid help script (Null)"); } //Back button event (default -> can be set dynamically using 'SetBackButton' method buttonBackInteraction = buttonBack.GetComponent <ButtonInteraction>(); if (buttonBackInteraction != null) { buttonBackInteraction.SetButton(EventType.BackButtonGeneric); } else { Debug.LogError("Invalid buttonBackInteraction (Null)"); } backReturnEvent = EventType.None; //tooltips for (int i = 0; i < maxOptions; i++) { //interaction GenericInteraction interaction = arrayOfGenericOptions[i].GetComponent <GenericInteraction>(); if (interaction != null) { arrayOfInteractions[i] = interaction; //tooltip image GenericTooltipUI tooltipImage = interaction.imageTooltip; if (tooltipImage != null) { arrayOfImageTooltips[i] = tooltipImage; } else { Debug.LogErrorFormat("Invalid tooltipImage (Null) for arrayOfInteractions[{0}]", i); } //tooltip text GenericTooltipUI tooltipText = interaction.textTooltip; if (tooltipText != null) { arrayOfTextTooltips[i] = tooltipText; } else { Debug.LogErrorFormat("Invalid tooltipText (Null) for arrayOfInteractions[{0}]", i); } } else { Debug.LogErrorFormat("Invalid interaction (Null) for arrayOfGenericOptions[{0}]", i); } } }
/// <summary> /// Initialise and activate modal Action Menu /// </summary> /// <param name="details"></param> public void SetActionMenu(ModalGenericMenuDetails details) { //set states (done up front to prevent node tooltip reoccuring during menu display) ModalStateData package = new ModalStateData() { mainState = ModalSubState.ActionMenu }; GameManager.i.inputScript.SetModalState(package); //close all tooltips GameManager.i.guiScript.SetTooltipsOff(); //check enough actions if (GameManager.i.turnScript.CheckRemainingActions() == true) { //modalActionObject.SetActive(true); menuCanvas.gameObject.SetActive(true); //set all states to off button1.gameObject.SetActive(false); button2.gameObject.SetActive(false); button3.gameObject.SetActive(false); button4.gameObject.SetActive(false); button5.gameObject.SetActive(false); button6.gameObject.SetActive(false); //set up ModalActionObject itemDetails.text = string.Format("{0}{1}{2}", details.itemName, "\n", details.itemDetails); //tooltip at top of menu -> pass through data ModalMenuUI modal = itemDetails.GetComponent <ModalMenuUI>(); modal.menuType = details.menuType; switch (details.menuType) { case ActionMenuType.Node: case ActionMenuType.NodeGear: modal.nodeID = details.itemID; break; case ActionMenuType.Actor: modal.actorSlotID = details.itemID; break; case ActionMenuType.Player: break; case ActionMenuType.Gear: modal.gearName = details.itemKey; break; } //There can be a max of 6 buttons (5 plus 1 x Cancel) int counter = 0; Button tempButton; Text title; foreach (EventButtonDetails buttonDetails in details.listOfButtonDetails) { tempButton = null; title = null; counter++; //get the relevent UI elements switch (counter) { case 1: tempButton = button1; title = button1Text; break; case 2: tempButton = button2; title = button2Text; break; case 3: tempButton = button3; title = button3Text; break; case 4: tempButton = button4; title = button4Text; break; case 5: tempButton = button5; title = button5Text; break; case 6: tempButton = button6; title = button6Text; break; default: Debug.LogWarning("To many EventButtonDetails in list!\n"); break; } //set up the UI elements if (tempButton != null && title != null) { tempButton.onClick.RemoveAllListeners(); tempButton.onClick.AddListener(CloseActionMenu); tempButton.onClick.AddListener(buttonDetails.action); title.text = buttonDetails.buttonTitle; tempButton.gameObject.SetActive(true); GenericTooltipUI generic = tempButton.GetComponent <GenericTooltipUI>(); generic.tooltipHeader = buttonDetails.buttonTooltipHeader; generic.tooltipMain = buttonDetails.buttonTooltipMain; generic.tooltipDetails = buttonDetails.buttonTooltipDetail; generic.x_offset = 40; } } //convert coordinates Vector3 screenPos = Camera.main.WorldToScreenPoint(details.menuPos); //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 = modalMenuObject.GetComponent <RectTransform>(); //get dimensions of dynamic menu float width = rectTransform.rect.width; float height = rectTransform.rect.height; //calculate offset - height (default above) if (screenPos.y + height + offset < Screen.height) { screenPos.y += height + offset; } else { screenPos.y -= offset; } //width - default right if (screenPos.x + offset >= Screen.width) { screenPos.x -= offset + screenPos.x - Screen.width; } //go left if needed else if (screenPos.x - offset - width <= 0) { screenPos.x += offset - width; } else { screenPos.x += offset; } //set new position modalMenuObject.transform.position = screenPos; //block raycasts to gameobjects GameManager.i.guiScript.SetIsBlocked(true, details.modalLevel); modalLevel = details.modalLevel; modalState = details.modalState; Debug.LogFormat("[UI] ModalActionMenu.cs -> SetActionMenu{0}", "\n"); } else { //insufficient actions remaining -> create an outcome window to notify player ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails(); outcomeDetails.side = GameManager.i.sideScript.PlayerSide; outcomeDetails.textTop = "You have used up all your Actions for this turn"; //extra text if player is wounded if (GameManager.i.turnScript.CheckPlayerWounded() == true) { outcomeDetails.textBottom = "Maximum ONE Action allowed while WOUNDED"; } outcomeDetails.sprite = GameManager.i.spriteScript.infoSprite; outcomeDetails.modalLevel = details.modalLevel; outcomeDetails.modalState = details.modalState; EventManager.i.PostNotification(EventType.OutcomeOpen, this, outcomeDetails, "ModalActionMenu.cs -> SetActionMenu"); } }
/// <summary> /// Activate modal Main Menu. Called by InitialiseMainMenu. /// </summary> /// <param name="details"></param> private void SetMainMenu(ModalGenericMenuDetails details) { //game state -> save current state first gameState = GameManager.i.inputScript.GameState; GameManager.i.inputScript.GameState = GameState.MainMenu; //turn off node tooltip if needs be GameManager.i.guiScript.SetTooltipsOff(); //activate main menu mainMenuCanvas.gameObject.SetActive(true); //set all states to off button1.gameObject.SetActive(false); button2.gameObject.SetActive(false); button3.gameObject.SetActive(false); button4.gameObject.SetActive(false); button5.gameObject.SetActive(false); button6.gameObject.SetActive(false); button7.gameObject.SetActive(false); button8.gameObject.SetActive(false); button9.gameObject.SetActive(false); button10.gameObject.SetActive(false); button11.gameObject.SetActive(false); //set up ModalActionObject itemDetails.text = string.Format("{0}{1}{2}", details.itemName, "\n", details.itemDetails); /*//tooltip at top of menu -> pass through data * ModalMenuUI modal = itemDetails.GetComponent<ModalMenuUI>();*/ //There can be a max of 9 buttons int counter = 0; Button tempButton; TextMeshProUGUI title; foreach (EventButtonDetails buttonDetails in details.listOfButtonDetails) { tempButton = null; title = null; counter++; //get the relevent UI elements switch (counter) { case 1: tempButton = button1; title = button1Text; break; case 2: tempButton = button2; title = button2Text; break; case 3: tempButton = button3; title = button3Text; break; case 4: tempButton = button4; title = button4Text; break; case 5: tempButton = button5; title = button5Text; break; case 6: tempButton = button6; title = button6Text; break; case 7: tempButton = button7; title = button7Text; break; case 8: tempButton = button8; title = button8Text; break; case 9: tempButton = button9; title = button9Text; break; case 10: tempButton = button10; title = button10Text; break; case 11: tempButton = button11; title = button11Text; break; default: Debug.LogWarning("To many EventButtonDetails in list!\n"); break; } //set up the UI elements if (tempButton != null && title != null) { tempButton.onClick.RemoveAllListeners(); tempButton.onClick.AddListener(CloseMainMenu); tempButton.onClick.AddListener(buttonDetails.action); title.text = buttonDetails.buttonTitle; tempButton.gameObject.SetActive(true); GenericTooltipUI generic = tempButton.GetComponent <GenericTooltipUI>(); generic.tooltipHeader = buttonDetails.buttonTooltipHeader; generic.tooltipMain = buttonDetails.buttonTooltipMain; generic.tooltipDetails = buttonDetails.buttonTooltipDetail; generic.x_offset = 40; } } //No need to convert coordinates (already screen coords) Vector3 screenPos = details.menuPos; //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 = modalMenuObject.GetComponent <RectTransform>(); //get dimensions of dynamic menu float width = rectTransform.rect.width; float height = rectTransform.rect.height; //place menu in centre of given position screenPos.x -= width / 2; screenPos.y += height / 2; /*//calculate offset - height (default above) -> No Auto adjust for hitting screen boundaries (it's wonky) * if (screenPos.y + height + offset < Screen.height) * { screenPos.y += height + offset; } * else { screenPos.y -= offset; } * //width - default right * if (screenPos.x + offset >= Screen.width) * { screenPos.x -= offset + screenPos.x - Screen.width; } * //go left if needed * else if (screenPos.x - offset - width <= 0) * { screenPos.x += offset - width; } * else * { screenPos.x += offset; }*/ //set new position modalMenuObject.transform.position = screenPos; //set states ModalStateData package = new ModalStateData() { mainState = ModalSubState.MainMenu }; GameManager.i.inputScript.SetModalState(package); //block raycasts to gameobjects GameManager.i.guiScript.SetIsBlocked(true, details.modalLevel); modalLevel = details.modalLevel; modalState = details.modalState; Debug.LogFormat("[UI] ModalMainMenu.cs -> SetMainMenu{0}", "\n"); }