Ejemplo n.º 1
0
    private void HandleEvent(AnimationEventObject eObject, float duration)
    {
        switch (eObject.eventType)
        {
        case TargetType.WeaponAbstract:
            _characterMaster.weapon?.ReceiveAnimationEvent(eObject, duration);
            break;

        default:
            Debug.LogError($"{nameof(AnimationManager)} doesn't know event type ${eObject.eventType}");
            break;
        }
    }
Ejemplo n.º 2
0
 /// <summary> Receives events from weapon animations. </summary>
 /// <param name="e"> The object sent from the animation </param>
 /// <param name="duration"> An optional duration that some events need </param>
 public void ReceiveAnimationEvent(AnimationEventObject e, float duration)
 {
     if (primaryAttack.state == AttackState.Ended)
     {
         return;
     }
     if (e == _animEventObjs.attackFadeIn && primaryAttack.state == AttackState.WindingUp)
     {
         FadeAttackIn(duration);
     }
     else if (e == _animEventObjs.attackAttackingStart && primaryAttack.state == AttackState.WindingUp)
     {
         primaryAttack.BeginAttacking();
     }
     else if (e == _animEventObjs.attackAttackingEnd && primaryAttack.state == AttackState.Attacking)
     {
         primaryAttack.BeginRecovering();
     }
     else if (e == _animEventObjs.attackFadeOut && primaryAttack.state == AttackState.Recovering)
     {
         primaryAttack.EndAttack(duration);
     }
 }
Ejemplo n.º 3
0
 public void HandleEvent(AnimationEventObject eObject)
 {
     HandleEvent(eObject, 0);
 }
Ejemplo n.º 4
0
    public void HandleEventWithDuration(AnimationEvent e)
    {
        AnimationEventObject eObject = e.objectReferenceParameter as AnimationEventObject;

        HandleEvent(eObject, e.floatParameter);
    }
Ejemplo n.º 5
0
        public static AnimationEventObject AnimationEventPopupLine(ICEWorldBehaviour _component, AnimationEventObject _event, BehaviourEventInfo[] _behaviour_events, ref bool _custom, string _help = "", string _title = "", string _hint = "")
        {
            if (_custom || _behaviour_events.Length == 0)
            {
                //_event.ComponentName = "";
                _event.MethodName = ICEEditorLayout.Text(_title, _hint, _event.MethodName, "");
                int indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                _event.ParameterType  = (AnimationEventParameterType)EditorGUILayout.EnumPopup(_event.ParameterType, GUILayout.Width(60));
                EditorGUI.indentLevel = indent;

                _custom = true;
            }
            else
            {
                string[] _array = new string[_behaviour_events.Length + 1];
                _array[0] = " ";

                for (int i = 0; i < _behaviour_events.Length; i++)
                {
                    _array[i + 1] = _behaviour_events[i].Key;
                }

                int _selected = ICEEditorLayout.Popup(_title, _hint, EditorTools.StringToIndex(_component.name + "." + _event.MethodName, _array), _array, "");

                if (_selected == 0)
                {
                    _event.Reset();
                }
                else
                {
                    for (int i = 0; i < _behaviour_events.Length; i++)
                    {
                        if (_behaviour_events[i].Key == _array[_selected])
                        {
                            _event.SetInfo(_behaviour_events[i]);
                        }
                    }
                }
            }


            EditorGUI.BeginDisabledGroup(_behaviour_events.Length == 0);
            _custom = ICEEditorLayout.CheckButtonMiddle("CUSTOM", "", _custom);
            EditorGUI.EndDisabledGroup();

            return(_event);
        }
