예제 #1
0
    private void SubInitialiseSessionStart()
    {
        //assign sprites to team Images
        Dictionary <int, TeamArc> dictOfTeamArcs = GameManager.i.dataScript.GetDictOfTeamArcs();

        if (dictOfTeamArcs != null)
        {
            if (dictOfTeamArcs.Count != arrayOfTeamOptions.Length)
            {
                Debug.LogWarning(string.Format("dictOfTeamArcs.Count {0} != arrayOfTeamImages.Length {1}", dictOfTeamArcs.Count, arrayOfTeamOptions.Length));
            }
            else
            {
                int limit = Mathf.Min(dictOfTeamArcs.Count, arrayOfTeamOptions.Length);
                //limit = Mathf.Min(dictOfTeamArcs.Count, arrayOfTeamTexts.Length);
                for (int index = 0; index < limit; index++)
                {
                    //get TeamArc from dict based on index
                    TeamArc arc = null;
                    if (dictOfTeamArcs.ContainsKey(index) == true)
                    {
                        arc = dictOfTeamArcs[index];
                        TeamInteraction teamUI = arrayOfTeamOptions[index].GetComponent <TeamInteraction>();
                        if (teamUI != null)
                        {
                            //assign to sprite
                            teamUI.teamImage.sprite = arc.sprite;
                            //assign to text (name of teamArc)
                            teamUI.teamText.text = arc.name;
                        }
                        else
                        {
                            Debug.LogError("Invalid TeamChoiceUI component (Null)");
                        }
                    }
                    else
                    {
                        Debug.LogWarning(string.Format("Invalid arc index \"{0}\" for \"{1}\" -> No Sprite assigned", index, arc.name));
                    }
                }
            }
        }
        else
        {
            Debug.LogError("Invalid dictOfTeamArcs (null) -> Sprites not assigned to ModalTeamPicker");
        }
    }
예제 #2
0
    /// <summary>
    /// Click confirm, carry out Team insert and exit picker
    /// </summary>
    private void ProcessTeamChoice()
    {
        modalTeamObject.SetActive(false);
        GameManager.i.guiScript.SetIsBlocked(false);
        //deselect all teams to prevent picker opening next time with a preselected team
        EventManager.i.PostNotification(EventType.DeselectOtherTeams, this, null, "ModalTeamPicker.cs -> ProcessTeamChoice");
        //set game state
        /*GameManager.instance.inputScript.GameState = GameState.Normal;*/
        GameManager.i.inputScript.ResetStates();
        /*Debug.LogFormat("[UI] ModalTeamPicker -> ModalTeamPicker" + "\n"));*/
        Debug.Log(string.Format("TeamPicker: Confirm teamID {0}{1}", teamIDSelected, "\n"));
        //insert team
        if (teamIDSelected > -1)
        {
            GameManager.i.teamScript.MoveTeam(TeamPool.OnMap, teamIDSelected, teamActorSlotID, teamNode);
        }
        else
        {
            Debug.LogError(string.Format("Invalid teamIDSelected \"{0}\" -> insert team operation cancelled", teamIDSelected));
        }
        //outcome dialogue windows
        ModalOutcomeDetails details = new ModalOutcomeDetails();

        details.side = GameManager.i.globalScript.sideAuthority;

        bool successFlag = true;

        if (teamIDSelected > -1)
        {
            details.textTop = GameManager.i.effectScript.SetTopTeamText(teamIDSelected);
            Actor actor = GameManager.i.dataScript.GetCurrentActor(teamActorSlotID, GameManager.i.globalScript.sideAuthority);
            if (actor != null)
            {
                details.textBottom = GameManager.i.effectScript.SetBottomTeamText(actor);
            }
            else
            {
                successFlag = false;
            }
            Team team = GameManager.i.dataScript.GetTeam(teamIDSelected);
            if (team != null)
            {
                TeamInteraction teamInteract = arrayOfTeamOptions[team.arc.TeamArcID].GetComponent <TeamInteraction>();
                if (teamInteract != null)
                {
                    details.sprite = teamInteract.teamImage.sprite;
                }
                else
                {
                    successFlag = false;
                }
            }
            else
            {
                successFlag = false;
            }
        }
        //something went wrong, default message
        if (successFlag == false)
        {
            details.textTop    = "There have been unexplained delays and no team has been inserted";
            details.textBottom = "As soon as you've identified who is at fault heads will roll";
            details.sprite     = GameManager.i.spriteScript.errorSprite;
        }
        //action expended if successful
        if (successFlag == true)
        {
            details.isAction = true;
            details.reason   = "Team Picker";
        }
        //fire up Outcome dialogue
        EventManager.i.PostNotification(EventType.OutcomeOpen, this, details, "ModalTeamPicker.cs -> ProcessTeamChoice");
    }