/// <summary>
        /// Draw the GUI.
        /// </summary>
        public override void OnInspectorGUI()
        {
            myTarget = (EventResponder)target;

            Undo.RecordObject(target, "Event Update");
            GameObject sender = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Sender", "Add the Game Object that holds the target component."), myTarget.sender, typeof(GameObject), true);

            myTarget.sender = sender;
            if (myTarget.sender != null)
            {
                types = GetComponentsOnGameObject(myTarget.sender);
            }
            if (myTarget.sender == null)
            {
                myTarget.sender = myTarget.gameObject;
            }

            if (myTarget.sender != null)
            {
                string typeName = null;
                if (types == null)
                {
                    types = GetComponentsOnGameObject(myTarget.sender);
                }
                int typeIndex = System.Array.IndexOf(types, myTarget.typeName);
                if (typeIndex == -1 || typeIndex >= types.Length)
                {
                    typeIndex = 0;
                }
                if (types != null && types.Length > 0)
                {
                    typeName = types[EditorGUILayout.Popup("Component", typeIndex, types)];
                }
                else
                {
                    EditorGUILayout.HelpBox("No components found on this GameObject.", MessageType.Info);
                }

                myTarget.typeName = typeName;

                if (myTarget.typeName != null && myTarget.typeName.Length > 0)
                {
                    events = GetEventNamesForType(myTarget.typeName);
                    if (events != null && events.Length > 0)
                    {
                        int eventIndex = System.Array.IndexOf(events, myTarget.eventName);
                        if (eventIndex == -1 || eventIndex >= events.Length)
                        {
                            eventIndex = 0;
                        }
                        string name = events[EditorGUILayout.Popup("Event", eventIndex, events)];
                        myTarget.eventName = name;

                        type = typeof(Character).Assembly.GetType("PlatformerPro." + typeName);
                        if (type == null)
                        {
                            type = typeof(Character).Assembly.GetTypes().Where(t => t.Name == typeName).FirstOrDefault();
                        }
                        eventInfo     = type.GetEvent(myTarget.eventName);
                        parameterType = eventInfo.EventHandlerType.GetMethod("Invoke").GetParameters()[1].ParameterType;

                        // Animation event
                        if (parameterType != null && parameterType.IsAssignableFrom(typeof(AnimationEventArgs)))
                        {
                            myTarget.animationStateFilter = (AnimationState)EditorGUILayout.EnumPopup(new GUIContent("Animation State", "The animation state which will trigger this event response, use NONE for any state"),
                                                                                                      myTarget.animationStateFilter);
                        }
                        // Damage event
                        if (parameterType != null && parameterType.IsAssignableFrom(typeof(DamageInfoEventArgs)))
                        {
                            myTarget.damageTypeFilter = (DamageType)EditorGUILayout.EnumPopup(new GUIContent("Damage Type", "The damage type which will trigger this event response, use NONE for any type"),
                                                                                              myTarget.damageTypeFilter);
                        }
                        // Button event
                        if (parameterType != null && parameterType.IsAssignableFrom(typeof(ButtonEventArgs)))
                        {
                            myTarget.buttonStateFilter = (ButtonState)EditorGUILayout.EnumPopup(new GUIContent("Button State", "The button state which triggers this response, use ANY for any type"),
                                                                                                myTarget.buttonStateFilter);
                        }
                        // Phase event
                        if (parameterType != null && parameterType.IsAssignableFrom(typeof(PhaseEventArgs)))
                        {
                            myTarget.stringFilter = EditorGUILayout.TextField(new GUIContent("Phase", "Name of the phase or empty string for any phase."),
                                                                              myTarget.stringFilter);
                        }
                        // State event
                        if (parameterType != null && parameterType.IsAssignableFrom(typeof(StateEventArgs)))
                        {
                            myTarget.stringFilter = EditorGUILayout.TextField(new GUIContent("State", "Name of the state or empty string for any state."),
                                                                              myTarget.stringFilter);
                        }
                        // Attack event
                        if (parameterType != null && parameterType.IsAssignableFrom(typeof(AttackEventArgs)))
                        {
                            myTarget.stringFilter = EditorGUILayout.TextField(new GUIContent("Attack", "Name of the attack or empty string for any attack."),
                                                                              myTarget.stringFilter);
                        }
                        // Extra Damage event
                        if (parameterType != null && parameterType.IsAssignableFrom(typeof(ExtraDamageInfoEventArgs)))
                        {
                            myTarget.stringFilter = EditorGUILayout.TextField(new GUIContent("Attack", "Name of the attack or empty string for any attack."),
                                                                              myTarget.stringFilter);
                        }
                        // Item event
                        if (parameterType != null && parameterType.IsAssignableFrom(typeof(ItemEventArgs)))
                        {
                            myTarget.stringFilter = EditorGUILayout.TextField(new GUIContent("Item Type", "Name of the item type or empty for any item."), myTarget.stringFilter);
                            myTarget.intFilter    = EditorGUILayout.IntField(new GUIContent("Amount", "Minimum amount that must be in the inventory."), myTarget.intFilter);
                        }
                        // Activation event
                        if (parameterType != null && parameterType.IsAssignableFrom(typeof(ActivationEventArgs)))
                        {
                            myTarget.stringFilter = EditorGUILayout.TextField(new GUIContent("Item", "Name of the Activation Item or empty string for any item."),
                                                                              myTarget.stringFilter);
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No events found on this component.", MessageType.Info);
                    }
                }
            }

            if (myTarget.actions != null)
            {
                for (int i = 0; i < myTarget.actions.Length; i++)
                {
                    EditorGUILayout.BeginVertical("HelpBox");

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (i == 0)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Move Up", EditorStyles.miniButtonLeft))
                    {
                        EventResponse tmp = myTarget.actions[i - 1];
                        myTarget.actions[i - 1] = myTarget.actions[i];
                        myTarget.actions[i]     = tmp;
                        break;
                    }
                    GUI.enabled = true;
                    if (i == myTarget.actions.Length - 1)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Move Down", EditorStyles.miniButtonRight))
                    {
                        EventResponse tmp = myTarget.actions[i + 1];
                        myTarget.actions[i + 1] = myTarget.actions[i];
                        myTarget.actions[i]     = tmp;
                        break;
                    }
                    GUI.enabled = true;
                    // Remove
                    GUILayout.Space(4);
                    bool removed = false;
                    if (GUILayout.Button("Remove", EditorStyles.miniButton))
                    {
                        myTarget.actions = myTarget.actions.Where(a => a != myTarget.actions[i]).ToArray();
                        removed          = true;
                    }
                    GUILayout.EndHorizontal();
                    if (!removed)
                    {
                        RenderAction(myTarget, myTarget, myTarget.actions[i]);
                    }
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            // Add new actions
            if (GUILayout.Button("Add Action"))
            {
                if (myTarget.actions == null)
                {
                    myTarget.actions = new EventResponse[1];
                }
                else
                {
                    // Copy and grow array
                    EventResponse[] tmpActions = myTarget.actions;
                    myTarget.actions = new EventResponse[tmpActions.Length + 1];
                    System.Array.Copy(tmpActions, myTarget.actions, tmpActions.Length);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        /// <summary>
        /// Draws an event response action in the inspector.
        /// </summary>
        /// <param name="action">Action.</param>
        public static void RenderAction(object target, object repsonder, EventResponse action)
        {
            if (!(target is EventResponder || target is PowerUpManager))
            {
                Debug.LogWarning("Unexpected type passed to RenderAction()");
                return;
            }

            if (action == null)
            {
                action = new EventResponse();
            }

            // action.responseType = (EventResponseType) EditorGUILayout.EnumPopup( new GUIContent("Action Type", "The type of action to do when this event occurs."), action.responseType);
            // TODO No need to create this every update
            GUIContent[] popUps = new GUIContent[System.Enum.GetValues(typeof(EventResponseType)).Length];
            int          i      = 0;

            foreach (object t in System.Enum.GetValues(typeof(EventResponseType)))
            {
                popUps[i] = new GUIContent(((EventResponseType)t).GetName(), "");
                i++;
            }
            int actionIndex = (int)action.responseType;

            actionIndex         = EditorGUILayout.Popup(new GUIContent("Action Type", "The type of action to do when this event occurs."), actionIndex, popUps);
            action.responseType = (EventResponseType)actionIndex;

            // Delay
            action.delay = EditorGUILayout.FloatField(new GUIContent("Action Delay", "how long to wait before doing the action."), action.delay);
            if (action.delay < 0.0f)
            {
                action.delay = 0.0f;
            }
            else if (action.delay > 0.0f)
            {
                EditorGUILayout.HelpBox("If you use many events with delay you may notice some garbage collection issues on mobile devices", MessageType.Info);
            }

            // Game Object
            if (action.responseType == EventResponseType.ACTIVATE_GAMEOBJECT ||
                action.responseType == EventResponseType.ACTIVATE_GAMEOBJECT_AT_POSITION ||
                action.responseType == EventResponseType.DEACTIVATE_GAMEOBJECT ||
                action.responseType == EventResponseType.SEND_MESSSAGE)
            {
                action.targetGameObject = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Game Object", "The game object that will be acted on"), action.targetGameObject, typeof(GameObject), true);
            }

            // Component
            if (action.responseType == EventResponseType.ENABLE_BEHAVIOUR ||
                action.responseType == EventResponseType.DISABLE_BEHAVIOUR)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Behaviour", "The behaviour will be acted on"), action.targetComponent, typeof(Component), true);
            }

            // Instantiate
            if (action.responseType == EventResponseType.INSTANTIATE_AT_POSITION)
            {
                action.targetGameObject = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Game Object", "The game object to instantiate"), action.targetGameObject, typeof(GameObject), true);
            }

            // Particle system
            if (action.responseType == EventResponseType.PLAY_PARTICLES ||
                action.responseType == EventResponseType.PAUSE_PARTICLES)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Particle System", "The particle system that will be acted on"), action.targetComponent, typeof(ParticleSystem), true);
            }

            // Send message
            if (action.responseType == EventResponseType.SEND_MESSSAGE)
            {
                action.message = EditorGUILayout.TextField(new GUIContent("Message", "The message to send via send message"), action.message);
            }

            // Animation Override
            if (action.responseType == EventResponseType.OVERRIDE_ANIMATON)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Character", "Character to update."), action.targetComponent, typeof(Character), true);
                action.overrideState   = EditorGUILayout.TextField(new GUIContent("Override State", "The name of the override state."), action.overrideState);
            }

            // Clear Animation Override
            if (action.responseType == EventResponseType.CLEAR_ANIMATION_OVERRIDE)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Character", "Character to update."), action.targetComponent, typeof(Character), true);
                action.overrideState   = EditorGUILayout.TextField(new GUIContent("Override State", "The name of the override state to clear."), action.overrideState);
            }

            // Force Animation
            if (action.responseType == EventResponseType.SPECIAL_MOVE_ANIMATION)
            {
                EditorGUILayout.HelpBox("This type has been deprectaed use PLAY_ANIMATION with a Character as your target instead.", MessageType.Warning);
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Character", "Character to update."), action.targetComponent, typeof(Character), true);
                action.animationState  = (AnimationState)EditorGUILayout.EnumPopup(new GUIContent("Animation State", "The name of the override state."), action.animationState);
            }

            // Sprite
            if (action.responseType == EventResponseType.SWITCH_SPRITE)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Sprite Renderer", "SpriteRenderer to update."), action.targetComponent, typeof(SpriteRenderer), true);
                action.newSprite       = (Sprite)EditorGUILayout.ObjectField(new GUIContent("New Sprite", "Sprite to switch in."), action.newSprite, typeof(Sprite), true);
            }

            // SFX
            if (action.responseType == EventResponseType.PLAY_SFX)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Sound Effect", "The sound effect to play."), action.targetComponent, typeof(SoundEffect), true);
            }

            // MUSIC PLAYER
            if (action.responseType == EventResponseType.PLAY_SONG ||
                action.responseType == EventResponseType.STOP_SONG)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Music Player", "The music player."), action.targetComponent, typeof(MusicPlayer), true);
                if (action.responseType == EventResponseType.PLAY_SONG)
                {
                    action.message = EditorGUILayout.TextField(new GUIContent("Song Name", "The name of the song to play."), action.message);
                }
            }


            // Vulnerable/Invulnerable
            if (action.responseType == EventResponseType.MAKE_VULNERABLE ||
                action.responseType == EventResponseType.MAKE_INVULNERABLE)
            {
                if (action.targetComponent is CharacterHealth)
                {
                    action.targetComponent = action.targetComponent.gameObject.GetComponentInParent(typeof(IMob));
                }
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Character", "The character or enemy that will be acted on"), action.targetComponent, typeof(IMob), true);
            }

            // Load level
            if (action.responseType == EventResponseType.LOAD_SCENE)
            {
                string[] scenes = GetBuildSettingsSceneNames();

                int index = Array.IndexOf(scenes, action.message);
                index = EditorGUILayout.Popup(new GUIContent("Scene Name", "The name of the scene to load (make sure its added to the build settings)."), index, scenes);

                if (scenes.Length > 0)
                {
                    action.message = scenes[index];
                }
            }

            // Load level
            if (action.responseType == EventResponseType.LOCK ||
                action.responseType == EventResponseType.UNLOCK)
            {
                action.message = EditorGUILayout.TextField(new GUIContent("Lock Name", "The name of the lock (often a level name but it doesn't have to be)."), action.message);
            }

            // Respawn
            if (action.responseType == EventResponseType.RESPAWN ||
                action.responseType == EventResponseType.SET_ACTIVE_RESPAWN)
            {
                action.message = EditorGUILayout.TextField(new GUIContent("Respawn Point Name", "The name of the respawn point to respawn at, leave blank for whatever is currently active."), action.message);
            }

            // Teleport
            if (action.responseType == EventResponseType.TELEPORT)
            {
                action.targetGameObject = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Teleport Target", "The Transform position where the player will be teleported to."), action.targetGameObject, typeof(GameObject), true);
            }

            // Effects
            if (action.responseType == EventResponseType.START_EFFECT)
            {
                action.targetComponent  = (Component)EditorGUILayout.ObjectField(new GUIContent("Effect", "The effect that will be played."), action.targetComponent, typeof(FX_Base), true);
                action.targetGameObject = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Callback Object", "The game object that will be called back when the effect is finished"), action.targetGameObject, typeof(GameObject), true);
                if (action.targetComponent != null && action.targetGameObject != null)
                {
                    action.message = EditorGUILayout.TextField(new GUIContent("Callback Message", "The name message to send on call back."), action.message);
                    EditorGUILayout.HelpBox("Note that many effects do not support call backs.", MessageType.Info);
                }
            }

            // Animations
            if (action.responseType == EventResponseType.PLAY_ANIMATION ||
                action.responseType == EventResponseType.STOP_ANIMATION)
            {
                action.targetGameObject = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Character/Animator", "GameObject holding a Character, Animation or Animator to play or stop."), action.targetGameObject, typeof(GameObject), true);
            }

            // Animation state
            if (action.responseType == EventResponseType.PLAY_ANIMATION)
            {
                if (action.targetGameObject != null)
                {
                    Character       character       = action.targetGameObject.GetComponent <Character>();
                    SpecialMovement specialMovement = action.targetGameObject.GetComponentInChildren <SpecialMovement>();
                    if (specialMovement != null)
                    {
                        action.animationState = (AnimationState)EditorGUILayout.EnumPopup(new GUIContent("Animation State", "The state to play."), action.animationState);
                    }
                    else
                    {
                        if (character != null)
                        {
                            EditorGUILayout.HelpBox("If using a Character it is recommneded that you add a SpecialMovement_PlayAnimation to handle playing animations.", MessageType.Warning);
                        }
                        Animator animator = action.targetGameObject.GetComponent <Animator> ();
                        if (animator != null)
                        {
                            action.message = EditorGUILayout.TextField(new GUIContent("Animation State", "Name of the Animation to play."), action.message);
                        }
                    }
                }
                else
                {
                    // Assume character will be passed in event
                    action.animationState = (AnimationState)EditorGUILayout.EnumPopup(new GUIContent("Animation State", "The state to play."), action.animationState);
                }
            }

            // Animation state
            if (action.responseType == EventResponseType.STOP_ANIMATION)
            {
                SpecialMovement specialMovement = action.targetGameObject == null ? null : action.targetGameObject.GetComponentInChildren <SpecialMovement>();
                Animator        animator        = action.targetGameObject == null ? null : action.targetGameObject.GetComponent <Animator>();
                if (specialMovement == null && animator != null)
                {
                    EditorGUILayout.HelpBox("You cannot stop an Animator only an Animation or Character Special Movement. Instead use PLAY_ANIMATION and provide an IDLE or DEFAULT state", MessageType.Warning);
                }
            }

            // Scores
            if (action.responseType == EventResponseType.ADD_SCORE ||
                action.responseType == EventResponseType.RESET_SCORE)
            {
                action.message = EditorGUILayout.TextField(new GUIContent("Score Type", "ID string for the score type."), action.message);
            }
            if (action.responseType == EventResponseType.ADD_SCORE)
            {
                action.intValue = EditorGUILayout.IntField(new GUIContent("Amount", "How much score to add."), action.intValue);
            }

            // Max health/lives
            if (action.responseType == EventResponseType.UPDATE_MAX_HEALTH ||
                action.responseType == EventResponseType.SET_MAX_HEALTH ||
                action.responseType == EventResponseType.UPDATE_MAX_LIVES ||
                action.responseType == EventResponseType.SET_MAX_LIVES ||
                action.responseType == EventResponseType.ADD_LIVES ||
                action.responseType == EventResponseType.HEAL ||
                action.responseType == EventResponseType.DAMAGE ||
                action.responseType == EventResponseType.KILL)
            {
                if (!(action.targetComponent is CharacterHealth))
                {
                    action.targetComponent = null;
                }
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("CharacterHealth", "Reference to the CharacterHealth"), action.targetComponent, typeof(CharacterHealth), true);
            }


            // Item max
            if (action.responseType == EventResponseType.UPDATE_ITEM_MAX ||
                action.responseType == EventResponseType.SET_ITEM_MAX)
            {
                if (!(action.targetComponent is ItemManager))
                {
                    action.targetComponent = null;
                }
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("ItemManager", "Reference to the ItemManager"), action.targetComponent, typeof(ItemManager), true);
                action.message         = EditorGUILayout.TextField(new GUIContent("Item Type", "Type of item to update max for"), action.message);
            }

            // Update Max health/lives/item max
            if (action.responseType == EventResponseType.UPDATE_MAX_HEALTH ||
                action.responseType == EventResponseType.UPDATE_MAX_LIVES ||
                action.responseType == EventResponseType.ADD_LIVES ||
                action.responseType == EventResponseType.UPDATE_ITEM_MAX)
            {
                action.intValue = EditorGUILayout.IntField(new GUIContent("Amount", "How much to add or remove."), action.intValue);
            }

            // Heal
            if (action.responseType == EventResponseType.HEAL)
            {
                action.intValue = EditorGUILayout.IntField(new GUIContent("Amount", "How much to heal."), action.intValue);
            }

            // Damage
            if (action.responseType == EventResponseType.DAMAGE)
            {
                action.intValue   = EditorGUILayout.IntField(new GUIContent("Amount", "How much damage to cause."), action.intValue);
                action.damageType = (DamageType)EditorGUILayout.EnumPopup(new GUIContent("Damage Type", "Type of damage."), (DamageType)action.damageType);
            }

            // Set Max health/lives/item max
            if (action.responseType == EventResponseType.SET_MAX_HEALTH ||
                action.responseType == EventResponseType.SET_MAX_LIVES ||
                action.responseType == EventResponseType.SET_ITEM_MAX)
            {
                action.intValue = EditorGUILayout.IntField(new GUIContent("New Value", "The new value."), action.intValue);
            }

            // Named properties
            if (action.responseType == EventResponseType.SET_TAGGED_PROPERTY ||
                action.responseType == EventResponseType.ADD_TO_TAGGED_PROPERTY ||
                action.responseType == EventResponseType.MULTIPLY_TAGGED_PROPERTY)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Character", "Character to set property for."), action.targetComponent, typeof(Character), true);

                int index = Array.IndexOf(CachedTaggedPropertyNames, action.message);
                index = EditorGUILayout.Popup(new GUIContent("Property", "Named property type."), index, CachedTaggedPropertyNames);

                action.message    = index >= 0 ? CachedTaggedPropertyNames[index] : string.Empty;
                action.floatValue = EditorGUILayout.FloatField(new GUIContent("New Value", "The new value (float)."), action.floatValue);
            }

            if (action.responseType == EventResponseType.SET_TAGGED_PROPERTY)
            {
                EditorGUILayout.HelpBox("For booleans use 0 for false, anything else for true.", MessageType.Info);
            }

            // Spawn item
            if (action.responseType == EventResponseType.SPAWN_ITEM)
            {
                if (!(action.targetComponent is RandomItemSpawner))
                {
                    action.targetComponent = null;
                }
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Item Spawner", "Reference to the RandomItemSpawner"), action.targetComponent, typeof(RandomItemSpawner), true);
            }

            // Velocity
            if (action.responseType == EventResponseType.ADD_VELOCITY ||
                action.responseType == EventResponseType.SET_VELOCITY)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Reciever", "The behaviour that will have velocity added or set"), action.targetComponent, typeof(Component), true);
                if (!(action.targetComponent is IMob || action.targetComponent is Rigidbody2D))
                {
                    EditorGUILayout.HelpBox("Component must be a Character, Enemy or Rigidbody 2D. To drag specific components try locking an inspector window.", MessageType.Warning);
                }
                action.vectorValue = EditorGUILayout.Vector2Field(new GUIContent("Velocity", "Velocity to add or set."), action.vectorValue);
                action.boolValue   = EditorGUILayout.Toggle(new GUIContent("Velocity is Relative", "Is velocity relative to facing direction or rigidbody rotation?"), action.boolValue);
            }

            // Depth
            if (action.responseType == EventResponseType.SET_DEPTH)
            {
                action.intValue = EditorGUILayout.IntField(new GUIContent("Depth", "Depth to set"), action.intValue);
            }

            // Power-Up
            if (action.responseType == EventResponseType.POWER_UP)
            {
                action.message = EditorGUILayout.TextField(new GUIContent("Power-Up Type", "The name of the power up to apply."), action.message);
            }

            // items
            if (action.responseType == EventResponseType.COLLECT_ITEM ||
                action.responseType == EventResponseType.CONSUME_ITEM)
            {
                action.message  = EditorGUILayout.TextField(new GUIContent("Item", "The name of the item."), action.message);
                action.intValue = EditorGUILayout.IntField(new GUIContent("Amount", "The amount of item to collect/consume."), action.intValue);
            }

            // Activation groups
            if (action.responseType == EventResponseType.ACTIVATE_ITEM ||
                action.responseType == EventResponseType.DEACTIVATE_ITEM)
            {
                action.targetComponent = (Component)EditorGUILayout.ObjectField(new GUIContent("Activation Group", "Activation Group to use, if empty we will try to find an ActivationGroup on the Character triggering event."), action.targetComponent, typeof(ActivationGroup), true);
                action.message         = EditorGUILayout.TextField(new GUIContent("Activation Item", "The id of the activation item."), action.message);
            }
        }
