Пример #1
0
        /// <summary>
        /// Creates a new team of a particular TeamArcType, eg. "Security". natoCount is used to determine Nato nomlecture, eg. 'Alpha/Bravo/Charlie'
        /// </summary>
        /// <param name="arcType"></param>
        public Team(string arcType, int natoCount)
        {
            //valid arcType
            int teamArcID = GameManager.i.dataScript.GetTeamArcID(arcType);

            if (teamArcID > -1)
            {
                //get teamArc
                TeamArc teamArc = GameManager.i.dataScript.GetTeamArc(teamArcID);
                if (teamArc != null)
                {
                    teamID = GameManager.i.teamScript.teamIDCounter++;
                    arc    = teamArc;
                    InitialiseTeamData(natoCount);
                    AddToCollections(this);
                }
                else
                {
                    Debug.LogError(string.Format("TeamArc type \"{0}\", ID {1}, not found in dictionary -> Team not created{2}", arcType, teamArcID, "\n"));
                }
            }
            else
            {
                Debug.LogError(string.Format("TeamArc type \"{0}\" not found in dictionary -> Team not created{1}", arcType, "\n"));
            }
        }
Пример #2
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");
        }
    }