/// <summary>
    /// show AI display
    /// </summary>
    public void SetAIDisplay()
    {
        //close side tab
        EventManager.i.PostNotification(EventType.AISideTabClose, this, null, "AIDisplayUI.cs -> SetAIDisplay");
        //Power panel on/off
        if (isFree == true)
        {
            powerPanel.gameObject.SetActive(false);
            tabBottomText.text = tabBottomTextCache;
            SetDetectedFlasher(false);
        }
        else
        {
            //get any relevant player modifiers
            GameManager.i.aiScript.UpdatePlayerHackingLists();
            //gear text
            gearText.text = GameManager.i.aiScript.UpdateGearText();
            //open UI
            powerPanel.gameObject.SetActive(true);
        }
        //switch on display
        aiDisplayObject.SetActive(true);
        //set modal status
        GameManager.i.guiScript.SetIsBlocked(true);
        //turn off any alert message
        GameManager.i.alertScript.CloseAlertUI(true);
        //set game state
        ModalStateData package = new ModalStateData();

        package.mainState = ModalSubState.InfoDisplay;
        package.infoState = ModalInfoSubState.AIInfo;
        GameManager.i.inputScript.SetModalState(package);
    }
Beispiel #2
0
    /// <summary>
    /// Restore from ShowMe. Button deactivated in place of Confirm button
    /// </summary>
    private void ExecuteRestore()
    {
        //set Game State
        ModalStateData package = new ModalStateData();

        package.mainState = ModalSubState.Outcome;
        GameManager.i.inputScript.SetModalState(package);
        //alert message
        GameManager.i.alertScript.CloseAlertUI();
        //swap buttons
        confirmButtonNormal.gameObject.SetActive(true);
        showMeButtonNormal.gameObject.SetActive(false);
        //turn ModalOutcome back on
        outcomeObject.SetActive(true);
    }
Beispiel #3
0
 /// <summary>
 /// Open City Info display
 /// </summary>
 private void SetCityInfo(City city)
 {
     if (city != null)
     {
         //exit any generic or node tooltips
         GameManager.i.tooltipGenericScript.CloseTooltip("CityInfoUI.cs -> SetCityInfo");
         GameManager.i.tooltipNodeScript.CloseTooltip("CityInfoUI.cs -> SetCityInfo");
         //close any Alert Message
         GameManager.i.alertScript.CloseAlertUI(true);
         //populate data
         cityName.text        = city.tag;
         cityArc.text         = city.Arc.name;
         cityDescription.text = city.descriptor;
         //district details -> keep in this order (GetDistrictNames initialises data for GetDistrictTotals)
         districtNames.text  = GetDistrictNames(city);
         districtTotals.text = GetDistrictTotals();
         //centre panel -> mayor / faction / organisation
         if (city.mayor != null)
         {
             mayorName.text = city.mayor.mayorName;
             if (city.mayor.GetTrait() != null)
             {
                 mayorTrait.text = city.mayor.GetTrait().tagFormatted;
             }
             else
             {
                 mayorTrait.text = "Unknown";
             }
         }
         else
         {
             mayorName.text = "Unknown";
         }
         factionName.text   = GameManager.i.hqScript.GetHqName(globalAuthority, false);
         factionTrait.text  = GameManager.i.hqScript.GetHqDescription(globalAuthority);
         organisations.text = GameManager.i.cityScript.GetNumOfOrganisations();
         //city image (uses arc sprite, GUIManager.cs default sprite if arc sprite is null)
         if (city.Arc.sprite != null)
         {
             cityImage.sprite = city.Arc.sprite;
         }
         else
         {
             cityImage.sprite = GameManager.i.spriteScript.cityArcDefaultSprite;
         }
         Debug.Assert(cityImage.sprite != null, "Invalid city Arc default sprite");
         //Organisation tooltip
         mayorTooltip.tooltipHeader         = GameManager.i.cityScript.GetMayorNameFormatted();
         mayorTooltip.tooltipMain           = GameManager.i.cityScript.GetMayorTraitFormatted();
         mayorTooltip.tooltipDetails        = GameManager.i.cityScript.GetMayorFactionFormatted();
         mayorTooltip.x_offset              = 25;
         factionTooltip.tooltipHeader       = GameManager.i.hqScript.GetHqName(globalAuthority);
         factionTooltip.tooltipMain         = GameManager.i.hqScript.GetHqDescription(globalAuthority);
         factionTooltip.tooltipDetails      = GameManager.i.hqScript.GetHqDetails(globalAuthority);
         factionTooltip.x_offset            = 25;
         organisationTooltip.tooltipHeader  = GameManager.i.cityScript.GetCityNameFormatted();
         organisationTooltip.tooltipDetails = GameManager.i.cityScript.GetOrganisationsTooltip();
         organisationTooltip.x_offset       = 25;
         //activate main panel
         cityInfoObject.SetActive(true);
         //set modal status
         GameManager.i.guiScript.SetIsBlocked(true);
         //set game state
         ModalStateData package = new ModalStateData();
         package.mainState = ModalSubState.InfoDisplay;
         package.infoState = ModalInfoSubState.CityInfo;
         GameManager.i.inputScript.SetModalState(package);
         Debug.LogFormat("[UI] CityInfoUI.cs -> SetCityInfo{0}", "\n");
     }
     else
     {
         Debug.LogWarning("Invalid city (Null) -> tooltip cancelled");
     }
 }
    /// <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");
        }
    }
