Skip to content

Commit

Permalink
Enemy Death Animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vertigo2720 committed Apr 30, 2019
1 parent 8e83179 commit 4d5d047
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 25 deletions.
42 changes: 21 additions & 21 deletions Assets/Animations/FadeOut.anim
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ AnimationClip:
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
Expand Down Expand Up @@ -336,7 +336,7 @@ AnimationClip:
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
Expand Down Expand Up @@ -534,7 +534,7 @@ AnimationClip:
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Particle System
path: MovementEffect
classID: 1
script: {fileID: 0}
m_PPtrCurves: []
Expand Down Expand Up @@ -566,6 +566,20 @@ AnimationClip:
typeID: 212
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 86906294
attribute: 4215373228
script: {fileID: 0}
typeID: 212
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 86906294
attribute: 2334886179
script: {fileID: 0}
typeID: 212
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 86906294
attribute: 304273561
Expand All @@ -588,7 +602,7 @@ AnimationClip:
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 922205677
path: 187357077
attribute: 2086281974
script: {fileID: 0}
typeID: 1
Expand Down Expand Up @@ -643,20 +657,6 @@ AnimationClip:
typeID: 212
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 86906294
attribute: 4215373228
script: {fileID: 0}
typeID: 212
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 86906294
attribute: 2334886179
script: {fileID: 0}
typeID: 212
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 3911917848
attribute: 2526845255
Expand Down Expand Up @@ -1050,7 +1050,7 @@ AnimationClip:
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
Expand Down Expand Up @@ -1078,7 +1078,7 @@ AnimationClip:
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
Expand Down Expand Up @@ -1276,7 +1276,7 @@ AnimationClip:
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Particle System
path: MovementEffect
classID: 1
script: {fileID: 0}
m_EulerEditorCurves: []
Expand Down
2 changes: 1 addition & 1 deletion Assets/Animations/Player.controller
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
Expand Down
104 changes: 103 additions & 1 deletion Assets/Prefabs/Enemies/EnemyPrefab.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ GameObject:
- component: {fileID: 1872908493}
- component: {fileID: 1872908494}
- component: {fileID: -6911162521525427796}
- component: {fileID: 1728266495278993848}
m_Layer: 9
m_Name: EnemyPrefab
m_TagString: Enemy
Expand All @@ -43,6 +44,7 @@ Transform:
m_Children:
- {fileID: 3579085367688188161}
- {fileID: 9092254529329041504}
- {fileID: 7991722935139464824}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -142,6 +144,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5493f83ebc998d42bbffb399f8d58cc, type: 3}
m_Name:
m_EditorClassIdentifier:
DeathSound: {fileID: 8300000, guid: 9378110c644b8e24ab87f1a48e5fda0f, type: 3}
CanDie: 1
--- !u!114 &2698188209980429850
MonoBehaviour:
Expand Down Expand Up @@ -345,6 +348,25 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!95 &1728266495278993848
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3600171806446077816}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 7a23da44abe99174bb5b2e2919f6d493, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!1 &8645085800693663213
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -356,7 +378,7 @@ GameObject:
- component: {fileID: 3579085367688188161}
- component: {fileID: 3020919942879555487}
m_Layer: 9
m_Name: Sprite
m_Name: New Sprite
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -424,6 +446,86 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1001 &5121510740274167382
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 8373896260879854672}
m_Modifications:
- target: {fileID: 2960013453429452165, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_Name
value: SadBoyExplosion
objectReference: {fileID: 0}
- target: {fileID: 2960013453429452165, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalPosition.x
value: 0.64267373
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalPosition.y
value: 2.3625278
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalPosition.z
value: 0.7953651
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b85289b1734de5847b6c8f12689a8e04, type: 3}
--- !u!4 &7991722935139464824 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3025028379963803694, guid: b85289b1734de5847b6c8f12689a8e04,
type: 3}
m_PrefabInstance: {fileID: 5121510740274167382}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &6118633295177230143
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
1 change: 1 addition & 0 deletions Assets/Prefabs/Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5493f83ebc998d42bbffb399f8d58cc, type: 3}
m_Name:
m_EditorClassIdentifier:
DeathSound: {fileID: 0}
CanDie: 1
--- !u!114 &503392398
MonoBehaviour:
Expand Down
6 changes: 6 additions & 0 deletions Assets/Scripts/DeathComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(AudioSource))]
public class DeathComponent : MonoBehaviour
{
public AudioClip DeathSound;
public delegate void HandleDied();
public HandleDied RaiseDied;
private AudioSource AudioSource;

[Tooltip("Because what's a death component without the ability to not die")]
public bool CanDie = true;
Expand All @@ -14,10 +17,13 @@ public class DeathComponent : MonoBehaviour
/// Indicate the object has died
/// </summary>
/// <param name="Instigator">Obeject ultimately responsible for the death</param>
///
public void Died(GameObject Instigator)
{
AudioSource = GetComponent<AudioSource>();
if (CanDie)
{
AudioSource.PlayOneShot(DeathSound);
RaiseDied?.Invoke();
}
}
Expand Down
11 changes: 9 additions & 2 deletions Assets/Scripts/EnemyScripts/EnemyControllerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,21 @@ protected void AbortBehaviors()
{
CurrentBehaviorSet?.Behaviors.Where(b => b.ShouldAbort).ToList().ForEach(b => b.Abort());
}

/// <summary>
/// Death Animation???
/// </summary>
protected void DeathAnimation()
{
GetComponent<Animator>().SetTrigger("Death");
}
/// <summary>
/// Death logic
/// </summary>
protected void Died()
{
AbortBehaviors();
DeathAnimation();
// Lolded
Destroy(gameObject);
Destroy(gameObject, 1f);
}
}

0 comments on commit 4d5d047

Please sign in to comment.