Esempio n. 1
0
        public override void OnEnter()
        {
            string text = i18nContents.Value;

            if (UseDialogList && dialogList != null)
            {
                text = dialogList.Entries[dialogListIndex].ContentToken;
            }
            if (!string.IsNullOrEmpty(text))
            {
                EventDispatcher          eventDispatcher = Service.Get <EventDispatcher>();
                HudEvents.SetSubtaskText evt             = default(HudEvents.SetSubtaskText);
                evt.ID = ((!SubtaskId.IsNone) ? SubtaskId.Value : text);
                string tokenTranslation = Service.Get <Localizer>().GetTokenTranslation(text);
                if (!IntegerCount.IsNone && !Integer.IsNone)
                {
                    int num = Mathf.Clamp(Integer.Value, 0, IntegerCount.Value);
                    evt.SubtaskText = $"{num}/{IntegerCount.Value} {tokenTranslation}";
                    evt.IsComplete  = num == IntegerCount.Value;
                }
                else if (!Bool.IsNone)
                {
                    evt.SubtaskText = tokenTranslation;
                    evt.IsComplete  = Bool.Value;
                }
                eventDispatcher.DispatchEvent(evt);
            }
            Finish();
        }
    private bool onSubtaskTextSet(HudEvents.SetSubtaskText evt)
    {
        QuestSubtask questSubtask = null;

        if (SubtaskCount > 0)
        {
            QuestSubtask[] componentsInChildren = SubtaskDropDownPanel.GetComponentsInChildren <QuestSubtask>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                if (componentsInChildren[i].ID == evt.ID)
                {
                    questSubtask = componentsInChildren[i];
                    break;
                }
            }
        }
        if (questSubtask == null)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate(SubtaskTickPanelPrefab, SubtaskDropDownPanel.transform, worldPositionStays: false);
            questSubtask    = gameObject.GetComponentInChildren <QuestSubtask>();
            questSubtask.ID = evt.ID;
            MascotDefinition definition = Service.Get <QuestService>().ActiveQuest.Mascot.Definition;
            if (definition != null)
            {
                Color navigationArrowColor = definition.NavigationArrowColor;
                questSubtask.SetTickColor(navigationArrowColor);
                questSubtask.SetTickOutlineColor(navigationArrowColor);
            }
            SubtaskCount++;
        }
        questSubtask.SubtaskText.text = evt.SubtaskText;
        if (questSubtask.TickToggle != null)
        {
            Service.Get <iOSHapticFeedback>().TriggerNotificationFeedback(iOSHapticFeedback.NotificationFeedbackType.Success);
            questSubtask.TickToggle.isOn = evt.IsComplete;
        }
        if (this.SubtasksChanged != null)
        {
            this.SubtasksChanged();
        }
        return(false);
    }