Example #1
0
        void OnEnable()
        {
            ConditionalEvent conditionalEvent = EventEditorPanel.eventToEdit;

            if (conditionalEvent == null)
            {
                conditionalEvent = CharacterEditor.Instance.CurrentEvent();
            }

            switch (eventType)
            {
            case EventType.typeSubject:
                parameterBuilder = SubjectParameterBuilder.Instance;
                parameters       = conditionalEvent.subjects;
                break;

            case EventType.typeCondition:
                parameterBuilder = ConditionParameterBuilder.Instance;
                parameters       = conditionalEvent.conditions;
                break;

            case EventType.typeEvent:
                parameterBuilder = EventParameterBuilder.Instance;
                parameters       = conditionalEvent.events;
                break;
            }
            UpdateParamsList();
            UpdateTypesDropdown();
            CheckParameterChanges();
            UpdateParameter();
        }
Example #2
0
        // Add frame based events
        public void AddKeyframeEvent(uint keyframe, ConditionalEvent <GameEntityModel> e)
        {
            List <ConditionalEvent <GameEntityModel> > frameEvents;

            if (!keyframeEvents.TryGetValue(keyframe, out frameEvents))
            {
                frameEvents = new List <ConditionalEvent <GameEntityModel> >(1);
                keyframeEvents.Add(keyframe, frameEvents);
            }
            frameEvents.Add(e);
        }
Example #3
0
//		void OnDropdownAnimationSelected(int itemId){
//
//		}

//		void OnListAnimationSelected(int itemId){
//
//		}



        public void OnAddButton()
        {
            // Find selected anim
            CharacterAnimation selectedAnim = GetAnimationFromDropdown();
            // Find selected event
            ConditionalEvent selectedEvent = allEventsSorted[_eventsList.SelectedItem];

            // Clone event and add to animation
            selectedAnim.events.Add(selectedEvent.Clone());
            allEvents[selectedEvent].Add(selectedAnim);

            // Refresh UI
            RefreshAnimationsList();
            RefreshAnimationsDropdown();
        }
Example #4
0
//		void OnDropdownObjectSelected(int itemId){
//
//		}

//		void OnListObjectSelected(int itemId){
//
//		}



        public void OnAddButton()
        {
            // Find selected anim
            HUDObject selectedAnim = GetObjectFromDropdown();
            // Find selected event
            ConditionalEvent selectedEvent = allEventsSorted[_eventsList.SelectedItem];

            // Clone event and add to object
            selectedAnim.events.Add(selectedEvent.Clone());
            allEvents[selectedEvent].Add(selectedAnim);

            // Refresh UI
            RefreshObjectsList();
            RefreshObjectsDropdown();
        }
Example #5
0
        void ApplyEventModifications()
        {
            // replace old event with new event on all animations containing it
            ConditionalEvent         oldEvent = allEventsSorted[_eventsList.SelectedItem];
            ConditionalEventComparer comparer = new ConditionalEventComparer();

            foreach (CharacterAnimation anim in allEvents[oldEvent])
            {
                for (int i = 0; i < anim.events.Count; ++i)
                {
                    if (comparer.Equals(oldEvent, anim.events[i]))
                    {
                        anim.events[i] = EventEditorPanel.eventToEdit.Clone();
                        break;
                    }
                }
            }
            EventEditorPanel.eventToEdit = null;
            CharacterEditor.Instance.RefreshEvents();
        }
Example #6
0
        void RefreshAnimationsList()
        {
            if (allEventsSorted.Count == 0)
            {
                _removeButton.interactable = false;
                return;
            }
            ConditionalEvent          selectedEvent = allEventsSorted[_eventsList.SelectedItem];
            List <string>             newOptions    = new List <string>();
            List <CharacterAnimation> eventAnims;

            if (allEvents.TryGetValue(selectedEvent, out eventAnims))
            {
                foreach (CharacterAnimation anim in eventAnims)
                {
                    newOptions.Add(anim.name);
                }
                _animationsList.Options = newOptions;
            }
            _removeButton.interactable = _animationsList.OptionsCount > 0;
        }
