private void LoadAnimationIntoCache(string modelKey) { // Builds the animation object for all model, action, direction // combinations. Object is then added to the AnimationCache. AnimationCache animationCache = AnimationCache.Instance; foreach (BaseAction directionalAction in _directionalActions) { // Use the respective importer for the action IAnimationImporter animationImporter = directionalAction.GetAnimationImporter(); var newAnimations = animationImporter.ImportAnimations(modelKey, DirectionType.Down); foreach (AnimationDNABlock newAnimation in newAnimations) { string animationKey = $"{modelKey}_{directionalAction.AnimationTag}_{DirectionType.GetAnimationForDirection(newAnimation.Direction)}"; animationCache.Add(animationKey, newAnimation); } } // The "Idle" action reuses the first image of the death animation, so we need // to import the first frame of all death sprites without a direction tag. BaseAction deathAnimation = new DeathAction(); var deathImporter = deathAnimation.GetAnimationImporter(); var deathAnimations = deathImporter.ImportAnimations(modelKey, DirectionType.None); foreach (AnimationDNABlock newAnimation in deathAnimations) { string animationKey = $"{modelKey}_{deathAnimation.AnimationTag}"; animationCache.Add(animationKey, newAnimation); } }
/// <summary> /// Does a death action. /// </summary> /// <param name="action">Action.</param> virtual protected IEnumerator DoDeathAction(DeathAction action) { // Wait... if (action.delay > 0) { yield return(new WaitForSeconds(action.delay)); } // Then act switch (action.actionType) { case DeathActionType.DESTROY_CHARACTER: Destroy(character.gameObject); break; case DeathActionType.RESPAWN: Debug.LogError("RESPAWN is not supported by the GameOverScreen"); break; case DeathActionType.RELOAD_SCENE: #if !UNITY_4_6 && !UNITY_5_1 && !UNITY_5_2 SceneManager.LoadScene(SceneManager.GetActiveScene().name); #else Application.LoadLevel(Application.loadedLevel); #endif break; case DeathActionType.LOAD_ANOTHER_SCENE: #if !UNITY_4_6 && !UNITY_5_1 && !UNITY_5_2 LevelManager.PreviousLevel = SceneManager.GetActiveScene().name; SceneManager.LoadScene(action.supportingData); #else LevelManager.PreviousLevel = Application.loadedLevelName; Application.LoadLevel(action.supportingData); #endif break; case DeathActionType.SEND_MESSAGE: action.supportingGameObject.SendMessage(action.supportingData, SendMessageOptions.DontRequireReceiver); break; case DeathActionType.CLEAR_RESPAWN_POINTS: if (LevelManager.Instance != null) { LevelManager.Instance.ClearRespawns(); } break; case DeathActionType.RESET_DATA: foreach (Persistable persistable in action.supportingGameObject.GetComponents <Persistable>()) { persistable.ResetSaveData(); } break; } }
public void LoadAnimationIntoCache(string modelKey) { /* * Builds the animation object for all model, action, direction * combinations. Object is then added to the AnimationCache. */ AnimationCache animationStore = AnimationCache.Instance; // All directional actions List <BaseAction> directionalActions = new List <BaseAction>(); directionalActions.Add(new SlashAction()); directionalActions.Add(new SpellcastAction()); directionalActions.Add(new ThrustAction()); directionalActions.Add(new WalkAction()); directionalActions.Add(new ShootAction()); directionalActions.Add(new DeathAction()); foreach (BaseAction actionAnimation in directionalActions) { // Use the respective importer for the action IAnimationImporter importer = actionAnimation.GetAnimationImporter(); List <AnimationDNABlock> newAnimations = importer.ImportAnimations(modelKey, DirectionType.DOWN); foreach (AnimationDNABlock newAnimation in newAnimations) { string animationKey = String.Format("{0}_{1}_{2}", modelKey, actionAnimation.GetAnimationTag(), DirectionType.GetAnimationForDirection(newAnimation.Direction)); animationStore.Add(animationKey, newAnimation); } } // The "Idle" action reuses the first image of the death animation, so we need // to import the first frame of all death sprites without a direction tag. BaseAction deathAnimation = new DeathAction(); IAnimationImporter deathImporter = deathAnimation.GetAnimationImporter(); List <AnimationDNABlock> deathAnimations = deathImporter.ImportAnimations(modelKey, DirectionType.NONE); foreach (AnimationDNABlock newAnimation in deathAnimations) { string animationKey = String.Format("{0}_{1}", modelKey, deathAnimation.GetAnimationTag()); animationStore.Add(animationKey, newAnimation); } }
void TriggerReap(Card card) { var action = new DeathAction(card); container.AddReaction(action); }