예제 #3
0
        virtual protected void RenderResponse(PowerUpResponse response)
        {
            responseVisibility[response] = EditorGUILayout.Foldout(responseVisibility[response], response.type);
            if (responseVisibility[response])
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(10);
                GUILayout.Box("", GUILayout.Width(1), GUILayout.ExpandHeight(true));
                EditorGUILayout.BeginVertical();

                string type = EditorGUILayout.TextField(new GUIContent("PowerUp Type", "Type of the PowerUp."), response.type);
                if (type != response.type)
                {
                    response.type = type;
                    EditorUtility.SetDirty(target);
                    responseNames = null;
                }

                bool resetOnDamage = EditorGUILayout.Toggle(new GUIContent("Reset on Damage", "Should the power up be removed if the character is damaged)."), response.resetOnDamage);
                if (resetOnDamage != response.resetOnDamage)
                {
                    response.resetOnDamage = resetOnDamage;
                    EditorUtility.SetDirty(target);
                }

                int timer = EditorGUILayout.IntField(new GUIContent("PowerUp Timer", "Time the PowerUp is active for (use 0 for unlimited)."), response.time);
                if (timer < 0)
                {
                    timer = 0;
                }
                if (timer != response.time)
                {
                    response.time = timer;
                    EditorUtility.SetDirty(target);
                }
                // Show resets if timer > 0
                if (timer > 0.0f)
                {
                    int originalResetIndex = responseNames.IndexOf(response.powerUpReset);
                    int selectedResetIndex = originalResetIndex;
                    selectedResetIndex = EditorGUILayout.Popup("Reset Response", originalResetIndex, responseNames.ToArray());
                    if (originalResetIndex != selectedResetIndex)
                    {
                        response.powerUpReset = responseNames[selectedResetIndex];
                    }
                }

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                // Add new actions
                if (GUILayout.Button("Add Action"))
                {
                    if (response.actions == null)
                    {
                        response.actions = new EventResponse[1];
                    }
                    else
                    {
                        // Copy and grow array
                        EventResponse[] tmpActions = response.actions;
                        response.actions = new EventResponse[tmpActions.Length + 1];
                        System.Array.Copy(tmpActions, response.actions, tmpActions.Length);
                    }
                    EditorUtility.SetDirty(target);
                }
                if (GUILayout.Button("Remove PowerUp Type"))
                {
                    myTarget.responses.Remove(response);
                    EditorUtility.SetDirty(target);
                }

                EditorGUILayout.EndHorizontal();

                if (response.actions != null)
                {
                    for (int i = 0; i < response.actions.Length; i++)
                    {
                        EditorGUILayout.BeginVertical("HelpBox");

                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (i == 0)
                        {
                            GUI.enabled = false;
                        }
                        if (GUILayout.Button("Move Up", EditorStyles.miniButtonLeft))
                        {
                            EventResponse tmp = response.actions[i - 1];
                            response.actions[i - 1] = response.actions[i];
                            response.actions[i]     = tmp;
                            EditorUtility.SetDirty(target);
                            break;
                        }
                        GUI.enabled = true;
                        if (i == response.actions.Length - 1)
                        {
                            GUI.enabled = false;
                        }
                        if (GUILayout.Button("Move Down", EditorStyles.miniButtonRight))
                        {
                            EventResponse tmp = response.actions[i + 1];
                            response.actions[i + 1] = response.actions[i];
                            response.actions[i]     = tmp;
                            EditorUtility.SetDirty(target);
                            break;
                        }
                        GUI.enabled = true;
                        // Remove
                        GUILayout.Space(4);
                        bool removed = false;
                        if (GUILayout.Button("Remove", EditorStyles.miniButton))
                        {
                            response.actions = response.actions.Where(a => a != response.actions[i]).ToArray();
                            EditorUtility.SetDirty(target);
                            removed = true;
                        }
                        GUILayout.EndHorizontal();
                        if (!removed)
                        {
                            EventResponderInspector.RenderAction(target, response, response.actions[i]);
                        }
                        EditorGUILayout.EndVertical();
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
            }
        }
예제 #4
0
        virtual protected void RenderResetResponse()
        {
            resetResponseVisibility = EditorGUILayout.Foldout(resetResponseVisibility, "RESET");
            if (resetResponseVisibility)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(10);
                GUILayout.Box("", GUILayout.Width(1), GUILayout.ExpandHeight(true));
                EditorGUILayout.BeginVertical();

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                // Add new actions
                if (GUILayout.Button("Add Action"))
                {
                    if (myTarget.resetResponse.actions == null)
                    {
                        myTarget.resetResponse.actions = new EventResponse[1];
                    }
                    else
                    {
                        // Copy and grow array
                        EventResponse[] tmpActions = myTarget.resetResponse.actions;
                        myTarget.resetResponse.actions = new EventResponse[tmpActions.Length + 1];
                        System.Array.Copy(tmpActions, myTarget.resetResponse.actions, tmpActions.Length);
                    }
                    EditorUtility.SetDirty(target);
                }

                EditorGUILayout.EndHorizontal();

                if (myTarget.resetResponse.actions != null)
                {
                    for (int i = 0; i < myTarget.resetResponse.actions.Length; i++)
                    {
                        EditorGUILayout.BeginVertical("HelpBox");

                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (i == 0)
                        {
                            GUI.enabled = false;
                        }
                        if (GUILayout.Button("Move Up", EditorStyles.miniButtonLeft))
                        {
                            EventResponse tmp = myTarget.resetResponse.actions[i - 1];
                            myTarget.resetResponse.actions[i - 1] = myTarget.resetResponse.actions[i];
                            myTarget.resetResponse.actions[i]     = tmp;
                            EditorUtility.SetDirty(target);
                            break;
                        }
                        GUI.enabled = true;
                        if (i == myTarget.resetResponse.actions.Length - 1)
                        {
                            GUI.enabled = false;
                        }
                        if (GUILayout.Button("Move Down", EditorStyles.miniButtonRight))
                        {
                            EventResponse tmp = myTarget.resetResponse.actions[i + 1];
                            myTarget.resetResponse.actions[i + 1] = myTarget.resetResponse.actions[i];
                            myTarget.resetResponse.actions[i]     = tmp;
                            EditorUtility.SetDirty(target);
                            break;
                        }
                        GUI.enabled = true;
                        // Remove
                        GUILayout.Space(4);
                        bool removed = false;
                        if (GUILayout.Button("Remove", EditorStyles.miniButton))
                        {
                            myTarget.resetResponse.actions = myTarget.resetResponse.actions.Where(a => a != myTarget.resetResponse.actions[i]).ToArray();
                            EditorUtility.SetDirty(target);
                            removed = true;
                        }
                        GUILayout.EndHorizontal();
                        if (!removed)
                        {
                            EventResponderInspector.RenderAction(target, myTarget.resetResponse, myTarget.resetResponse.actions[i]);
                        }
                        EditorGUILayout.EndVertical();
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
            }
        }
 /// <summary>
 /// Applies the filters.
 /// </summary>
 /// <returns><c>true</c>, if filtering was passed, <c>false</c> otherwise.</returns>
 /// <param name="action">Action.</param>
 /// <param name="args">Arguments.</param>
 virtual protected bool ApplyFilters(EventResponse action, System.EventArgs args)
 {
     if (args is AnimationEventArgs)
     {
         if (animationStateFilter == AnimationState.NONE || animationStateFilter == ((AnimationEventArgs)args).State)
         {
             return(true);
         }
         return(false);
     }
     if (args is ExtraDamageInfoEventArgs)
     {
         if ((stringFilter == null || stringFilter == "" || stringFilter == ((ExtraDamageInfoEventArgs)args).AttackName) &&
             (damageTypeFilter == DamageType.NONE || damageTypeFilter == ((DamageInfoEventArgs)args).DamageInfo.DamageType))
         {
             return(true);
         }
         return(false);
     }
     if (args is DamageInfoEventArgs)
     {
         if (damageTypeFilter == DamageType.NONE || damageTypeFilter == ((DamageInfoEventArgs)args).DamageInfo.DamageType)
         {
             return(true);
         }
         return(false);
     }
     if (args is ButtonEventArgs)
     {
         if (buttonStateFilter == ButtonState.ANY || buttonStateFilter == ((ButtonEventArgs)args).State)
         {
             return(true);
         }
         return(false);
     }
     if (args is AttackEventArgs)
     {
         if (stringFilter == null || stringFilter == "" || stringFilter == ((AttackEventArgs)args).Name)
         {
             return(true);
         }
         return(false);
     }
     if (args is PhaseEventArgs)
     {
         if (stringFilter == null || stringFilter == "" || stringFilter == ((PhaseEventArgs)args).PhaseName)
         {
             return(true);
         }
         return(false);
     }
     if (args is StateEventArgs)
     {
         if (stringFilter == null || stringFilter == "" || stringFilter == ((StateEventArgs)args).StateName)
         {
             return(true);
         }
         return(false);
     }
     if (args is ItemEventArgs)
     {
         if (stringFilter == null || stringFilter == "" || stringFilter == ((ItemEventArgs)args).Type)
         {
             if (intFilter == 0)
             {
                 return(true);
             }
             if (((ItemEventArgs)args).Amount >= intFilter)
             {
                 return(true);
             }
         }
         return(false);
     }
     if (args is ActivationEventArgs)
     {
         if (stringFilter == null || stringFilter == "" || stringFilter == ((ActivationEventArgs)args).ItemId)
         {
             return(true);
         }
         return(false);
     }
     return(true);
 }
예제 #6
0
        /// <summary>
        /// Do the action
        /// </summary>
        /// <param name="args">Event arguments.</param>
        /// <param name="action">Action.</param>
        virtual protected void DoImmediateAction(EventResponse action, System.EventArgs args)
        {
            Character       character;
            CharacterHealth characterHealth = null;
            ItemManager     itemManager     = null;
            Animator        animator;
            Animation       animation;

            switch (action.responseType)
            {
            case EventResponseType.DEBUG_LOG:
                Debug.Log(string.Format("Got event, arguments: {0}", args != null ? args.ToString() : ""));
                break;

            case EventResponseType.ACTIVATE_GAMEOBJECT:
                action.targetGameObject.SetActive(true);
                break;

            case EventResponseType.DEACTIVATE_GAMEOBJECT:
                action.targetGameObject.SetActive(false);
                break;

            case EventResponseType.SEND_MESSSAGE:
                action.targetGameObject.SendMessage(action.message, SendMessageOptions.DontRequireReceiver);
                break;

            case EventResponseType.ENABLE_BEHAVIOUR:
                if (action.targetComponent is Movement)
                {
                    ((Movement)action.targetComponent).Enabled = true;
                }
                else if (action.targetComponent is Behaviour)
                {
                    ((Behaviour)action.targetComponent).enabled = true;
                }
                else if (action.targetComponent is Renderer)
                {
                    ((Renderer)action.targetComponent).enabled = true;
                }
                break;

            case EventResponseType.DISABLE_BEHAVIOUR:
                if (action.targetComponent is Movement)
                {
                    ((Movement)action.targetComponent).Enabled = false;
                }
                else if (action.targetComponent is Behaviour)
                {
                    ((Behaviour)action.targetComponent).enabled = false;
                }
                else if (action.targetComponent is Renderer)
                {
                    ((Renderer)action.targetComponent).enabled = false;
                }
                break;

            case EventResponseType.OVERRIDE_ANIMATON:
                if (action.targetComponent is Character)
                {
                    ((Character)action.targetComponent).AddAnimationOverride(action.overrideState);
                }
                break;

            case EventResponseType.CLEAR_ANIMATION_OVERRIDE:
                if (action.targetComponent is Character)
                {
                    ((Character)action.targetComponent).RemoveAnimationOverride(action.overrideState);
                }
                break;

            case EventResponseType.SPECIAL_MOVE_ANIMATION:
                character = null;
                if (action.targetComponent is Character)
                {
                    character = (Character)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    character = ((CharacterEventArgs)args).Character;
                }
                if (character != null)
                {
                    SpecialMovement_PlayAnimation movement = character.GetComponentInChildren <SpecialMovement_PlayAnimation>();
                    if (movement == null)
                    {
                        Debug.LogWarning("Cannot play an animation as the Character does not have a SpecalMovement_PlayAnimation attached");
                    }
                    else
                    {
                        movement.Play(action.animationState);
                    }
                }
                break;

            case EventResponseType.PLAY_PARTICLES:
                if (action.targetComponent is ParticleSystem)
                {
                    ((ParticleSystem)action.targetComponent).Play();
                }
                break;

            case EventResponseType.PAUSE_PARTICLES:
                if (action.targetComponent is ParticleSystem)
                {
                    ((ParticleSystem)action.targetComponent).Pause();
                }
                break;

            case EventResponseType.SWITCH_SPRITE:
                if (action.targetComponent is SpriteRenderer)
                {
                    ((SpriteRenderer)action.targetComponent).sprite = action.newSprite;
                }
                break;

            case EventResponseType.PLAY_SFX:
                if (action.targetComponent is SoundEffect)
                {
                    ((SoundEffect)action.targetComponent).Play();
                }
                break;

            case EventResponseType.PLAY_SONG:
                if (action.targetComponent is MusicPlayer)
                {
                    ((MusicPlayer)action.targetComponent).Play(action.message);
                }
                break;

            case EventResponseType.STOP_SONG:
                if (action.targetComponent is MusicPlayer)
                {
                    ((MusicPlayer)action.targetComponent).Stop();
                }
                break;

            case EventResponseType.MAKE_INVULNERABLE:
                character = null;
                if (action.targetComponent is Character)
                {
                    character = (Character)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    character = ((CharacterEventArgs)args).Character;
                }
                if (character != null)
                {
                    CharacterHealth ch = character.GetComponentInChildren <CharacterHealth>();
                    if (ch != null)
                    {
                        ch.SetInvulnerable();
                    }
                    else
                    {
                        Debug.LogWarning("Tried to make Character invulnerable but no CharacterHealth found.");
                    }
                }
                else if (action.targetComponent is Enemy)
                {
                    ((Enemy)action.targetComponent).MakeInvulnerable(99999999);
                }
                else
                {
                    Debug.LogWarning("Tried to make invulnerable but didn't know how to make the target invulnerable.");
                }
                break;

            case EventResponseType.MAKE_VULNERABLE:
                character = null;
                if (action.targetComponent is Character)
                {
                    character = (Character)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    character = ((CharacterEventArgs)args).Character;
                }
                if (character != null)
                {
                    CharacterHealth ch = character.GetComponentInChildren <CharacterHealth>();
                    if (ch != null)
                    {
                        ch.SetVulnerable();
                    }
                    else
                    {
                        Debug.LogWarning("Tried to make Character vulnerable but no CharacterHealth found.");
                    }
                }
                else if (action.targetComponent is Enemy)
                {
                    ((Enemy)action.targetComponent).MakeVulnerable();
                }
                else
                {
                    Debug.LogWarning("Tried to make vulnerable but didn't know how to make the target invulnerable.");
                }
                break;

            case EventResponseType.LEVEL_COMPLETE:
                LevelManager.Instance.LevelCompleted();
                break;

            case EventResponseType.LOAD_SCENE:
                foreach (Character c in FindObjectsOfType <Character>())
                {
                    c.AboutToExitScene(action.message);
                }
                                #if !UNITY_4_6 && !UNITY_5_1 && !UNITY_5_2
                SceneManager.LoadScene(action.message);
                                #else
                Application.LoadLevel(action.message);
                                #endif
                break;

            case EventResponseType.LOCK:
                LevelManager.Instance.LockLevel(action.message);
                break;

            case EventResponseType.UNLOCK:
                LevelManager.Instance.UnlockLevel(action.message);
                break;

            case EventResponseType.RESPAWN:
                if (args is CharacterEventArgs)
                {
                    LevelManager.Instance.Respawn(((CharacterEventArgs)args).Character, action.message);
                }
                else
                {
                    Debug.LogWarning("Tried to respawn but the triggering event did not derive from Character.");
                }
                break;

            case EventResponseType.SET_ACTIVE_RESPAWN:
                LevelManager.Instance.ActivateRespawnPoint(action.message);
                break;

            case EventResponseType.START_EFFECT:
                if (action.targetComponent is FX_Base)
                {
                    if (action.targetGameObject != null && action.message != null && action.message != "")
                    {
                        ((FX_Base)action.targetComponent).StartEffect(action.targetGameObject, action.message);
                    }
                    else
                    {
                        ((FX_Base)action.targetComponent).StartEffect();
                    }
                }
                else
                {
                    Debug.LogWarning("Trying to play an Effect that isn't derived from FX_Base.");
                }
                break;

            case EventResponseType.FLIP_GRAVITY:
                if (args is CharacterEventArgs)
                {
                    FlippableGravity gravity = ((CharacterEventArgs)args).Character.GetComponent <FlippableGravity>();
                    if (gravity != null)
                    {
                        gravity.FlipGravity();
                    }
                    else
                    {
                        Debug.LogWarning("Tried to flip gravity but the character didn't have a FlippableGravity attached.");
                    }
                }
                else
                {
                    Debug.LogWarning("Tried to flip gravity but the triggering event did not derive from Character.");
                }
                break;

            case EventResponseType.START_SWIM:
                character = null;
                if (action.targetComponent is Character)
                {
                    character = (Character)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    character = ((CharacterEventArgs)args).Character;
                }
                if (character != null)
                {
                    SpecialMovement_Swim movement = character.GetComponentInChildren <SpecialMovement_Swim>();
                    if (movement == null)
                    {
                        Debug.LogWarning("Cannot start swim as the Character does not have a SpecalMovement_Swim attached");
                    }
                    else
                    {
                        ((SpecialMovement_Swim)movement).StartSwim();
                    }
                }
                break;

            case EventResponseType.STOP_SWIM:
                character = null;
                if (action.targetComponent is Character)
                {
                    character = (Character)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    character = ((CharacterEventArgs)args).Character;
                }
                if (character != null)
                {
                    SpecialMovement_Swim movement = character.GetComponentInChildren <SpecialMovement_Swim>();
                    if (movement == null)
                    {
                        Debug.LogWarning("Cannot stop swim as the Character does not have a SpecalMovement_Swim attached");
                    }
                    else
                    {
                        ((SpecialMovement_Swim)movement).StopSwim();
                    }
                }
                break;

            case EventResponseType.ADD_SCORE:
                ScoreManager.GetInstanceForType(action.message).AddScore(action.intValue);
                break;

            case EventResponseType.RESET_SCORE:
                ScoreManager.GetInstanceForType(action.message).ResetScore();
                break;

            case EventResponseType.PLAY_ANIMATION:
                animator = action.targetGameObject.GetComponent <Animator>();
                if (animator != null)
                {
                    animator.Play(action.message);
                }
                else
                {
                    animation = action.targetGameObject.GetComponent <Animation>();
                    if (animation != null)
                    {
                        animation.Play();
                    }
                    else
                    {
                        Debug.LogWarning("Couldn't find an Animation or Animatopr on the target GameObject");
                    }
                }
                break;

            case EventResponseType.STOP_ANIMATION:
                animation = action.targetGameObject.GetComponent <Animation>();
                if (animation != null)
                {
                    animation.Stop();
                }
                else
                {
                    Debug.LogWarning("Couldn't find an Animation or Animatopr on the target GameObject");
                }
                break;

            case EventResponseType.UPDATE_LIVES:
                if (action.targetComponent is CharacterHealth)
                {
                    characterHealth = (CharacterHealth)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    characterHealth = ((CharacterEventArgs)args).Character.GetComponent <CharacterHealth>();
                }
                if (characterHealth == null)
                {
                    Debug.LogWarning("No characterHealth found on target, cannot increase max lives");
                }
                else
                {
                    characterHealth.CurrentLives += action.intValue;
                }
                break;

            case EventResponseType.UPDATE_MAX_LIVES:
                if (action.targetComponent is CharacterHealth)
                {
                    characterHealth = (CharacterHealth)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    characterHealth = ((CharacterEventArgs)args).Character.GetComponent <CharacterHealth>();
                }
                if (characterHealth == null)
                {
                    Debug.LogWarning("No characterHealth found on target, cannot increase max lives");
                }
                else
                {
                    characterHealth.MaxLives += action.intValue;
                }
                break;

            case EventResponseType.SET_MAX_LIVES:
                if (action.targetComponent is CharacterHealth)
                {
                    characterHealth = (CharacterHealth)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    characterHealth = ((CharacterEventArgs)args).Character.GetComponent <CharacterHealth>();
                }
                if (characterHealth == null)
                {
                    Debug.LogWarning("No characterHealth found on target, cannot increase max lives");
                }
                else
                {
                    characterHealth.MaxLives = action.intValue;
                }
                break;

            case EventResponseType.UPDATE_MAX_HEALTH:
                if (action.targetComponent is CharacterHealth)
                {
                    characterHealth = (CharacterHealth)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    characterHealth = ((CharacterEventArgs)args).Character.GetComponent <CharacterHealth>();
                }
                if (characterHealth == null)
                {
                    Debug.LogWarning("No characterHealth found on target, cannot increase max health");
                }
                else
                {
                    characterHealth.MaxHealth += action.intValue;
                }
                break;

            case EventResponseType.SET_MAX_HEALTH:
                if (action.targetComponent is CharacterHealth)
                {
                    characterHealth = (CharacterHealth)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    characterHealth = ((CharacterEventArgs)args).Character.GetComponent <CharacterHealth>();
                }
                if (characterHealth == null)
                {
                    Debug.LogWarning("No characterHealth found on target, cannot decrease max health");
                }
                else
                {
                    characterHealth.MaxHealth = action.intValue;
                }
                break;

            case EventResponseType.UPDATE_ITEM_MAX:
                if (action.targetComponent is ItemManager)
                {
                    itemManager = (ItemManager)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    itemManager = ((CharacterEventArgs)args).Character.GetComponentInChildren <ItemManager>();
                }
                if (itemManager == null)
                {
                    Debug.LogWarning("No itemManager found on target, cannot increase item max");
                }
                else
                {
                    itemManager.IncreaseItemMax(action.message, action.intValue);
                }
                break;

            case EventResponseType.SET_ITEM_MAX:
                if (action.targetComponent is ItemManager)
                {
                    itemManager = (ItemManager)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    itemManager = ((CharacterEventArgs)args).Character.GetComponentInChildren <ItemManager>();
                }
                if (itemManager == null)
                {
                    Debug.LogWarning("No itemManager found on target, cannot decrease item max");
                }
                else
                {
                    itemManager.SetItemMax(action.message, -action.intValue);
                }
                break;

            case EventResponseType.SET_TAGGED_PROPERTY:
                character = null;
                if (action.targetComponent is Character)
                {
                    character = (Character)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    character = ((CharacterEventArgs)args).Character;
                }
                if (character != null)
                {
                    character.SetTaggedProperty(action.message, action.floatValue);
                }
                break;

            case EventResponseType.ADD_TO_TAGGED_PROPERTY:
                character = null;
                if (action.targetComponent is Character)
                {
                    character = (Character)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    character = ((CharacterEventArgs)args).Character;
                }
                if (character != null)
                {
                    character.AddToTaggedProperty(action.message, action.floatValue);
                }
                break;

            case EventResponseType.MULTIPLY_TAGGED_PROPERTY:
                character = null;
                if (action.targetComponent is Character)
                {
                    character = (Character)action.targetComponent;
                }
                else if (args is CharacterEventArgs)
                {
                    character = ((CharacterEventArgs)args).Character;
                }
                if (character != null)
                {
                    character.MultiplyTaggedProperty(action.message, action.floatValue);
                }
                break;

            case EventResponseType.SPAWN_ITEM:
                if (action.targetComponent is RandomItemSpawner)
                {
                    ((RandomItemSpawner)action.targetComponent).Spawn();
                }
                else
                {
                    Debug.LogWarning("No RandomItemSpawner is set.");
                }
                break;

            case EventResponseType.ADD_VELOCITY:
                if (action.targetComponent == null && args is CharacterEventArgs)
                {
                    character = ((CharacterEventArgs)args).Character;
                    float   modifier        = action.boolValue ? character.LastFacedDirection : 1;
                    Vector2 currentVelocity = character.Velocity;
                    currentVelocity += action.vectorValue;
                    character.SetVelocityX(currentVelocity.x * modifier);
                    character.SetVelocityY(currentVelocity.y);
                }
                else if (action.targetComponent is IMob)
                {
                    float   modifier        = action.boolValue ? ((IMob)action.targetComponent).LastFacedDirection : 1;
                    Vector2 currentVelocity = ((IMob)action.targetComponent).Velocity;
                    currentVelocity += action.vectorValue;
                    ((IMob)action.targetComponent).SetVelocityX(currentVelocity.x * modifier);
                    ((IMob)action.targetComponent).SetVelocityY(currentVelocity.y);
                }
                else if (action.targetComponent is Rigidbody2D)
                {
                    if (action.boolValue)
                    {
                        ((Rigidbody2D)action.targetComponent).AddRelativeForce(action.vectorValue, ForceMode2D.Impulse);
                    }
                    else
                    {
                        ((Rigidbody2D)action.targetComponent).AddForce(action.vectorValue, ForceMode2D.Impulse);
                    }
                }
                else
                {
                    Debug.LogWarning("Tried to add velocity to an object that wasnt a Character, Enemy or Rigidbody2D");
                }
                break;

            case EventResponseType.SET_VELOCITY:
                character = ((CharacterEventArgs)args).Character;
                if (action.targetComponent == null && args is CharacterEventArgs)
                {
                    float modifier = action.boolValue ? character.LastFacedDirection : 1;
                    character.SetVelocityX(action.vectorValue.x * modifier);
                    character.SetVelocityY(action.vectorValue.y);
                }
                else if (action.targetComponent is IMob)
                {
                    float modifier = action.boolValue ? ((IMob)action.targetComponent).LastFacedDirection : 1;
                    ((IMob)action.targetComponent).SetVelocityX(action.vectorValue.x * modifier);
                    ((IMob)action.targetComponent).SetVelocityY(action.vectorValue.y);
                }
                else if (action.targetComponent is Rigidbody2D)
                {
                    ((Rigidbody2D)action.targetComponent).velocity = action.vectorValue;
                }
                else
                {
                    Debug.LogWarning("Tried to set velocity on an object that wasnt a Character, Enemy or Rigidbody2D");
                }
                break;
            }
        }