Пример #1
0
    /// <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)
    {
        //select event type
        switch (eventType)
        {
        case EventType.OpenTeamPicker:
            ModalActionDetails details = Param as ModalActionDetails;
            SetTeamPicker(details);
            break;

        case EventType.CloseTeamPicker:
            CloseTeamPicker();
            break;

        case EventType.ChangeColour:
            SetColours();
            break;

        case EventType.ConfirmTeamActivate:
            SetConfirmButton(true, (int)Param);
            break;

        case EventType.ConfirmTeamDeactivate:
            SetConfirmButton(false);
            break;

        case EventType.ConfirmTeamChoice:
            ProcessTeamChoice();
            break;

        default:
            Debug.LogError(string.Format("Invalid eventType {0}{1}", eventType, "\n"));
            break;
        }
    }
Пример #2
0
 /// <summary>
 /// If using multiple nested option windows you need to call this prior to using a back button to ensure it has the details needed to pass through
 /// to the previous window
 /// </summary>
 /// <param name="details"></param>
 public void InitialiseNestedOptions(ModalActionDetails details)
 {
     if (details != null)
     {
         nestedDetails = details;
     }
     else
     {
         Debug.LogError("Invalid ModalActionDetails (null)");
     }
 }
Пример #3
0
    /// <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");
    }