/*/// <summary> * /// returns inputted string formatted in the specified colour, ready for display. Returns original, unformatted text if a problem * /// </summary> * /// <param name="text"></param> * /// <param name="colorType"></param> * /// <returns></returns> * public string GetFormattedString(string text, ColourType colourType) * { * string formattedText = text; * if (string.IsNullOrEmpty(text) == false) * { formattedText = string.Format("{0}{1}{2}", GetColour(colourType), text, GetEndTag()); } * else { Debug.LogError("Invalid text (Null)"); } * return formattedText; * }*/ /// <summary> /// Debug display of an outcome message with all colours LoadManager.cs -> arrayOfColours (Colour.SO) named and appropriately coloure for purposes of colour comparison /// </summary> public void DebugDisplayColourPalette() { //create an outcome window to notify player ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails(); outcomeDetails.side = GameManager.i.sideScript.PlayerSide; outcomeDetails.textTop = "Colour Palette"; StringBuilder builder = new StringBuilder(); Colour[] arrayOfColour = GameManager.i.loadScript.arrayOfColours; if (arrayOfColour != null) { foreach (Colour colour in arrayOfColour) { if (colour != null) { builder.AppendFormat("<color={0}>{1}</color>{2}", colour.hexCode, colour.name, "\n"); } else { Debug.LogWarning("Invalid colour (Null) in arrayOfColours"); } } } else { Debug.LogError("Invalid arrayOfColour (Null)"); } outcomeDetails.textBottom = builder.ToString(); EventManager.i.PostNotification(EventType.OutcomeOpen, this, outcomeDetails, "TargetManager.cs -> InitialiseGenericPickerTargetInfo"); }
/// <summary> /// display autoRun history message in outcome window /// </summary> public void ShowAutoRunMessage() { //only if nobody has yet won if (GameManager.i.turnScript.winStateLevel == WinStateLevel.None) { List <string> listOfEvents = GameManager.i.dataScript.GetListOfHistoryAutoRun(); if (listOfEvents != null) { StringBuilder builder = new StringBuilder(); if (listOfEvents.Count > 0) { for (int i = 0; i < listOfEvents.Count; i++) { builder.AppendLine(listOfEvents[i]); } } else { builder.AppendLine("No Events"); } //create an outcome window to notify player ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails(); outcomeDetails.side = _playerSide; outcomeDetails.textTop = "AutoRun complete"; outcomeDetails.textBottom = builder.ToString(); EventManager.i.PostNotification(EventType.OutcomeOpen, this, outcomeDetails, "SideManager.cs -> RevertToHumanPlayer"); } else { Debug.LogError("Invalid listOfHistoryAutoRun (Null)"); } } }
/// <summary> /// handles all admin for Npc departing map (reached destination and no repeat or repeat but timer has run out). isInteract true if player has interacted with Npc prior to departure /// </summary> private void ProcessNpcDepart(Npc npc, bool isInteract = false) { //outcome message for InfoPipeline if Player hasn't interacted with Npc if (isInteract == false) { //bad effects string effectText = ProcessEffects(npc, false); string textTopString = string.Format("The {0}{1}{2} catches a shuttle out of {3}. You failed to {4}{5}{6}", colourNeutral, npc.tag, colourEnd, GameManager.i.cityScript.GetCityName(), colourBad, npc.action.activity, colourEnd); string textBottomString = effectText; //pipeline msg ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails { textTop = textTopString, textBottom = textBottomString, sprite = npc.sprite, isAction = false, side = GameManager.i.globalScript.sideResistance, type = MsgPipelineType.Npc }; if (GameManager.i.guiScript.InfoPipelineAdd(outcomeDetails) == false) { Debug.LogWarningFormat("Npc departs with Player InfoPipeline message FAILED to be added to dictOfPipeline"); } } npc.status = NpcStatus.Departed; npc.currentNode = null; GameManager.i.nodeScript.nodeNpc = -1; Debug.LogFormat("[Npc] MissionManager.cs -> ProcessNpcDepart: Npc \"{0}\" Departed{1}", npc.tag, "\n"); //infoOrg reset if (GameManager.i.campaignScript.campaign.orgInfo != null) { GameManager.i.orgScript.CancelOrgInfoTracking(OrgInfoType.Npc); } }
/// <summary> /// checks for Npc activating and being placed onMap /// </summary> private void CheckNpcActive(Npc npc) { //check start turn if (GameManager.i.turnScript.Turn >= npc.startTurn) { int rnd = Random.Range(0, 100); if (rnd < npc.startChance) { //Start if (npc.currentStartNode != null) { npc.status = NpcStatus.Active; npc.currentNode = npc.currentStartNode; npc.timerTurns = npc.maxTurns; npc.daysActive = 1; GameManager.i.nodeScript.nodeNpc = npc.currentStartNode.nodeID; Debug.LogFormat("[Npc] MissionManager.cs -> CheckNpcActive: Npc \"{0}\" OnMap (rnd {1}, needed < {2}) at {3}, {4}, ID {5}, timer {6}{7}", npc.tag, rnd, npc.startChance, npc.currentNode.nodeName, npc.currentNode.Arc.name, npc.currentNode.nodeID, npc.timerTurns, "\n"); string text = string.Format("{0} has arrived in City at {1}, {2}, ID {3}", npc.tag, npc.currentStartNode.nodeName, npc.currentStartNode.Arc.name, npc.currentStartNode.nodeID); GameManager.i.messageScript.NpcArrival(text, npc); //tracker AddTrackerRecord(npc); //outcome msg (infoPipeline) string goodEffects = GetEffects(npc.listOfGoodEffects, colourGood); string badEffects = GetEffects(npc.listOfBadEffects, colourBad); string textTopString = string.Format("A {0}{1}{2} has arrived in the city. They have {3}{4}{5}", colourAlert, npc.tag, colourEnd, colourAlert, npc.item, colourEnd); string textBottomString = string.Format("We want you to {0}{1}{2}{3}{4}If successful{5}{6}{7}{8}If you fail{9}{10}", colourNeutral, npc.action.activity, colourEnd, "\n", "\n", "\n", goodEffects, "\n", "\n", "\n", badEffects); ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails { textTop = textTopString, textBottom = textBottomString, sprite = npc.sprite, isAction = false, side = GameManager.i.globalScript.sideResistance, type = MsgPipelineType.Npc, help0 = "npc_0", help1 = "npc_1" }; if (GameManager.i.guiScript.InfoPipelineAdd(outcomeDetails) == false) { Debug.LogWarningFormat("Npc arrives InfoPipeline message FAILED to be added to dictOfPipeline"); } //msg GameManager.i.messageScript.NpcOngoing("Npc arrives onMap", npc); //tracer CheckIfTracerSpotsNpc(npc); } else { Debug.LogWarning("Invalid Npc currentStartNode (Null)"); } } else { Debug.LogFormat("[Npc] MissionManager.cs -> CheckNpcActive: Npc \"{0}\" failed Activation roll (rnd {1}, needed < {2}){3}", npc.tag, rnd, npc.startChance, "\n"); } } }
/// <summary> /// Active Player at same node as Npc -> interacts (can't happen if Npc in Invisible mode) /// </summary> /// <param name="npc"></param> private bool ProcessNpcInteract(Npc npc) { bool isSuccess = false; if (npc.CheckIfInvisibleMode() == false) { //Player interacts with Npc if (GameManager.i.playerScript.status == ActorStatus.Active) { //good effects string effectText = ProcessEffects(npc, true); string textTopString = string.Format("You {0}{1}{2} the {3}{4}{5}", colourAlert, npc.action.tag, colourEnd, colourAlert, npc.tag, colourEnd); string textBottomString = string.Format("The {0} {1} at {2}{3}{4}{5}{6}{7}", npc.tag, npc.action.outcome, colourAlert, npc.currentNode.nodeName, colourEnd, "\n", "\n", effectText); //pipeline msg ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails { textTop = textTopString, textBottom = textBottomString, sprite = npc.sprite, isAction = false, side = GameManager.i.globalScript.sideResistance, type = MsgPipelineType.Npc }; if (GameManager.i.guiScript.InfoPipelineAdd(outcomeDetails) == false) { Debug.LogWarningFormat("Npc interacts with Player InfoPipeline message FAILED to be added to dictOfPipeline"); } //messages (need to be BEFORE depart) Debug.LogFormat("[Npc] MissionManager.cs -> UpdateActiveNpc: Player INTERACTS with Npc \"{0}\" at {1}, {2}, ID {3}{4}", npc.tag, npc.currentNode.nodeName, npc.currentNode.Arc.name, npc.currentNode.nodeID, "\n"); GameManager.i.messageScript.NpcInteract("Npc interacted with", npc); //history GameManager.i.dataScript.AddHistoryPlayer(new HistoryActor() { text = string.Format("You {0} the {1}", npc.action.tag, npc.tag), district = npc.currentNode.nodeName }); //Npc departs map ProcessNpcDepart(npc, true); isSuccess = true; } } else { Debug.LogFormat("[Npc] MissionManager.cs -> ProcessNpcInteract: Npc in Invisible Mode, {0}, {1}, nodeID {2}{3}", npc.currentNode.nodeName, npc.currentNode.Arc.name, npc.currentNode.nodeID, "\n"); } return(isSuccess); }
/// <summary> /// Event Handler /// </summary> /// <param name="eventType"></param> /// <param name="Sender"></param> /// <param name="Param"></param> public void OnEvent(EventType eventType, Component Sender, object Param = null) { //detect event type switch (eventType) { case EventType.OutcomeOpen: ModalOutcomeDetails details = Param as ModalOutcomeDetails; if (details.isSpecial == true) { SetModalOutcomeSpecial(details); } else { SetModalOutcome(details); } break; case EventType.OutcomeClose: if (isSpecial == true) { StartCoroutine(RunCloseSequence()); } else { CloseModalOutcome(); } break; case EventType.OutcomeShowMe: ExecuteShowMe(); break; case EventType.OutcomeRestore: ExecuteRestore(); break; default: Debug.LogError(string.Format("Invalid eventType {0}{1}", eventType, "\n")); break; } }
/// <summary> /// Resistance Actor (Human/AI) captured /// NOTE: node, team and actor checked for null by parent method /// </summary> /// <param name="node"></param> /// <param name="team"></param> /// <param name="actor"></param> private void CaptureActor(CaptureDetails details) { string text = string.Format("{0}, {1}, Captured at \"{2}\", {3}", details.actor.actorName, details.actor.arc.name, details.node.nodeName, details.node.Arc.name); //message GameManager.i.messageScript.ActorCapture(text, details.node, details.team, details.actor.actorID); //AutoRun (both sides) if (GameManager.i.turnScript.CheckIsAutoRun() == true) { string textAutoRun = string.Format("{0}{1}{2}, {3}Captured{4}", colourAlert, details.actor.arc.name, colourEnd, colourBad, colourEnd); GameManager.i.dataScript.AddHistoryAutoRun(textAutoRun); } //detention period details.actor.captureTimer = captureTimerValue; //raise city loyalty int cause = GameManager.i.cityScript.CityLoyalty; cause += actorCaptured; cause = Mathf.Min(GameManager.i.cityScript.maxCityLoyalty, cause); GameManager.i.cityScript.CityLoyalty = cause; //invisibility set to zero (most likely already is) details.actor.SetDatapoint(ActorDatapoint.Invisibility2, 0); //history details.actor.AddHistory(new HistoryActor() { text = string.Format("Captured at {0}", details.node.nodeName) }); //update map GameManager.i.nodeScript.NodeRedraw = true; //update contacts GameManager.i.contactScript.UpdateNodeContacts(); //admin GameManager.i.actorScript.numOfActiveActors--; details.actor.Status = ActorStatus.Captured; details.actor.inactiveStatus = ActorInactive.None; details.actor.tooltipStatus = ActorTooltip.Captured; details.actor.nodeCaptured = details.node.nodeID; details.actor.numOfTimesCaptured++; if (GameManager.i.sideScript.resistanceOverall == SideState.Human) { //effects builder StringBuilder builder = new StringBuilder(); //any carry over text? if (string.IsNullOrEmpty(details.effects) == false) { builder.Append(string.Format("{0}{1}{2}", details.effects, "\n", "\n")); } builder.Append(string.Format("{0}{1} has been Captured{2}{3}{4}", colourBad, details.actor.arc.name, colourEnd, "\n", "\n")); builder.AppendFormat("{0}City Loyalty +{1}{2}{3}{4}", colourBad, actorCaptured, colourEnd, "\n", "\n"); //reduce actor alpha to show inactive (sprite and text) GameManager.i.actorPanelScript.UpdateActorAlpha(details.actor.slotID, GameManager.i.guiScript.alphaInactive); //popUpFixed -> don't wait for an outcome Msg, display straight away GameManager.i.popUpFixedScript.SetData(details.actor.slotID, "CAPTURED!"); //actor captured outcome window ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails { textTop = text, textBottom = builder.ToString(), sprite = GameManager.i.spriteScript.errorSprite, isAction = false, side = GameManager.i.globalScript.sideResistance }; //edge case of Inactive player and Authority AI capture an actor which may (?) generate a message that'll upset the info pipeline. If player active, display at time of action, otherwise put in pipeline if (GameManager.i.playerScript.status != ActorStatus.Active) { outcomeDetails.type = MsgPipelineType.CaptureActor; } EventManager.i.PostNotification(EventType.OutcomeOpen, this, outcomeDetails, "CaptureManager.cs -> CaptureActor"); } }
/// <summary> /// Player captured. /// Note: Node and Team already checked for null by parent method /// </summary> /// <param name="node"></param> /// <param name="team"></param> private void CapturePlayer(CaptureDetails details, bool isStartOfTurn = false) { //PLAYER CAPTURED string text = string.Format("Player Captured at {0}{1}{2}, {3}{4}{5} district by {6}{7} {8}{9}", colourAlert, details.node.nodeName, colourEnd, colourAlert, details.node.Arc.name, colourEnd, colourBad, details.team.arc.name, details.team.teamName, colourEnd); //AutoRun (both sides) if (GameManager.i.turnScript.CheckIsAutoRun() == true) { string textAutoRun = string.Format("{0} {1}Captured{2}", GameManager.i.playerScript.GetPlayerNameResistance(), colourBad, colourEnd); GameManager.i.dataScript.AddHistoryAutoRun(textAutoRun); } //detention period -> Note: Player only ever incarcerated for one turn (needs to be '2' for sequencing issues) GameManager.i.actorScript.captureTimerPlayer = 2; //effects builder StringBuilder builder = new StringBuilder(); //any carry over text? if (string.IsNullOrEmpty(details.effects) == false) { builder.Append(string.Format("{0}{1}{2}", details.effects, "\n", "\n")); } builder.Append(string.Format("{0}Player has been Captured{1}{2}{3}", colourBad, colourEnd, "\n", "\n")); //message GameManager.i.messageScript.ActorCapture(text, details.node, details.team); //update node trackers GameManager.i.nodeScript.nodePlayer = -1; GameManager.i.nodeScript.nodeCaptured = details.node.nodeID; //Raise city loyalty int cause = GameManager.i.cityScript.CityLoyalty; cause += actorCaptured; cause = Mathf.Min(GameManager.i.cityScript.maxCityLoyalty, cause); GameManager.i.cityScript.CityLoyalty = cause; //invisibility set to zero (most likely already is) GameManager.i.playerScript.Invisibility = 0; //statistics GameManager.i.dataScript.StatisticIncrement(StatType.PlayerCaptured); //update map GameManager.i.nodeScript.NodeRedraw = true; //set security state back to normal GameManager.i.authorityScript.SetAuthoritySecurityState("Security measures have been cancelled", string.Format("{0}, Player, has been CAPTURED", GameManager.i.playerScript.PlayerName)); //change player state if (GameManager.i.sideScript.resistanceOverall == SideState.Human) { //Human resistance player GameManager.i.playerScript.status = ActorStatus.Captured; GameManager.i.playerScript.tooltipStatus = ActorTooltip.Captured; GameManager.i.playerScript.inactiveStatus = ActorInactive.None; //AI side tab GameManager.i.aiScript.UpdateSideTabData(); //add power to authority actor who owns the team (only if they are still OnMap if (GameManager.i.sideScript.authorityOverall == SideState.Human) { if (GameManager.i.dataScript.CheckActorSlotStatus(details.team.actorSlotID, GameManager.i.globalScript.sideAuthority) == true) { Actor actor = GameManager.i.dataScript.GetCurrentActor(details.team.actorSlotID, GameManager.i.globalScript.sideAuthority); if (actor != null) { actor.Power++; } else { Debug.LogError(string.Format("Invalid actor (null) from team.ActorSlotID {0}", details.team.actorSlotID)); } } } builder.AppendFormat("{0}City Loyalty +{1}{2}{3}{4}", colourBad, actorCaptured, colourEnd, "\n", "\n"); //Gear confiscated int numOfGear = GameManager.i.playerScript.CheckNumOfGear(); if (numOfGear > 0) { List <string> listOfGear = GameManager.i.playerScript.GetListOfGear(); if (listOfGear != null) { //reverse loop through list of gear and remove all for (int i = listOfGear.Count - 1; i >= 0; i--) { GameManager.i.playerScript.RemoveGear(listOfGear[i], true); } builder.Append(string.Format("{0}Gear confiscated ({1} item{2}){3}", colourBad, numOfGear, numOfGear != 1 ? "s" : "", colourEnd)); } else { Debug.LogError("Invalid listOfGear (Null)"); } } //switch off flashing red indicator on top widget UI EventManager.i.PostNotification(EventType.StopSecurityFlash, this, null, "CaptureManager.cs -> CapturePlayer"); //reduce player alpha to show inactive (sprite and text) GameManager.i.actorPanelScript.UpdatePlayerAlpha(GameManager.i.guiScript.alphaInactive); //player captured outcome window ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails { textTop = text, textBottom = builder.ToString(), sprite = GameManager.i.spriteScript.capturedSprite, isAction = false, side = GameManager.i.globalScript.sideResistance, type = MsgPipelineType.CapturePlayer, help0 = "capture_0", help1 = "capture_1", help2 = "capture_2", help3 = "capture_3" }; if (GameManager.i.guiScript.InfoPipelineAdd(outcomeDetails) == false) { Debug.LogWarningFormat("Player Captured infoPipeline message FAILED to be added to dictOfPipeline"); } /*EventManager.instance.PostNotification(EventType.OpenOutcomeWindow, this, outcomeDetails, "CaptureManager.cs -> CapturePlayer"); NO NEED AS IN INFOPIPELINE ALREADY */ } else { //AI Resistance Player GameManager.i.aiRebelScript.status = ActorStatus.Captured; //Remove Gear GameManager.i.aiRebelScript.GearPoolEmpty("being CAPTURED"); } //invisible node if (GameManager.i.missionScript.mission.npc != null) { GameManager.i.missionScript.mission.npc.AddInvisibleNode(details.node.nodeID); } //popUpFixed -> don't wait for an outcome Msg, display straight away GameManager.i.popUpFixedScript.SetData(PopUpPosition.Player, "CAPTURED!"); GameManager.i.popUpFixedScript.SetData(PopUpPosition.Player, "Gear Lost"); GameManager.i.popUpFixedScript.SetData(PopUpPosition.TopCentre, $"City Loyalty +{actorCaptured}"); GameManager.i.popUpFixedScript.ExecuteFixed(); //Human player captured and not autorun if (GameManager.i.sideScript.resistanceOverall == SideState.Human && GameManager.i.turnScript.CheckIsAutoRun() == false) { //end turn GameManager.i.turnScript.SetActionsToZero(); } }
/// <summary> /// Tutorial button on RHS clicked, open up relevant tutorial UI based on supplied item /// </summary> /// <param name="item"></param> private void OpenTutorialItem(int index = -1) { //flush input buffer Input.ResetInputAxes(); if (GameManager.i.inputScript.ModalState == ModalState.Normal) { if (index > -1) { //get tutorialItem if (index < listOfSetItems.Count) { currentItem = listOfSetItems[index]; if (currentItem != null) { //switch off all arrows for (int i = 0; i < numOfItems; i++) { listOfInteractions[i].arrowImage.gameObject.SetActive(false); } //display arrow next to selected + 1 tutorial button (shows the next one you need to click on) if (index + 1 < numOfItems) { listOfInteractions[index + 1].arrowImage.gameObject.SetActive(true); } //what type of item switch (currentItem.tutorialType.name) { case "Dialogue": //open special outcome window ModalOutcomeDetails details = new ModalOutcomeDetails() { side = GameManager.i.sideScript.PlayerSide, textTop = GameManager.Formatt(currentItem.dialogue.topText, ColourType.moccasinText), textBottom = currentItem.dialogue.bottomText, sprite = GameManager.i.tutorialScript.tutorial.sprite, isAction = false, isSpecial = true, isSpecialGood = true }; EventManager.i.PostNotification(EventType.OutcomeOpen, this, details); break; case "Goal": GameManager.i.tutorialScript.UpdateGoal(currentItem.goal); //change colour to completed (indicates that you're currently doing, or have done, the goal) ColorBlock goalColours = listOfButtons[index].colors; goalColours.normalColor = colourCompleted; listOfButtons[index].colors = goalColours; break; case "Information": EventManager.i.PostNotification(EventType.GameHelpOpen, this, currentItem.gameHelp); break; case "Query": /* * if (currentItem.isQueryDone == false) * { * TopicUIData data = GetTopicData(currentItem); * if (data != null) * { EventManager.i.PostNotification(EventType.TopicDisplayOpen, this, data); } * //change colour to completed (indicates that you're currently doing, or have done, the query) * ColorBlock itemColours = listOfButtons[index].colors; * itemColours.normalColor = colourCompleted; * listOfButtons[index].colors = itemColours; * } * else * { * //query has already been done * ModalOutcomeDetails detailsDone = new ModalOutcomeDetails() * { * side = GameManager.i.sideScript.PlayerSide, * textBottom = "Haven't we already covered that?<br><br>I must be having a <b>Senior Moment</b>", * sprite = GameManager.i.tutorialScript.tutorial.sprite, * isAction = false, * isSpecial = true, * isSpecialGood = false * }; * if (string.IsNullOrEmpty(currentItem.queryHeader) == false) * { detailsDone.textTop = GameManager.Formatt(currentItem.queryHeader, ColourType.moccasinText); } * else * { * detailsDone.textTop = GameManager.Formatt("I beg your pardon", ColourType.moccasinText); * Debug.LogWarningFormat("Invalid queryHeader (Null or Empty) for \"{0}\"", currentItem.name); * } * //special outcome * EventManager.i.PostNotification(EventType.OutcomeOpen, this, detailsDone); * }*/ TopicUIData data = GetTopicData(currentItem); if (data != null) { EventManager.i.PostNotification(EventType.TopicDisplayOpen, this, data); } /*//change colour to completed (indicates that you're currently doing, or have done, the query) * ColorBlock itemColours = listOfButtons[index].colors; * itemColours.normalColor = colourCompleted; * listOfButtons[index].colors = itemColours;*/ break; default: Debug.LogWarningFormat("Unrecognised item.TutorialType \"{0}\"", currentItem.tutorialType.name); break; } } else { Debug.LogWarningFormat("Invalid currentItem (tutorial) (Null)"); } } else { Debug.LogWarningFormat("Invalid index (is {0}, listOfSetItems.Count is {1})", index, listOfSetItems.Count); } } else { Debug.LogWarning("Invalid index (button.buttonInteraction.returnValue (-1)"); } } }
/// <summary> /// Open Inventory UI /// </summary> /// <param name="details"></param> private void SetInventoryUI(InventoryInputData details) { Color colorImage, colorStars, colorText; bool errorFlag = false; //set modal status GameManager.i.guiScript.SetIsBlocked(true); //tooltips off GameManager.i.guiScript.SetTooltipsOff(); //activate main panel inventoryCanvas.gameObject.SetActive(true); //delegate method to be called in the event of refresh handler = details.handler; //populate dialogue if (details != null) { //set up modal panel & buttons to be side appropriate switch (details.side.name) { case "Authority": modalPanel.sprite = GameManager.i.sideScript.inventory_background_Authority; headerPanel.sprite = GameManager.i.sideScript.header_background_Authority; //set button sprites buttonCancel.GetComponent <Image>().sprite = GameManager.i.sideScript.button_Authority; /*//set sprite transitions * SpriteState spriteStateAuthority = new SpriteState(); * spriteStateAuthority.highlightedSprite = GameManager.i.sideScript.button_highlight_Authority; * spriteStateAuthority.pressedSprite = GameManager.i.sideScript.button_Click; * buttonCancel.spriteState = spriteStateAuthority;*/ break; case "Resistance": modalPanel.sprite = GameManager.i.sideScript.inventory_background_Resistance; headerPanel.sprite = GameManager.i.sideScript.header_background_Resistance; //set button sprites buttonCancel.GetComponent <Image>().sprite = GameManager.i.sideScript.button_Resistance; /*//set sprite transitions * SpriteState spriteStateRebel = new SpriteState(); * spriteStateRebel.highlightedSprite = GameManager.i.sideScript.button_highlight_Resistance; * spriteStateRebel.pressedSprite = GameManager.i.sideScript.button_Click; * buttonCancel.spriteState = spriteStateRebel;*/ break; default: Debug.LogError(string.Format("Invalid side \"{0}\"", details.side.name)); break; } //set texts headerText.text = details.textHeader; topText.text = details.textTop; bottomText.text = details.textBottom; //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); } //loop array and set options for (int i = 0; i < details.arrayOfOptions.Length; i++) { //valid option? if (arrayOfInventoryOptions[i] != null) { if (arrayOfInteractions[i] != null) { if (details.arrayOfOptions[i] != null) { //activate option arrayOfInventoryOptions[i].SetActive(true); //check if greyed out (NOTE: doesn't include stars/text above image, eg. compatibility as only CaptureTool options can be greyed out and they don't have compatibility stars) colorImage = arrayOfInteractions[i].optionImage.color; colorText = arrayOfInteractions[i].textUpper.color; colorStars = arrayOfInteractions[i].textLower.color; if (details.arrayOfOptions[i].isFaded == true) { //fade image colorImage.a = 0.25f; colorText.a = 0.25f; colorStars.a = 0.25f; } else { //need to set to full alpha otherwise previous settings will carry over colorImage.a = 1.0f; colorText.a = 1.0f; colorStars.a = 1.0f; } arrayOfInteractions[i].optionImage.color = colorImage; arrayOfInteractions[i].textUpper.color = colorText; arrayOfInteractions[i].textLower.color = colorStars; //populate option data arrayOfInteractions[i].optionImage.sprite = details.arrayOfOptions[i].sprite; arrayOfInteractions[i].textTop.text = details.arrayOfOptions[i].textTop; arrayOfInteractions[i].textUpper.text = details.arrayOfOptions[i].textUpper; arrayOfInteractions[i].textLower.text = details.arrayOfOptions[i].textLower; arrayOfInteractions[i].optionData = details.arrayOfOptions[i].optionID; arrayOfInteractions[i].actorSlotID = details.arrayOfOptions[i].slotID; arrayOfInteractions[i].optionName = details.arrayOfOptions[i].optionName; arrayOfInteractions[i].type = details.state; //tooltip data -> sprites if (arrayOfTooltipsSprites[i] != null) { if (details.arrayOfTooltipsSprite[i] != null) { arrayOfTooltipsSprites[i].gameObject.SetActive(true); arrayOfTooltipsSprites[i].tooltipHeader = details.arrayOfTooltipsSprite[i].textHeader; arrayOfTooltipsSprites[i].tooltipMain = details.arrayOfTooltipsSprite[i].textMain; arrayOfTooltipsSprites[i].tooltipDetails = details.arrayOfTooltipsSprite[i].textDetails; arrayOfTooltipsSprites[i].x_offset = 55; } else { Debug.LogWarningFormat("Invalid tooltipDetailsSprite (Null) for arrayOfOptions[{0}]", i); } } else { Debug.LogError(string.Format("Invalid GenericTooltipUI (Null) in arrayOfTooltips[{0}]", i)); } //tooltip data -> stars if (arrayOfTooltipsStars[i] != null) { if (details.arrayOfTooltipsStars[i] != null) { arrayOfTooltipsStars[i].gameObject.SetActive(true); arrayOfTooltipsStars[i].tooltipHeader = details.arrayOfTooltipsStars[i].textHeader; arrayOfTooltipsStars[i].tooltipMain = details.arrayOfTooltipsStars[i].textMain; arrayOfTooltipsStars[i].tooltipDetails = details.arrayOfTooltipsStars[i].textDetails; arrayOfTooltipsStars[i].x_offset = 55; arrayOfTooltipsStars[i].y_offset = 15; } else { //this tooltip is optional, fill with blank data otherwise previously used data will be used arrayOfTooltipsStars[i].tooltipHeader = ""; arrayOfTooltipsStars[i].tooltipMain = ""; arrayOfTooltipsStars[i].tooltipDetails = ""; } } //tooltip data -> compatibility if (arrayOfTooltipsCompatibility[i] != null) { if (details.arrayOfTooltipsCompatibility[i] != null) { arrayOfTooltipsCompatibility[i].gameObject.SetActive(true); arrayOfTooltipsCompatibility[i].tooltipHeader = details.arrayOfTooltipsCompatibility[i].textHeader; arrayOfTooltipsCompatibility[i].tooltipMain = details.arrayOfTooltipsCompatibility[i].textMain; arrayOfTooltipsCompatibility[i].tooltipDetails = details.arrayOfTooltipsCompatibility[i].textDetails; arrayOfTooltipsCompatibility[i].x_offset = 55; arrayOfTooltipsCompatibility[i].y_offset = 15; } else { //this tooltip is optional, fill with blank data otherwise previously used data will be used arrayOfTooltipsCompatibility[i].tooltipHeader = ""; arrayOfTooltipsCompatibility[i].tooltipMain = ""; arrayOfTooltipsCompatibility[i].tooltipDetails = ""; } } //tooltip data -> upper Text if (arrayOfTooltipsTexts[i] != null) { if (details.arrayOfTooltipsTexts[i] != null) { arrayOfTooltipsTexts[i].gameObject.SetActive(true); arrayOfTooltipsTexts[i].tooltipHeader = details.arrayOfTooltipsTexts[i].textHeader; arrayOfTooltipsTexts[i].tooltipMain = details.arrayOfTooltipsTexts[i].textMain; arrayOfTooltipsTexts[i].tooltipDetails = details.arrayOfTooltipsTexts[i].textDetails; arrayOfTooltipsTexts[i].x_offset = 55; arrayOfTooltipsTexts[i].y_offset = 15; } else { //this tooltip is optional, fill with blank data otherwise previously used data will be used arrayOfTooltipsTexts[i].tooltipHeader = ""; arrayOfTooltipsTexts[i].tooltipMain = ""; arrayOfTooltipsTexts[i].tooltipDetails = ""; } } } else { //invalid option, switch off arrayOfInventoryOptions[i].SetActive(false); } } else { //error -> Null Interaction data Debug.LogErrorFormat("Invalid arrayOfInventoryOptions[\"{0}\"] optionInteraction (Null)", i); break; } } else { //error -> Null array Debug.LogErrorFormat("Invalid arrayOfInventoryOptions[{0}] (Null)", i); break; } } } else { Debug.LogError("Invalid InventoryInputData (Null)"); errorFlag = true; } //error outcome message if there is a problem if (errorFlag == true) { modalInventoryObject.SetActive(false); //create an outcome window to notify player ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails(); outcomeDetails.textTop = "There has been a hiccup and the information isn't available"; outcomeDetails.textBottom = "We've called the WolfMan. He's on his way"; outcomeDetails.side = details.side; EventManager.i.PostNotification(EventType.OutcomeOpen, this, outcomeDetails, "ModalInventoryUI.cs -> SetInventoryUI"); } else { //all good, inventory window displayed ModalStateData package = new ModalStateData() { mainState = ModalSubState.Inventory, inventoryState = details.state }; GameManager.i.inputScript.SetModalState(package); Debug.LogFormat("[UI] ModalInventoryUI.cs -> SetInventoryUI{0}", "\n"); } }
/*/// <summary> * /// event handler * /// </summary> * /// <param name="eventType"></param> * /// <param name="Sender"></param> * /// <param name="Param"></param> * public void OnEvent(EventType eventType, Component Sender, object Param = null) * { * //detect event type * switch (eventType) * { * case EventType.ChangeColour: * SetColours(); * break; * default: * Debug.LogError(string.Format("Invalid eventType {0}{1}", eventType, "\n")); * break; * } * }*/ /*/// <summary> * /// Set colour palette for tooltip * /// </summary> * public void SetColours() * { * colourDefault = GameManager.instance.colourScript.GetColour(ColourType.whiteText); * colourNormal = GameManager.instance.colourScript.GetColour(ColourType.normalText); * colourAlert = GameManager.instance.colourScript.GetColour(ColourType.salmonText); * colourResistance = GameManager.instance.colourScript.GetColour(ColourType.blueText); * colourBad = GameManager.instance.colourScript.GetColour(ColourType.badText); * colourNeutral = GameManager.instance.colourScript.GetColour(ColourType.neutralText); * colourGood = GameManager.instance.colourScript.GetColour(ColourType.goodText); * colourEnd = GameManager.instance.colourScript.GetEndTag(); * }*/ #region RemoveSecretFromAll /// <summary> /// Removes a given secret from all actors (OnMap and Reserve) and player. If calling for a deleted secret then set to true, otherwise, for a normal revealed secret situation, default false /// This ensures that if a secret is deleted from an actor who is currently blackmailing then their blackmailer status is removed if they end up with no secrets remaining /// Revealed secrets may trigger an investigation, deleted ones not /// Returns true if successfully removed secret/s, false otherwise /// </summary> /// <param name="secretID"></param> public bool RemoveSecretFromAll(string secretName, bool isDeletedSecret = false) { GlobalSide side = GameManager.i.sideScript.PlayerSide; Secret secret = GameManager.i.dataScript.GetSecret(secretName); bool isSuccess = true; if (secret != null) { //remove from player GameManager.i.playerScript.RemoveSecret(secretName); if (isDeletedSecret == true) { //message string playerMsg = string.Format("Player loses secret \"{0}\"", secret.tag); GameManager.i.messageScript.PlayerSecret(playerMsg, secret, false); } //remove actors from secret list secret.RemoveAllActors(); //Create a list of all current actors plus all actors in Reserve List <Actor> listOfActors = new List <Actor>(); //add current actors Actor[] arrayOfActors = GameManager.i.dataScript.GetCurrentActorsFixed(side); if (arrayOfActors != null) { for (int i = 0; i < arrayOfActors.Length; i++) { //check actor is present in slot (not vacant) if (GameManager.i.dataScript.CheckActorSlotStatus(i, side) == true) { listOfActors.Add(arrayOfActors[i]); } } } else { Debug.LogWarning("Invalid arrayOfActors (Null)"); } //add reserve actors List <int> listOfReserveActors = GameManager.i.dataScript.GetActorList(GameManager.i.sideScript.PlayerSide, ActorList.Reserve); if (listOfReserveActors.Count > 0) { for (int i = 0; i < listOfReserveActors.Count; i++) { Actor actor = GameManager.i.dataScript.GetActor(listOfReserveActors[i]); if (actor != null) { listOfActors.Add(actor); } else { Debug.LogWarningFormat("Invalid actor (Null) for actorID {0}", listOfReserveActors[i]); } } } //loop all actors foreach (Actor actor in listOfActors) { if (actor != null) { actor.RemoveSecret(secretName); //blackmail check -> if actor is blackmailing and they end up with zero secrets then the condition is removed if (isDeletedSecret == true) { //message (any situation where a blackmail check is needed is going to be a deleted secret, hence the need for a message string msgText = string.Format("{0} loses secret \"{1}\"", actor.arc.name, secret.tag); GameManager.i.messageScript.ActorSecret(msgText, actor, secret, false); if (actor.CheckConditionPresent(conditionBlackmail) == true) { if (actor.CheckNumOfSecrets() == 0) { actor.RemoveCondition(conditionBlackmail, "Secret no longer has any effect"); //additional explanatory message (why has condition gone?) string blackText = string.Format("{0} can no longer Blackmail (no Secret)", actor.arc.name); string reason = "The secret they hold has no value"; GameManager.i.messageScript.ActorBlackmail(blackText, actor, secret, true, reason); } } } } } //chance Investigation launched if (GameManager.i.playerScript.CheckInvestigationPossible() == true) { //revealed secrets only (no investigation possible for deleted secrets) if (isDeletedSecret == false) { string text; int rnd = Random.Range(0, 100); int chance = GameManager.i.playerScript.chanceInvestigation; int gameTurn = GameManager.i.turnScript.Turn; if (rnd < chance) { //create a new investigation Investigation invest = new Investigation() { reference = string.Format("{0}{1}", gameTurn, secret.name), tag = secret.investigationTag, evidence = secret.investigationEvidence, turnStart = gameTurn, lead = GameManager.i.hqScript.GetRandomHqPosition(), city = GameManager.i.cityScript.GetCityName(), status = InvestStatus.Ongoing, outcome = InvestOutcome.None }; //add to player's list GameManager.i.playerScript.AddInvestigation(invest); //stats GameManager.i.dataScript.StatisticIncrement(StatType.InvestigationsLaunched); //msgs Debug.LogFormat("[Rnd] SecretManager.cs -> RemoveSecretFromAll: INVESTIGATION commences, need < {0}, rolled {1}{2}", chance, rnd, "\n"); text = "INVESTIGATION commences"; GameManager.i.messageScript.GeneralRandom(text, "Investigation", chance, rnd, true, "rand_4"); text = string.Format("Investigation into Player {0} launched by {1}", invest.tag, invest.lead); GameManager.i.messageScript.InvestigationNew(text, invest); //history GameManager.i.dataScript.AddHistoryPlayer(new HistoryActor() { text = string.Format("Investigation Launched into your conduct ({0})", secret.investigationTag) }); //outcome (message pipeline) text = string.Format("<size=120%>INVESTIGATION</size>{0}Launched into your{1}{2}", "\n", "\n", GameManager.Formatt(invest.tag, ColourType.neutralText)); string bottomText = "Unknown"; Actor actor = GameManager.i.dataScript.GetHqHierarchyActor(invest.lead); if (actor == null) { Debug.LogErrorFormat("Invalid HQ actor for ActorHQ invest.lead \"{0}\"", GameManager.i.hqScript.GetHqTitle(invest.lead)); bottomText = string.Format("HQ have assigned their {0} to lead the investigation{1}", actor.actorName, GameManager.Formatt(GameManager.i.hqScript.GetHqTitle(invest.lead), ColourType.salmonText).ToUpper(), "\n"); } else { bottomText = string.Format("HQ have assigned{0}{1}, {2}{3}to lead the investigation{4}", "\n", actor.actorName, GameManager.Formatt(GameManager.i.hqScript.GetHqTitle(invest.lead), ColourType.salmonText).ToUpper(), "\n", "\n"); } ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails { textTop = text, textBottom = bottomText, sprite = GameManager.i.spriteScript.investigationSprite, isAction = false, side = GameManager.i.sideScript.PlayerSide, type = MsgPipelineType.InvestigationLaunched, help0 = "invest_10" }; if (GameManager.i.guiScript.InfoPipelineAdd(outcomeDetails) == false) { Debug.LogWarningFormat("Investigation Launched InfoPipeline message FAILED to be added to dictOfPipeline"); } } else { //msgs Debug.LogFormat("[Rnd] SecretManager.cs -> RemoveSecretFromAll: No Investigation, need < {0}, rolled {1}{2}", chance, rnd, "\n"); text = "No INVESTIGATION"; GameManager.i.messageScript.GeneralRandom(text, "Investigation", chance, rnd, false, "rand_4"); } } } else { Debug.LogFormat("[Inv] SecretManager.cs -> RemoveSecretFromAll: Max number of investigations already, new Investigation not possible{0}", "\n"); } } else { isSuccess = false; Debug.LogWarningFormat("Invalid secret (Null) for secret {0} -> Not removed", secretName); } return(isSuccess); }
/// <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> /// 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"); } }
/// <summary> /// Initialise ModalOutcome window but in special format (expanding black bars across the screen) /// </summary> /// <param name="details"></param> private void SetModalOutcomeSpecial(ModalOutcomeDetails details) { if (details != null) { isSpecial = true; //ignore if autoRun true if (GameManager.i.turnScript.CheckIsAutoRun() == false) { if (CheckModalOutcomeActive() == false) { //reset input Input.ResetInputAxes(); //exit any generic or node tooltips GameManager.i.tooltipGenericScript.CloseTooltip("ModalOutcome.cs -> SetModalOutcomeSpecial"); GameManager.i.tooltipNodeScript.CloseTooltip("ModalOutcome.cs -> SetModalOutcomeSpecial"); GameManager.i.tooltipHelpScript.CloseTooltip("ModalOutcome.cs -> SetModalOutcomeSpecial"); reason = details.reason; triggerEvent = details.triggerEvent; //set modal true GameManager.i.guiScript.SetIsBlocked(true, details.modalLevel); //toggle panels panelNormal.gameObject.SetActive(false); canvasSpecial.gameObject.SetActive(true); //register action status isAction = details.isAction; #region archive /*//Show Me * if (details.listOfNodes != null && details.listOfNodes.Count > 0) * { * * //showMe data * listOfShowMeNodes = details.listOfNodes; * //disable Confirm, activate Show Me button * confirmButtonNormal.gameObject.SetActive(false); * showMeButtonNormal.gameObject.SetActive(true); * //events to call to handle underlying UI (if any) * hideOtherEvent = details.hideEvent; * restoreOtherEvent = details.restoreEvent; * } * else * { * listOfShowMeNodes.Clear(); * //disable ShowMe, activate Confirm button * confirmButtonNormal.gameObject.SetActive(true); * showMeButtonNormal.gameObject.SetActive(false); * //default settings for events * hideOtherEvent = EventType.None; * restoreOtherEvent = EventType.None; * }*/ //set opacity to zero (invisible) //SetOpacity(0f); #endregion //set up modalOutcome elements topTextSpecial.text = details.textTop; bottomTextSpecial.text = details.textBottom; /*bottomTextSpecial.text = string.Format("{0}{1}{2}<size=80%>Press ANY Key to exit</size>", details.textBottom, "\n", "\n");*/ if (details.sprite != null) { portraitSpecial.sprite = details.sprite; } //open Canvas outcomeCanvas.gameObject.SetActive(true); //set blackBar to min width blackBarTransform.sizeDelta = new Vector2(specialWidth, blackBarTransform.sizeDelta.y); //highlight colour if (details.isSpecialGood == true) { highlight.color = colourGood; } else { highlight.color = colourBad; } //set states ModalStateData package = new ModalStateData() { mainState = ModalSubState.Outcome }; GameManager.i.inputScript.SetModalState(package); //pass through data for when the outcome window is closed modalLevel = details.modalLevel; modalState = details.modalState; Debug.LogFormat("[UI] ModalOutcome.cs -> SetModalOutcomeSpecial{0}", "\n"); //fixed popUps GameManager.i.popUpFixedScript.ExecuteFixed(0.75f); //grow black bars myCoroutineBarGrow = StartCoroutine("GrowBlackBar"); myCoroutineHighlights = StartCoroutine("RunHighlights"); } else { Debug.LogWarning("Can't start a new Modal Outcome as an instance is already active"); } } } else { Debug.LogWarning("Invalid ModalOutcomeDetails package (Null)"); } }
/// <summary> /// Initiate Modal Outcome window /// </summary> /// <param name="details"></param> public void SetModalOutcome(ModalOutcomeDetails details) { if (details != null) { isSpecial = false; //ignore if autoRun true if (GameManager.i.turnScript.CheckIsAutoRun() == false) { //reset input Input.ResetInputAxes(); //exit any generic or node tooltips GameManager.i.tooltipGenericScript.CloseTooltip("ModalOutcome.cs -> SetModalOutcome"); GameManager.i.tooltipNodeScript.CloseTooltip("ModalOutcome.cs -> SetModalOutcome"); GameManager.i.tooltipHelpScript.CloseTooltip("ModalOutcome.cs -> SetModalOutcome"); reason = details.reason; triggerEvent = details.triggerEvent; //set help List <HelpData> listOfHelpData = GameManager.i.helpScript.GetHelpData(details.help0, details.help1, details.help2, details.help3); if (listOfHelpData != null && listOfHelpData.Count > 0) { helpButtonNormal.gameObject.SetActive(true); helpNormal.SetHelpTooltip(listOfHelpData, 100, 200); } else { helpButtonNormal.gameObject.SetActive(false); } //set modal true GameManager.i.guiScript.SetIsBlocked(true, details.modalLevel); //toggle panels panelNormal.gameObject.SetActive(true); canvasSpecial.gameObject.SetActive(false); //register action status isAction = details.isAction; /* * //set confirm button image and sprite states * switch (details.side.name) * { * case "Authority": * //set button sprites * confirmButton.GetComponent<Image>().sprite = GameManager.i.sideScript.button_Authority; * //set sprite transitions * SpriteState spriteStateAuthority = new SpriteState(); * spriteStateAuthority.highlightedSprite = GameManager.i.sideScript.button_highlight_Authority; * spriteStateAuthority.pressedSprite = GameManager.i.sideScript.button_Click; * confirmButton.spriteState = spriteStateAuthority; * break; * case "Resistance": * //set button sprites * confirmButton.GetComponent<Image>().sprite = GameManager.i.sideScript.button_Resistance; * //set sprite transitions * SpriteState spriteStateRebel = new SpriteState(); * spriteStateRebel.highlightedSprite = GameManager.i.sideScript.button_highlight_Resistance; * spriteStateRebel.pressedSprite = GameManager.i.sideScript.button_Click; * confirmButton.spriteState = spriteStateRebel; * break; * default: * Debug.LogError(string.Format("Invalid side \"{0}\"", details.side)); * break; * } * //set transition * confirmButton.transition = Selectable.Transition.SpriteSwap; */ //Show Me if (details.listOfNodes != null && details.listOfNodes.Count > 0) { //showMe data listOfShowMeNodes = details.listOfNodes; //disable Confirm, activate Show Me button confirmButtonNormal.gameObject.SetActive(false); showMeButtonNormal.gameObject.SetActive(true); //events to call to handle underlying UI (if any) hideOtherEvent = details.hideEvent; restoreOtherEvent = details.restoreEvent; } else { listOfShowMeNodes.Clear(); //disable ShowMe, activate Confirm button confirmButtonNormal.gameObject.SetActive(true); showMeButtonNormal.gameObject.SetActive(false); //default settings for events hideOtherEvent = EventType.None; restoreOtherEvent = EventType.None; } //set opacity to zero (invisible) //SetOpacity(0f); //set up modalOutcome elements topTextNormal.text = details.textTop; bottomTextNormal.text = details.textBottom; if (details.sprite != null) { portraitNormal.sprite = details.sprite; } /*//get dimensions of outcome window (dynamic) * float width = rectTransform.rect.width; * float height = rectTransform.rect.height;*/ //set states ModalStateData package = new ModalStateData() { mainState = ModalSubState.Outcome }; GameManager.i.inputScript.SetModalState(package); //open Canvas outcomeCanvas.gameObject.SetActive(true); //pass through data for when the outcome window is closed modalLevel = details.modalLevel; modalState = details.modalState; Debug.LogFormat("[UI] ModalOutcome.cs -> SetModalOutcome{0}", "\n"); //fixed popUps GameManager.i.popUpFixedScript.ExecuteFixed(0.75f); } } else { Debug.LogWarning("Invalid ModalOutcomeDetails package (Null)"); } }
/// <summary> /// Release, or Escapes, Human/AI Resitance player from captitivity. 'isMessage' true for an outcome message (go false if called via EffectManager.cs). 'isReleased' false then assumed to have escaped /// </summary> public void ReleasePlayer(bool isMessage = false, bool isReleased = true) { string text; StringBuilder builder = new StringBuilder(); //update nodes int nodeID = GameManager.i.nodeScript.nodeCaptured; //message Node node = GameManager.i.dataScript.GetNode(nodeID); if (node != null) { if (isReleased == true) { //released text = string.Format("{0}, Player, released at \"{1}\", {2}", GameManager.i.playerScript.GetPlayerNameResistance(), node.nodeName, node.Arc.name); GameManager.i.messageScript.ActorRelease(text, node, GameManager.i.playerScript.actorID); } else { //escapes (can only do so with help of OrgEmergency) text = string.Format("{0}, Player, escapes from captivity at \"{1}\", {2}", GameManager.i.playerScript.GetPlayerNameResistance(), node.nodeName, node.Arc.name); GameManager.i.messageScript.PlayerEscapes(text, node); //history GameManager.i.dataScript.AddHistoryPlayer(new HistoryActor() { text = "You ESCAPE from Captivity", district = node.nodeName }); } Debug.LogFormat("[Ply] CaptureManager.cs -> ReleasePlayer: {0}{1}", text, "\n"); //history GameManager.i.dataScript.AddHistoryPlayer(new HistoryActor() { text = "You are RELEASED from Captivity", district = node.nodeName }); //actor gains condition questionable (do BEFORE updating nodeID's) GameManager.i.playerScript.AddCondition(conditionQuestionable, GameManager.i.globalScript.sideResistance, "Has been interrogated by Authority"); //update nodeID's GameManager.i.nodeScript.nodePlayer = nodeID; GameManager.i.nodeScript.nodeCaptured = -1; //decrease city loyalty int cause = GameManager.i.cityScript.CityLoyalty; cause -= actorReleased; cause = Mathf.Max(0, cause); GameManager.i.cityScript.CityLoyalty = cause; //zero out capture timer GameManager.i.actorScript.captureTimerPlayer = 0; //invisibility int invisibilityNew = releaseInvisibility; GameManager.i.playerScript.Invisibility = invisibilityNew; //autorun if (GameManager.i.turnScript.CheckIsAutoRun() == true) { text = string.Format("{0} {1}Released{2}", GameManager.i.playerScript.GetPlayerNameResistance(), colourGood, colourEnd); GameManager.i.dataScript.AddHistoryAutoRun(text); } //human resistance player if (GameManager.i.sideScript.resistanceOverall == SideState.Human) { //reset state GameManager.i.playerScript.status = ActorStatus.Active; GameManager.i.playerScript.tooltipStatus = ActorTooltip.None; builder.AppendFormat("{0}City Loyalty -{1}{2}{3}{4}", colourGood, actorReleased, colourEnd, "\n", "\n"); builder.AppendFormat("{0}Player's Invisibility +{1}{2}{3}{4}", colourGood, invisibilityNew, colourEnd, "\n", "\n"); builder.AppendFormat("{0}QUESTIONABLE condition gained{1}", colourBad, colourEnd); //AI side tab (otherwise 'player indisposed' message when accessing tab) GameManager.i.aiScript.UpdateSideTabData(); //update Player alpha GameManager.i.actorPanelScript.UpdatePlayerAlpha(GameManager.i.guiScript.alphaActive); //update map GameManager.i.nodeScript.NodeRedraw = true; if (isMessage == true) { //player released outcome window ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails { textTop = text, textBottom = builder.ToString(), sprite = GameManager.i.spriteScript.errorSprite, isAction = false, side = GameManager.i.globalScript.sideResistance, type = MsgPipelineType.ReleasePlayer }; if (GameManager.i.guiScript.InfoPipelineAdd(outcomeDetails) == false) { Debug.LogWarningFormat("Player Released from Captivity infoPipeline message FAILED to be added to dictOfPipeline"); } } //generate Action Points for the turn (Turn sequence has already reset to Zero due to player being captured) GameManager.i.turnScript.SetActionsForNewTurn(); } else { //AI resistance player GameManager.i.aiRebelScript.status = ActorStatus.Active; } } else { Debug.LogError(string.Format("Invalid node (Null) for nodeId {0}", nodeID)); } }
/// <summary> /// Open Review UI /// </summary> private void SetReviewUI(ReviewInputData details) { bool errorFlag = false; isOutcome = false; //reset timer (may have changed previously if player skipped review) reviewWaitTime = reviewWaitTimerDefault; Debug.LogFormat("[UI] ModalReviewUI.cs -> OpenReviewUI{0}", "\n"); //set modal status GameManager.i.guiScript.SetIsBlocked(true); //activate main panel panelObject.SetActive(true); reviewObject.SetActive(true); headerObject.SetActive(true); GlobalSide playerSide = GameManager.i.sideScript.PlayerSide; //buttons buttonReview.gameObject.SetActive(true); buttonExit.gameObject.SetActive(false); buttonHelpOpen.gameObject.SetActive(true); buttonHelpClose.gameObject.SetActive(false); //outcome symbols outcomeLeft.gameObject.SetActive(false); outcomeRight.gameObject.SetActive(false); //tooltips InitialiseHelp(); //set up modal panel & buttons to be side appropriate switch (playerSide.level) { case 1: panelBackground.sprite = GameManager.i.sideScript.inventory_background_Authority; panelHeader.sprite = GameManager.i.sideScript.header_background_Authority; //set button sprites buttonReview.GetComponent <Image>().sprite = GameManager.i.sideScript.button_Authority; buttonExit.GetComponent <Image>().sprite = GameManager.i.sideScript.button_Authority; //set sprite transitions SpriteState spriteStateAuthority = new SpriteState(); spriteStateAuthority.highlightedSprite = GameManager.i.sideScript.button_highlight_Authority; spriteStateAuthority.pressedSprite = GameManager.i.sideScript.button_Click; buttonReview.spriteState = spriteStateAuthority; buttonExit.spriteState = spriteStateAuthority; break; case 2: panelBackground.sprite = GameManager.i.sideScript.inventory_background_Resistance; panelHeader.sprite = GameManager.i.sideScript.header_background_Resistance; //set button sprites buttonReview.GetComponent <Image>().sprite = GameManager.i.sideScript.button_Resistance; buttonExit.GetComponent <Image>().sprite = GameManager.i.sideScript.button_Resistance; //set sprite transitions SpriteState spriteStateRebel = new SpriteState(); spriteStateRebel.highlightedSprite = GameManager.i.sideScript.button_highlight_Resistance; spriteStateRebel.pressedSprite = GameManager.i.sideScript.button_Click; buttonReview.spriteState = spriteStateRebel; buttonExit.spriteState = spriteStateRebel; break; default: Debug.LogError(string.Format("Invalid side \"{0}\"", playerSide.name)); break; } //set texts textHeader.text = "Peer Review"; textTop.text = "You are about to be assessed by your Peers"; textBottom.text = "Press SPACE, or the COMMENCE REVIEW button"; if (details != null) { //loop array and set options for (int i = 0; i < arrayOfOptions.Length; i++) { //valid option? if (arrayOfOptions[i] != null) { if (arrayOfInteractions[i] != null) { if (arrayOfOptions[i] != null) { //activate option arrayOfOptions[i].SetActive(true); //populate option data arrayOfInteractions[i].optionImage.sprite = details.arrayOfOptions[i].sprite; arrayOfInteractions[i].textUpper.text = details.arrayOfOptions[i].textUpper; arrayOfInteractions[i].optionData = details.arrayOfOptions[i].optionID; //result arrayOfInteractions[i].textResult.gameObject.SetActive(false); arrayOfInteractions[i].textResult.text = details.arrayOfOptions[i].textLower; //tooltip data -> sprites & titles (identical) if (arrayOfTooltipsSprites[i] != null) { if (details.arrayOfTooltipsSprite[i] != null) { //sprites arrayOfTooltipsSprites[i].tooltipHeader = details.arrayOfTooltipsSprite[i].textHeader; arrayOfTooltipsSprites[i].tooltipMain = details.arrayOfTooltipsSprite[i].textMain; arrayOfTooltipsSprites[i].tooltipDetails = details.arrayOfTooltipsSprite[i].textDetails; arrayOfTooltipsSprites[i].x_offset = 55; arrayOfTooltipsSprites[i].y_offset = -10; //titles arrayOfTooltipsTitles[i].tooltipHeader = details.arrayOfTooltipsSprite[i].textHeader; arrayOfTooltipsTitles[i].tooltipMain = details.arrayOfTooltipsSprite[i].textMain; arrayOfTooltipsTitles[i].tooltipDetails = details.arrayOfTooltipsSprite[i].textDetails; arrayOfTooltipsTitles[i].x_offset = 55; arrayOfTooltipsTitles[i].y_offset = 50; } else { Debug.LogWarningFormat("Invalid tooltipDetailsSprite (Null) for arrayOfOptions[{0}]", i); } } else { Debug.LogError(string.Format("Invalid GenericTooltipUI (Null) in arrayOfTooltips[{0}]", i)); } //tooltip data -> results if (arrayOfTooltipsResults[i] != null) { if (details.arrayOfTooltipsResult[i] != null) { arrayOfTooltipsResults[i].tooltipHeader = details.arrayOfTooltipsResult[i].textHeader; arrayOfTooltipsResults[i].tooltipMain = details.arrayOfTooltipsResult[i].textMain; arrayOfTooltipsResults[i].tooltipDetails = details.arrayOfTooltipsResult[i].textDetails; arrayOfTooltipsResults[i].x_offset = 55; arrayOfTooltipsResults[i].y_offset = 15; } else { Debug.LogWarningFormat("Invalid tooltipResults (Null) in arrayOfTooltipResults[{0}]", i); } } else { Debug.LogWarningFormat("Invalid arrayOfTooltipsResults[{0}] (Null)", i); } } else { //invalid option, switch off arrayOfOptions[i].SetActive(false); } } else { //error -> Null Interaction data Debug.LogErrorFormat("Invalid arrayOfInventoryOptions[\"{0}\"] optionInteraction (Null)", i); errorFlag = true; break; } } else { //error -> Null array Debug.LogErrorFormat("Invalid arrayOfInventoryOptions[{0}] (Null)", i); errorFlag = true; break; } } } else { Debug.LogError("Invalid ReviewInputData (Null)"); errorFlag = true; } //error outcome message if there is a problem if (errorFlag == true) { reviewObject.SetActive(false); //create an outcome window to notify player ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails(); outcomeDetails.textTop = "There has been a hiccup and the information isn't available"; outcomeDetails.textBottom = "We've called the WolfMan. He's on his way"; outcomeDetails.side = playerSide; EventManager.i.PostNotification(EventType.OutcomeOpen, this, outcomeDetails, "ModalInventoryUI.cs -> SetInventoryUI"); } else { //all good, review window displayed GameManager.i.inputScript.ModalReviewState = ModalReviewSubState.Open; votesFor = details.votesFor; votesAgainst = details.votesAgainst; votesAbstained = details.votesAbstained; ModalStateData package = new ModalStateData() { mainState = ModalSubState.Review }; GameManager.i.inputScript.SetModalState(package); Debug.LogFormat("[UI] ModalInventoryUI.cs -> SetInventoryUI{0}", "\n"); //flash review button isFlashReviewButton = true; StartCoroutine("ReviewButton"); } }
/// <summary> /// Click confirm, carry out Team insert and exit picker /// </summary> private void ProcessTeamChoice() { modalTeamObject.SetActive(false); GameManager.i.guiScript.SetIsBlocked(false); //deselect all teams to prevent picker opening next time with a preselected team EventManager.i.PostNotification(EventType.DeselectOtherTeams, this, null, "ModalTeamPicker.cs -> ProcessTeamChoice"); //set game state /*GameManager.instance.inputScript.GameState = GameState.Normal;*/ GameManager.i.inputScript.ResetStates(); /*Debug.LogFormat("[UI] ModalTeamPicker -> ModalTeamPicker" + "\n"));*/ Debug.Log(string.Format("TeamPicker: Confirm teamID {0}{1}", teamIDSelected, "\n")); //insert team if (teamIDSelected > -1) { GameManager.i.teamScript.MoveTeam(TeamPool.OnMap, teamIDSelected, teamActorSlotID, teamNode); } else { Debug.LogError(string.Format("Invalid teamIDSelected \"{0}\" -> insert team operation cancelled", teamIDSelected)); } //outcome dialogue windows ModalOutcomeDetails details = new ModalOutcomeDetails(); details.side = GameManager.i.globalScript.sideAuthority; bool successFlag = true; if (teamIDSelected > -1) { details.textTop = GameManager.i.effectScript.SetTopTeamText(teamIDSelected); Actor actor = GameManager.i.dataScript.GetCurrentActor(teamActorSlotID, GameManager.i.globalScript.sideAuthority); if (actor != null) { details.textBottom = GameManager.i.effectScript.SetBottomTeamText(actor); } else { successFlag = false; } Team team = GameManager.i.dataScript.GetTeam(teamIDSelected); if (team != null) { TeamInteraction teamInteract = arrayOfTeamOptions[team.arc.TeamArcID].GetComponent <TeamInteraction>(); if (teamInteract != null) { details.sprite = teamInteract.teamImage.sprite; } else { successFlag = false; } } else { successFlag = false; } } //something went wrong, default message if (successFlag == false) { details.textTop = "There have been unexplained delays and no team has been inserted"; details.textBottom = "As soon as you've identified who is at fault heads will roll"; details.sprite = GameManager.i.spriteScript.errorSprite; } //action expended if successful if (successFlag == true) { details.isAction = true; details.reason = "Team Picker"; } //fire up Outcome dialogue EventManager.i.PostNotification(EventType.OutcomeOpen, this, details, "ModalTeamPicker.cs -> ProcessTeamChoice"); }