/// <summary> /// Initialise the movement with the given movement data. /// </summary> /// <param name="character">Character.</param> /// <param name="movementData">Movement data.</param> override public Movement Init(Character character, MovementVariable[] movementData) { AssignReferences(character); // Set variables if (movementData != null && movementData.Length == MovementVariableCount) { warpSpeed = movementData[WarpSpeedIndex].FloatValue; warpDistance = movementData[WarpDistanceIndex].FloatValue; maxWarpCount = movementData[MaxWarpsIndex].IntValue; isInvincible = movementData[IsInvincibleIndex].BoolValue; controlType = (TeleportJumpControlType)movementData[ControlTypeIndex].IntValue; actionButton = movementData [ActionButtonindex].IntValue; timeToNextWarp = movementData [TimeToNextWarpIndex].FloatValue; } else { Debug.LogError("Invalid movement data."); } if (isInvincible) { characterHealth = character.GetComponentInChildren <CharacterHealth> (); if (characterHealth == null) { Debug.LogWarning("Teleport Jump couldn't find a character health and thus can't set invincibility."); } } eventArgs = new CharacterEventArgs(character); return(this); }
/// <summary> /// Handles the character loaded. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event args.</param> void HandleCharacterLoaded(object sender, CharacterEventArgs e) { if (loadOnCharacterLoad) { Load(this); } }
/// <summary> /// Handles the character loaded event by setting the character. /// </summary> virtual protected void HandleCharacterLoaded(object sender, CharacterEventArgs e) { if (character == null) { character = e.Character; // We have a character now Init the base base.Init(); } }
/// <summary> /// Init this instance. /// </summary> virtual protected void Init() { characterEventArgs = new CharacterEventArgs(); if (automaticActivation == PlatformActivationType.ACTIVATE_ON_START) { Activated = true; OnPlatformActivated(null); } conditions = GetComponents <AdditionalCondition> (); }
/// <summary> /// Initialise this instance. /// </summary> override public Movement Init(Character character) { this.character = character; args = new CharacterEventArgs(character); myAnimator = character.GetComponentInChildren <Animator> (); if (myAnimator == null) { Debug.LogWarning("WeildWeapon requires an animator to check for end of the weild weapon animation"); } return(this); }
/// <summary> /// Handles the character loaded event. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event.</param> void HandleCharacterLoaded(object sender, CharacterEventArgs e) { if (allCharacters == null) { allCharacters = new List <Character>(); } if (!allCharacters.Contains(e.Character)) { allCharacters.Add(e.Character); } }
/// <summary> /// Handles the trigger exited. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> virtual protected void HandleTriggerExited(object sender, CharacterEventArgs args) { if (args.Character == null) { return; } if (affectedCharacters.Contains(args.Character)) { affectedCharacters.Remove(args.Character); } }
/// <summary> /// Handles the trigger entered. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> virtual protected void HandleTriggerEntered(object sender, CharacterEventArgs args) { if (args.Character == null) { return; } if (!affectedCharacters.Contains(args.Character)) { Debug.Log("Add"); affectedCharacters.Add(args.Character); } }
/// <summary> /// Handle character respawns by resetting animation state. /// </summary> virtual protected void HandleRespawned(object sender, CharacterEventArgs e) { myAnimator.runtimeAnimatorController = defaultController; myAnimator.SetInteger("PreviousState", 0); myAnimator.SetInteger("State", 0); myAnimator.SetBool("HasPlayed", false); if (aimer != null) { myAnimator.SetFloat("GunPositionX", 0); myAnimator.SetFloat("GunPositionY", 0); } myAnimator.Play("IDLE"); }
/// <summary> /// Initialise this instance. /// </summary> override public Movement Init(Character character) { AssignReferences(character); if (isInvincible) { characterHealth = character.GetComponentInChildren <CharacterHealth> (); if (characterHealth == null) { Debug.LogWarning("Teleport Jump couldn't find a character health and thus can't set invincibility."); } } eventArgs = new CharacterEventArgs(character); return(this); }
/// <summary> /// Handles the character loaded event. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event.</param> virtual protected void HandleCharacterLoaded(object sender, CharacterEventArgs e) { character = e.Character; // Get item manager ref if (requireMatchingItem && itemManager == null) { if (character != null) { itemManager = character.GetComponentInChildren <ItemManager>(); } if (itemManager == null) { Debug.LogWarning("ActivationGroup could not find an Item Manager but has requireMatchingItem set to true!"); enabled = false; } } if (loadOnCharacterLoad) { Load(this); } }
/// <summary> /// Initialise the mvoement with the given movement data. /// </summary> /// <param name="character">Character.</param> /// <param name="movementData">Movement data.</param> override public Movement Init(Character character, MovementVariable[] movementData) { this.character = character; args = new CharacterEventArgs(character); myAnimator = character.GetComponentInChildren <Animator> (); if (myAnimator == null) { Debug.LogWarning("WeildWeapon requires an animator to check for end of the weild weapon animation"); } // if (movementData != null && movementData.Length >= MovementVariableCount) // { // overrideName = movementData[OverrideNameIndex].StringValue; // actionButton = movementData[ActionButtonIndex].IntValue; // // } // else // { // Debug.LogError("Invalid movement data."); // } return(this); }
/// <summary> /// Handles the character being loaded. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> override protected void HandleCharacterLoaded(object sender, CharacterEventArgs e) { base.HandleCharacterLoaded(sender, e); // We only get called if groups was null, so try to find the group foreach (ActivationGroup g in e.Character.GetComponentsInChildren <ActivationGroup>()) { if (g.groupName == groupName) { group = g; break; } } if (group == null) { // Search rest of scene foreach (ActivationGroup g in FindObjectsOfType <ActivationGroup>()) { if (g.groupName == groupName) { group = g; break; } } } if (group != null) { if (group.requireMatchingItem) { itemId = activationItemId; GetItemManager(); } group.Activated += HandleActivationChange; group.Deactivated += HandleActivationChange; } else { Debug.LogWarning("No activation group with name " + groupName + " was found. Deactivating GameObject."); gameObject.SetActive(false); } }
/// <summary> /// Handles the character being loaded. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> override protected void HandleCharacterLoaded(object sender, CharacterEventArgs e) { base.HandleCharacterLoaded(sender, e); // We only get called if groups was null, so try to find the group foreach (BasicAttacks a in e.Character.GetComponentsInChildren <BasicAttacks>()) { for (int i = 0; i < a.attacks.Count; i++) { if (attack != null) { break; } if (a.attacks[i].name == attackName) { attack = a; attackIndex = i; break; } } } UpdateFromAttackData(); }
/// <summary> /// Handles the character being loaded. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> virtual protected void HandleCharacterLoaded(object sender, CharacterEventArgs e) { Debug.Log("Set character"); character = e.Character; GetItemManager(); }
/// <summary> /// Handle character respawns by resetting animation state. /// </summary> virtual protected void HandleRespawned (object sender, CharacterEventArgs e) { myAnimator.runtimeAnimatorController = defaultController; myAnimator.SetInteger("PreviousState", 0); myAnimator.SetInteger("State", 0); myAnimator.SetBool("HasPlayed", false); if (aimer != null) { myAnimator.SetFloat("GunPositionX",0); myAnimator.SetFloat("GunPositionY",0); } myAnimator.Play ("IDLE"); }
/// <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 = null; CharacterHealth characterHealth = null; ItemManager itemManager = null; Animator animator; Animation animation; SpecialMovement_PlayAnimation specialMovement; 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.ACTIVATE_GAMEOBJECT_AT_POSITION: action.targetGameObject.transform.position = transform.position; 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.INSTANTIATE_AT_POSITION: if (action.targetGameObject != null) { Instantiate(action.targetGameObject, transform.position, Quaternion.identity); } break; case EventResponseType.OVERRIDE_ANIMATON: character = GetCharacter(action, args); if (character != null) { character.AddAnimationOverride(action.overrideState); } else { Debug.LogWarning("Tried to remove override but no character found"); } break; case EventResponseType.CLEAR_ANIMATION_OVERRIDE: character = GetCharacter(action, args); if (character != null) { character.RemoveAnimationOverride(action.overrideState); } else { Debug.LogWarning("Tried to remove override but no character found"); } break; case EventResponseType.SPECIAL_MOVE_ANIMATION: // This is legacy and shoulnd't be used any more character = GetCharacter(action, args); 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 = GetCharacter(action, args); 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 = GetCharacter(action, args); 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_4_7 && !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.TELEPORT: { if (args is DoorEventArgs) { CharacterEventArgs characterArgs = (CharacterEventArgs)args; print(action.targetGameObject); if (characterArgs.Character != null && action.targetGameObject != null) { characterArgs.Character.Transform.position = (action.targetGameObject.transform.position); } } } 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 = GetCharacter(action, args); 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 = GetCharacter(action, args); 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.SWIM_SURFACE: character = GetCharacter(action, args); if (character != null) { SpecialMovement_Swim movement = character.GetComponentInChildren <SpecialMovement_Swim>(); if (movement == null) { Debug.LogWarning("Cannot start surface swim as the Character does not have a SpecalMovement_Swim attached"); } else { ((SpecialMovement_Swim)movement).SurfaceSwim(); } } 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: character = GetCharacter(action, args); specialMovement = null; if (character != null) { specialMovement = character.GetComponentInChildren <SpecialMovement_PlayAnimation>(); if (specialMovement != null) { specialMovement.Play(action.animationState); break; } } animator = action.targetGameObject.GetComponent <Animator>(); if (animator != null) { animator.Play(action.message); break; } animation = action.targetGameObject.GetComponent <Animation>(); if (animation != null) { animation.Play(); break; } Debug.LogWarning("Couldn't find a Special Movement, Animation or Animator on the target GameObject"); break; case EventResponseType.STOP_ANIMATION: character = GetCharacter(action, args); specialMovement = null; if (character != null) { specialMovement = character.GetComponentInChildren <SpecialMovement_PlayAnimation>(); if (specialMovement != null) { specialMovement.StopAnimation(); break; } } animation = action.targetGameObject.GetComponent <Animation>(); if (animation != null) { animation.Stop(); break; } Debug.LogWarning("Couldn't find a Special Movement or Animation on the target GameObject"); break; case EventResponseType.ADD_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.HEAL: 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 heal."); } else { characterHealth.Heal(action.intValue); } break; case EventResponseType.DAMAGE: 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 damage."); } else { characterHealth.Damage(new DamageInfo(action.intValue, action.damageType, Vector2.zero)); } break; case EventResponseType.KILL: 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 kill."); } else { characterHealth.Kill(); } 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 = GetCharacter(action, args); if (character != null) { character.SetTaggedProperty(action.message, action.floatValue); } break; case EventResponseType.ADD_TO_TAGGED_PROPERTY: character = GetCharacter(action, args); if (character != null) { character.AddToTaggedProperty(action.message, action.floatValue); } break; case EventResponseType.MULTIPLY_TAGGED_PROPERTY: character = GetCharacter(action, args); 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: character = GetCharacter(action, args); if (action.targetComponent == null && character != null) { 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 != null && 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 != null && 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 = GetCharacter(action, args); if (action.targetComponent == null && character != null) { float modifier = action.boolValue ? character.LastFacedDirection : 1; character.SetVelocityX(action.vectorValue.x * modifier); character.SetVelocityY(action.vectorValue.y); } else if (action.targetComponent != null && 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 != null && 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; case EventResponseType.SET_DEPTH: character = GetCharacter(action, args); if (action.targetComponent == null && character != null) { character.ZLayer = action.intValue; } else if (action.targetComponent != null && action.targetComponent is IMob) { ((IMob)action.targetComponent).ZLayer = action.intValue; } break; case EventResponseType.POWER_UP: character = GetCharacter(action, args); if (character != null) { PowerUpManager p = character.GetComponent <PowerUpManager>(); if (p != null) { p.Collect(action.message); } else { Debug.LogWarning("Tried to PowerUp but no PowerUpManager could be found"); } } break; case EventResponseType.RESET_POWER_UP: character = GetCharacter(action, args); if (character != null) { PowerUpManager p = character.GetComponent <PowerUpManager>(); if (p != null) { p.HardReset(); } else { Debug.LogWarning("Tried to Reset PowerUp but no PowerUpManager could be found"); } } break; case EventResponseType.COLLECT_ITEM: character = GetCharacter(action, args); if (character != null) { ItemManager i = character.GetComponent <ItemManager>(); if (i != null) { i.CollectItem(ItemClass.NONE, action.message, action.intValue); } else { Debug.LogWarning("Tried to collect item but no ItemManager could be found"); } } break; case EventResponseType.CONSUME_ITEM: character = GetCharacter(action, args); if (character != null) { ItemManager i = character.GetComponent <ItemManager>(); if (i != null) { i.ConsumeItem(action.message, action.intValue); } else { Debug.LogWarning("Tried to consume item but no ItemManager could be found"); } } break; case EventResponseType.ACTIVATE_ITEM: if (action.targetComponent is ActivationGroup) { ((ActivationGroup)action.targetComponent).Activate(action.message); } else { character = GetCharacter(action, args); if (character != null) { ActivationGroup a = character.GetComponentInChildren <ActivationGroup>(); if (a != null) { a.Activate(action.message); } else { Debug.LogWarning("Tried to activate item but couldn't find an ActivationGroup and none was assigned"); } } else { Debug.LogWarning("Tried to activate item but couldn't find an ActivationGroup and none was assigned"); } } break; case EventResponseType.DEACTIVATE_ITEM: if (action.targetComponent is ActivationGroup) { ((ActivationGroup)action.targetComponent).Deactivate(action.message); } else { character = GetCharacter(action, args); if (character != null) { ActivationGroup a = character.GetComponentInChildren <ActivationGroup>(); if (a != null) { a.Deactivate(action.message); } else { Debug.LogWarning("Tried to deactivate item but couldn't find an ActivationGroup and none was assigned"); } } else { Debug.LogWarning("Tried to deactivate item but couldn't find an ActivationGroup and none was assigned"); } } break; } }
/// <summary> /// Handles the character being loaded. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> virtual protected void HandleCharacterLoaded(object sender, CharacterEventArgs e) { character = e.Character; GetGroup(); }
/// <summary> /// Handles a cahracter being loaded. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> void CharacterLoaded(object sender, CharacterEventArgs e) { target = e.Character; }
/// <summary> /// Handles the character being loaded. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event args.</param> virtual protected void HandleCharacterLoaded(object sender, CharacterEventArgs e) { character = e.Character; transform.Translate(character.transform.position.x - transform.position.x, character.transform.position.y - transform.position.y, 0); }
/// <summary> /// Handles the respawned event /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Even details.</param> virtual protected void HandleRespawned(object sender, CharacterEventArgs e) { transform.Translate(character.transform.position.x - transform.position.x, character.transform.position.y - transform.position.y, 0); }
/// <summary> /// Handles the character being loaded. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event data.</param> virtual protected void HandleCharacterLoaded(object sender, CharacterEventArgs e) { character = e.Character; RegisterCharacterEvents(); }