Ejemplo n.º 6
0
        public static void DrawAnimationEventData(ICEWorldBehaviour _component, AnimationEventsObject _events, AnimationClip _clip, EditorHeaderType _type, string _help = "", string _title = "", string _hint = "")
        {
            if (_events == null || _clip == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(_title))
            {
                _title = "Animation Events";
            }
            if (string.IsNullOrEmpty(_hint))
            {
                _hint = "";
            }
            if (string.IsNullOrEmpty(_help))
            {
                _help = Info.ANIMATION_EVENTS;
            }

            ICEEditorLayout.BeginHorizontal();

            if (IsEnabledFoldoutType(_type))
            {
                EditorGUI.BeginDisabledGroup(_events.Enabled == false);
            }

            DrawObjectHeaderLine(_events, GetSimpleFoldout(_type), _title, _hint);

            EditorGUI.BeginDisabledGroup(_events.Enabled == false);
            if (ICEEditorLayout.AddButtonSmall(""))
            {
                _events.Events.Add(new AnimationEventObject());
            }

            EditorGUI.BeginDisabledGroup(_events.Events.Count == 0);
            if (ICEEditorLayout.ClearButtonSmall <AnimationEventObject>(_events, _events.Events, ""))
            {
                AnimationUtility.SetAnimationEvents(_clip, _events.GetAnimationEvents());
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.EndDisabledGroup();

            if (IsEnabledFoldoutType(_type))
            {
                EditorGUI.EndDisabledGroup();
                bool _enabled = ICEEditorLayout.EnableButton(_events.Enabled);

                if (_enabled != _events.Enabled)
                {
                    _events.Enabled = _enabled;
                    if (_events.Enabled == false)
                    {
                        AnimationUtility.SetAnimationEvents(_clip, new AnimationEvent[0]);
                    }
                }
            }
            ICEEditorLayout.EndHorizontal(_help);

            // CONTENT BEGIN
            if (BeginObjectContentOrReturn(_type, _events))
            {
                return;
            }

            AnimationEvent[] _clip_events = AnimationUtility.GetAnimationEvents(_clip);

            _events.UpdateAnimationEvents(_clip_events);

            for (int i = 0; i < _events.Events.Count; i++)
            {
                AnimationEventObject _animation_event = _events.Events[i];
                ICEEditorLayout.BeginHorizontal();


                _animation_event = WorldPopups.AnimationEventPopupLine(_component, _animation_event, _component.BehaviourEvents, ref _animation_event.UseCustomFunction, "", "Event #" + i, "");

                bool _active = ICEEditorLayout.CheckButtonMiddle("ACTIVE", "", _animation_event.IsActive);

                if (_active != _animation_event.IsActive)
                {
                    _animation_event.IsActive = _active;
                    AnimationUtility.SetAnimationEvents(_clip, _events.GetAnimationEvents());
                }

                if (ICEEditorLayout.ListDeleteButtonMini <AnimationEventObject>(_events.Events, _animation_event, "Removes this animation event."))
                {
                    AnimationUtility.SetAnimationEvents(_clip, _events.GetAnimationEvents());
                    return;
                }

                ICEEditorLayout.EndHorizontal(Info.ANIMATION_EVENTS_METHOD_POPUP);

                EditorGUI.indentLevel++;

                if (_animation_event.ParameterType == AnimationEventParameterType.Integer)
                {
                    _animation_event.ParameterInteger = ICEEditorLayout.Integer("Parameter Integer", "", _animation_event.ParameterInteger, Info.EVENT_PARAMETER_INTEGER);
                }
                else if (_animation_event.ParameterType == AnimationEventParameterType.Float)
                {
                    _animation_event.ParameterFloat = ICEEditorLayout.Float("Parameter Float", "", _animation_event.ParameterFloat, Info.EVENT_PARAMETER_FLOAT);
                }
                else if (_animation_event.ParameterType == AnimationEventParameterType.String)
                {
                    _animation_event.ParameterString = ICEEditorLayout.Text("Parameter String", "", _animation_event.ParameterString, Info.EVENT_PARAMETER_STRING);
                }

                _animation_event.Time = ICEEditorLayout.Slider("Time", "The time at which the event will be fired off.", _animation_event.Time, 0.0001f, 0, _clip.length, Info.ANIMATION_EVENTS_METHOD_TIME);

                EditorGUI.indentLevel--;
            }

            if (_events.UpdateRequired(_clip_events))
            {
                AnimationUtility.SetAnimationEvents(_clip, _events.GetAnimationEvents());
            }

            EndObjectContent();
            // CONTENT END
        }