예제 #1
0
        public override void Setup(OfflineRulesProcessor rulesProcessor)
        {
            base.Setup(rulesProcessor);

            if (this.m_RulesProcessor != null)
            {
                m_SinglePlayerRulesProcessor = this.m_RulesProcessor as SinglePlayerRulesProcessor;

                Objective[] objectives = m_SinglePlayerRulesProcessor.objectiveInstances;

                int lengthOfArray = objectives.Length;
                //Display the objectives: Primary first then Secondary
                CreateHeading("PRIMARY");
                for (int i = 0; i < lengthOfArray; i++)
                {
                    if (i == 1)
                    {
                        CreateHeading("SECONDARY");
                    }
                    ObjectiveUI newObjectiveUi = Instantiate <ObjectiveUI>(i == 0 ? m_PrimaryObjectiveUiElement : m_ObjectiveUiElement);
                    newObjectiveUi.transform.SetParent(m_ObjectiveList, false);
                    newObjectiveUi.Setup(objectives[i], false);
                }

                m_LevelName.text = m_SinglePlayerRulesProcessor.GetRoundMessage().ToUpper();
            }
        }
예제 #2
0
        /// <summary>
        /// Displays this HUD element.
        /// </summary>
        /// <param name="rulesProcessor">The rules processor for the active mission.</param>
        public void ShowHud(RulesProcessor rulesProcessor)
        {
            //If we haven't already, subscribe to all the necessary events.
            Subscribe();
            this.m_RulesProcessor = rulesProcessor as SinglePlayerRulesProcessor;

            if (this.m_RulesProcessor == null)
            {
                Debug.LogError("Tried to show single player HUD in non-singleplayer game!!!");
                return;
            }

            gameObject.SetActive(true);
            m_SecondaryObjectives.Clear();

            //Iterate through objectives for this mission and instantiate the prompts accordingly.
            Objective[] objectives = this.m_RulesProcessor.objectiveInstances;

            int lengthOfArray = objectives.Length;

            for (int i = 0; i < lengthOfArray; i++)
            {
                Objective objective = objectives[i];
                if (objective.isPrimaryObjective)
                {
                    ObjectiveUI newObjectiveUi = Instantiate <ObjectiveUI>(m_ObjectiveUiElement);
                    newObjectiveUi.transform.SetParent(m_ObjectiveParent, false);
                    newObjectiveUi.Setup(objective);
                    newObjectiveUi.transform.SetAsFirstSibling();
                }
                else
                {
                    ObjectiveUI newObjectiveUi = Instantiate <ObjectiveUI>(m_SecondaryUiElement);
                    newObjectiveUi.transform.SetParent(m_ObjectiveParent, false);
                    newObjectiveUi.Setup(objective);
                    m_SecondaryObjectives.Add(newObjectiveUi.gameObject);
                }
            }
        }