// INITIALIZERS: --------------------------------------------------------------------------

        private void OnEnable()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }
            this.reaction = (QuestReaction)this.target;
        }
Beispiel #2
0
        // INITIALIZERS: --------------------------------------------------------------------------

        private void OnEnable()
        {
            this.reaction = (QuestReaction)this.target;
        }
Beispiel #3
0
        protected override void RowGUI(TreeView.RowGUIArgs args)
        {
            base.RowGUI(args);
            if (args.isRenaming)
            {
                return;
            }

            if (this.CanRename(args.item) && args.selected)
            {
                if (Event.current.type == EventType.ContextClick)
                {
                    this.BeginRename(args.item);
                    Event.current.Use();
                    return;
                }
            }

            Rect rectActionsFail = new Rect(
                args.rowRect.x + args.rowRect.width - ICON_INFO_WIDTH,
                args.rowRect.y,
                ICON_INFO_WIDTH,
                args.rowRect.height
                );

            Rect rectActionsComplete = new Rect(
                rectActionsFail.x - ICON_INFO_WIDTH,
                args.rowRect.y,
                ICON_INFO_WIDTH,
                args.rowRect.height
                );

            Rect rectConditions = new Rect(
                rectActionsComplete.x - ICON_INFO_WIDTH,
                args.rowRect.y,
                SETTINGS_BTN_WIDTH,
                args.rowRect.height
                );

            if (!this.databaseQuestsEditor.questsEditors.ContainsKey(args.item.id))
            {
                return;
            }
            IQuestEditor iquestEditor = this.databaseQuestsEditor.questsEditors[args.item.id];

            QuestReaction reaction = iquestEditor.iquest.reactions;

            if (reaction == null)
            {
                return;
            }

            GUIContent contentFail = QuestTreeUtils.GetIcon((
                                                                reaction.onFail != null && reaction.onFail.actions.Length > 0
                ? QuestTreeUtils.Icon.OnFail
                : QuestTreeUtils.Icon.OffFail
                                                                ));

            GUIContent contentComplete = QuestTreeUtils.GetIcon((
                                                                    reaction.onComplete != null && reaction.onComplete.actions.Length > 0
                                ? QuestTreeUtils.Icon.OnComplete
                                : QuestTreeUtils.Icon.OffComplete
                                                                    ));

            GUIContent contentConditions = QuestTreeUtils.GetIcon((
                                                                      reaction.conditions != null && reaction.conditions.conditions.Length > 0
                                ? QuestTreeUtils.Icon.OnConditions
                                : QuestTreeUtils.Icon.OffConditions
                                                                      ));

            EditorGUI.LabelField(rectActionsFail, contentFail);
            EditorGUI.LabelField(rectActionsComplete, contentComplete);
            EditorGUI.LabelField(rectConditions, contentConditions);

            if (EditorApplication.isPlaying)
            {
                args.item.icon = iquestEditor.GetIcon();
            }

            Rect rectSettings = new Rect(
                rectConditions.x - SETTINGS_BTN_WIDTH - 5f,
                args.rowRect.y,
                SETTINGS_BTN_WIDTH,
                args.rowRect.height
                );

            if (!EditorApplication.isPlaying && this.IsSelected(args.item.id))
            {
                if (GUI.Button(rectSettings, GUICONTENT_EDIT, EditorStyles.miniButton))
                {
                    QuestConfigWindow.Open(iquestEditor);
                }
            }
            else if (iquestEditor.ShowProgress())
            {
                float progress = iquestEditor.GetProgress();
                Rect  rectBkg  = new Rect(
                    rectSettings.x + PROG_PADDING,
                    rectSettings.y + (rectSettings.height / 2.0f - PROG_HEIGHT / 2.0f),
                    rectSettings.width - (2f * PROG_PADDING),
                    PROG_HEIGHT
                    );
                Rect rectBar = new Rect(
                    rectBkg.x,
                    rectBkg.y,
                    rectBkg.width * progress,
                    rectBkg.height
                    );

                EditorGUI.DrawRect(rectBkg, EditorApplication.isPlaying ? PROG_BCK_R : PROG_BCK_E);
                EditorGUI.DrawRect(rectBar, EditorApplication.isPlaying ? PROG_BAR_R : PROG_BAR_E);
            }
        }