Beispiel #5
0
    /// <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>
    /// 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");
    }
Beispiel #7
0
    /// <summary>
    /// Open Advert
    /// </summary>
    private IEnumerator OpenAdvert(Billboard billboard)
    {
        /*int counter;*/
        textTop.text    = ProcessAdvertTextTop(billboard);
        textBottom.text = billboard.textBottom.ToUpper();
        /*textName.text = GameManager.i.playerScript.FirstName.ToUpper();*/
        if (billboard.sprite != null)
        {
            logo.sprite = billboard.sprite;
            logo.gameObject.SetActive(true);
        }
        else
        {
            logo.gameObject.SetActive(false);
        }

        #region name Archive

        /*
         * //any longer than set num of char's will cause issues with pulsing, use a default text instead
         * if (textName.text.Length > maxNameChars)
         * { textName.text = "Yes YOU!"; }
         * //determine parameters for name text font size pulsing (max size is current max size feasible in space)
         * fontSizeMax = textName.fontSize;
         * fontSizeCurrent = fontSizeMax;
         * fontSizeState = Pulsing.Fading;
         * fontSizeCounter = 0.0f;
         */
        #endregion

        //set states
        ModalStateData package = new ModalStateData()
        {
            mainState = ModalSubState.Advert
        };
        GameManager.i.inputScript.SetModalState(package);
        GameManager.i.guiScript.SetIsBlocked(true);
        Debug.LogFormat("[UI] AdvertUI.cs -> OpenAdvert{0}", "\n");
        //open canvas
        advertCanvas.gameObject.SetActive(true);

        /*SetAdvertCentre(true);
         * counter = 0;*/

        //indefinitely strobe outer panel (cyan neon borders)
        /*isFading = true;*/

        #region while archive

        /*while (true)
         * {
         *  // - - - Strobe outer panel
         *  outerColour = outerPanel.color;
         *  if (isFading == false)
         *  {
         *      outerColour.a += Time.deltaTime / flashBorder;
         *      if (outerColour.a >= 1.0f)
         *      {
         *          isFading = true;
         *          counter = 0;
         *      }
         *  }
         *  else
         *  {
         *      if (counter == 0)
         *      {
         *          outerColour.a -= Time.deltaTime / flashBorder;
         *          if (outerColour.a <= 0.0f)
         *          { counter++; }
         *      }
         *      else
         *      {
         *          //when panel at 0 alpha, pause before repeating
         *          if (counter > 120)
         *          { isFading = false; }
         *          else { counter++; }
         *      }
         *  }
         *  outerPanel.color = outerColour;
         *  /*
         *  //Name text font size Pulsing
         *  switch (fontSizeState)
         *  {
         *      case Pulsing.Constant:
         *          //pause pulsing at max font size for a short moment
         *          fontSizeCounter += Time.deltaTime;
         *          if (fontSizeCounter > fontSizeCounterMax)
         *          {
         *              fontSizeState = Pulsing.Fading;
         *              fontSizeCounter = 0.0f;
         *          }
         *          break;
         *      case Pulsing.Growing:
         *          //grow at a faster rate than shrinking
         *          fontSizeCurrent += fontSizeCurrent * Time.deltaTime * fontSizeSpeed * fontSizeBoost;
         *          if (fontSizeCurrent >= fontSizeMax)
         *          {
         *              fontSizeState = Pulsing.Constant;
         *              //make sure fontsize doesn't momentarily go over the max and be outside the displayable area
         *              fontSizeCurrent = Mathf.Min(fontSizeCurrent, fontSizeMax);
         *          }
         *          break;
         *      case Pulsing.Fading:
         *          //shrinking
         *          fontSizeCurrent -= fontSizeCurrent * Time.deltaTime * fontSizeSpeed;
         *          if (fontSizeCurrent <= fontSizeMin)
         *          {
         *              fontSizeCurrent = Mathf.Max(0.0f, fontSizeCurrent);
         *              fontSizeState = Pulsing.Growing;
         *          }
         *          break;
         *      default: Debug.LogWarningFormat("Unrecognised fontSizeState \"{0}\"", fontSizeState); break;
         *  }
         *  //adjust font size
         *  textName.fontSize = fontSizeCurrent;
         *
         *  yield return null;
         * }*/
        #endregion

        yield return(null);
    }
Beispiel #8
0
    /// <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");
        }
    }
Beispiel #9
0
    /// <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)");
        }
    }
Beispiel #10
0
    /// <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)");
        }
    }
Beispiel #11
0
    /// <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");
        }
    }
Beispiel #12
0
    /// <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");
    }