Example #7
0
        void OnEnable()
        {
            ConditionalEvent conditionalEvent = EventEditorPanel.eventToEdit;

            if (conditionalEvent == null)
            {
                conditionalEvent = HUDEditor.Instance.CurrentEvent();
            }

            if (isCondition)
            {
                parameterBuilder = ConditionParameterBuilder.Instance;
                parameters       = conditionalEvent.conditions;
            }
            else
            {
                parameterBuilder = EventParameterBuilder.Instance;
                parameters       = conditionalEvent.events;
            }
            UpdateParamsList();
            UpdateTypesDropdown();
        }
Example #8
0
        void RefreshAnimationsDropdown()
        {
            Character character = CharacterEditor.Instance.character;

            if (character == null || allEventsSorted.Count == 0)
            {
                return;
            }
            ConditionalEvent selectedEvent = allEventsSorted[_eventsList.SelectedItem];

            _animationsDropdown.ClearOptions();
            List <CharacterAnimation> eventAnims = allEvents[selectedEvent];

            foreach (CharacterAnimation anim in character.animations)
            {
                if (!eventAnims.Contains(anim))
                {
                    _animationsDropdown.options.Add(new Dropdown.OptionData(anim.name));
                }
            }
            _addButton.interactable = _animationsDropdown.options.Count > 0;
            _animationsDropdown.RefreshShownValue();
        }
Example #9
0
        void RefreshObjectsDropdown()
        {
            HUD hud = HUDEditor.Instance.hud;

            if (hud == null || allEventsSorted.Count == 0)
            {
                return;
            }
            ConditionalEvent selectedEvent = allEventsSorted[_eventsList.SelectedItem];

            _objectsDropdown.ClearOptions();
            List <HUDObject> eventAnims = allEvents[selectedEvent];

            foreach (HUDObject anim in hud.objects)
            {
                if (!eventAnims.Contains(anim))
                {
                    _objectsDropdown.options.Add(new Dropdown.OptionData(anim.name));
                }
            }
            _addButton.interactable = _objectsDropdown.options.Count > 0;
            _objectsDropdown.RefreshShownValue();
        }
Example #10
0
        // TODO: pass a maxCount to avoid previous subjects to referenciate later subjects
        public string[] AvailableSubjects(int maxCount = -1)
        {
            ConditionalEvent eventToEdit = EventEditorPanel.eventToEdit;

            if (eventToEdit == null)
            {
                eventToEdit = CurrentEvent();
            }
            if (eventToEdit == null)
            {
                return(null);
            }
            string[] defaultSubjects = SubjectParameterBuilder.predefinedSubjectsList;
            string[] extraSubjects   = eventToEdit.SubjectsToString(maxCount);
            string[] res             = defaultSubjects;
            if (extraSubjects != null && extraSubjects.Length > 0)
            {
                res = new string[defaultSubjects.Length + extraSubjects.Length];
                defaultSubjects.CopyTo(res, 0);
                extraSubjects.CopyTo(res, defaultSubjects.Length);
            }
            return(res);
        }
Example #11
0
        public void OnRemoveButton()
        {
            // Find selected anim
            CharacterAnimation selectedAnim = GetAnimationFromList();
            // Find selected event
            ConditionalEvent selectedEvent = allEventsSorted[_eventsList.SelectedItem];
            // Find the event on the anim and remove it
            ConditionalEventComparer comparer = new ConditionalEventComparer();

            for (int i = 0; i < selectedAnim.events.Count; ++i)
            {
                if (comparer.Equals(selectedEvent, selectedAnim.events[i]))
                {
                    selectedAnim.events.RemoveAt(i);
                    break;
                }
            }

            allEvents[selectedEvent].Remove(selectedAnim);

            // Refresh UI
            RefreshAnimationsList();
            RefreshAnimationsDropdown();
        }
Example #12
0
 // Add general event
 public void AddGeneralEvent(ConditionalEvent <GameEntityModel> e)
 {
     generalEvents.Add(e);
 }