From bbf61229adc33d8114035ccf8aadb241ade0a304 Mon Sep 17 00:00:00 2001 From: dart Date: Sun, 3 Apr 2022 04:30:57 +0300 Subject: [PATCH] Explosion effect --- ldjam50/Assets/Prefabs/character.prefab | 5 +- ldjam50/Assets/Prefabs/mob.prefab | 1 + ldjam50/Assets/Scripts/Mob.cs | 24 +++-- .../Assets/Sprites/Effects/Expl32.png.meta | 2 +- .../Assets/Sprites/Effects/ExplAnimation.anim | 89 +++++++++++++++++++ .../Sprites/Effects/ExplAnimation.anim.meta | 8 ++ .../StandartEnemyAnimController.controller | 65 +++++++++++++- 7 files changed, 183 insertions(+), 11 deletions(-) create mode 100644 ldjam50/Assets/Sprites/Effects/ExplAnimation.anim create mode 100644 ldjam50/Assets/Sprites/Effects/ExplAnimation.anim.meta diff --git a/ldjam50/Assets/Prefabs/character.prefab b/ldjam50/Assets/Prefabs/character.prefab index 7a792ef..a9cb871 100644 --- a/ldjam50/Assets/Prefabs/character.prefab +++ b/ldjam50/Assets/Prefabs/character.prefab @@ -72,12 +72,12 @@ SpriteRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 - m_Sprite: {fileID: -1807468758588214948, guid: fc9a004f37844d541878fe6e00978d9e, type: 3} + m_Sprite: {fileID: 21300000, guid: 1ea3e1dc227afc0768a58ae84d17e6c5, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 m_DrawMode: 0 - m_Size: {x: 1, y: 1} + m_Size: {x: 1.16, y: 1.15} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 m_WasSpriteAssigned: 1 @@ -178,6 +178,7 @@ MonoBehaviour: damage: 10 moveSpeed: 0.02 characterSprite: {fileID: 1199223373439478175} + characterAnimator: {fileID: 0} --- !u!50 &3826968412464473223 Rigidbody2D: serializedVersion: 4 diff --git a/ldjam50/Assets/Prefabs/mob.prefab b/ldjam50/Assets/Prefabs/mob.prefab index 5c22dcc..bdab34b 100644 --- a/ldjam50/Assets/Prefabs/mob.prefab +++ b/ldjam50/Assets/Prefabs/mob.prefab @@ -74,6 +74,7 @@ MonoBehaviour: m_EditorClassIdentifier: characterObject: {fileID: 0} overMind: {fileID: 0} + mobSprite: {fileID: 6540482753690656168} moveSpeed: 0 health: 0 damage: 0 diff --git a/ldjam50/Assets/Scripts/Mob.cs b/ldjam50/Assets/Scripts/Mob.cs index 32340c4..6c082ac 100644 --- a/ldjam50/Assets/Scripts/Mob.cs +++ b/ldjam50/Assets/Scripts/Mob.cs @@ -9,8 +9,8 @@ public class Mob : MonoBehaviour { [SerializeField] private GameObject characterObject; [SerializeField] private OverMind overMind; - [SerializeField] private Sprite mobAnimController; - [SerializeField] private Sprite mobDeathAnimController; + [SerializeField] private GameObject mobSprite; + private Animator mobAnimator; [SerializeField] private float moveSpeed; [SerializeField] private float health; @@ -21,6 +21,11 @@ public class Mob : MonoBehaviour [SerializeField] private TextMesh healthText; + private void Start() + { + mobAnimator = mobSprite.GetComponent(); + } + public void ApplyDamage(float damage) { health -= damage; @@ -84,14 +89,21 @@ void OnTriggerEnter2D(Collider2D col) if (col.gameObject.CompareTag("Character")) { characterObject.GetComponent().SendMessage("ApplyDamage", damage); - - // mobAnimController = mobDeathAnimController; - overMind.DeathGoToPull(gameObject); + + mobAnimator.SetBool("IsDeath", true); + StartCoroutine(waiter()); + //overMind.DeathGoToPull(gameObject); } // Debug.Log("PIZDAAAAAA"); } - + + IEnumerator waiter() + { + yield return new WaitForSecondsRealtime(0.5f); + overMind.DeathGoToPull(gameObject); + } + public void SetupMob(OverMind.MobParameters mobParameters) { characterObject = mobParameters.Character; diff --git a/ldjam50/Assets/Sprites/Effects/Expl32.png.meta b/ldjam50/Assets/Sprites/Effects/Expl32.png.meta index 190acf8..52f07bc 100644 --- a/ldjam50/Assets/Sprites/Effects/Expl32.png.meta +++ b/ldjam50/Assets/Sprites/Effects/Expl32.png.meta @@ -70,7 +70,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 + spritePixelsToUnits: 32 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 diff --git a/ldjam50/Assets/Sprites/Effects/ExplAnimation.anim b/ldjam50/Assets/Sprites/Effects/ExplAnimation.anim new file mode 100644 index 0000000..8fa6350 --- /dev/null +++ b/ldjam50/Assets/Sprites/Effects/ExplAnimation.anim @@ -0,0 +1,89 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: ExplAnimation + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: [] + m_ScaleCurves: [] + m_FloatCurves: [] + m_PPtrCurves: + - curve: + - time: 0 + value: {fileID: 4455830272222587326, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - time: 0.06666667 + value: {fileID: 8855754954285246910, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - time: 0.13333334 + value: {fileID: -5608497299007999723, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - time: 0.2 + value: {fileID: 5140774079673320405, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - time: 0.26666668 + value: {fileID: -7448463022687376513, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - time: 0.33333334 + value: {fileID: 7781227294636230676, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - time: 0.4 + value: {fileID: -5688838636644343198, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - time: 0.46666667 + value: {fileID: 5139373333517102986, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + attribute: m_Sprite + path: + classID: 212 + script: {fileID: 0} + m_SampleRate: 60 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: + - serializedVersion: 2 + path: 0 + attribute: 0 + script: {fileID: 0} + typeID: 212 + customType: 23 + isPPtrCurve: 1 + pptrCurveMapping: + - {fileID: 4455830272222587326, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - {fileID: 8855754954285246910, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - {fileID: -5608497299007999723, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - {fileID: 5140774079673320405, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - {fileID: -7448463022687376513, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - {fileID: 7781227294636230676, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - {fileID: -5688838636644343198, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + - {fileID: 5139373333517102986, guid: f9067497a04eb314cb36ade16f7816c0, type: 3} + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 0.48333335 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 0 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: [] + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 0 + m_HasMotionFloatCurves: 0 + m_Events: [] diff --git a/ldjam50/Assets/Sprites/Effects/ExplAnimation.anim.meta b/ldjam50/Assets/Sprites/Effects/ExplAnimation.anim.meta new file mode 100644 index 0000000..c19d3ce --- /dev/null +++ b/ldjam50/Assets/Sprites/Effects/ExplAnimation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f4b517d0e48d6aaa5ae0b063c62202e7 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ldjam50/Assets/Sprites/Enemies/Standart/StandartEnemyAnimController.controller b/ldjam50/Assets/Sprites/Enemies/Standart/StandartEnemyAnimController.controller index f33fd4a..df85a5a 100644 --- a/ldjam50/Assets/Sprites/Enemies/Standart/StandartEnemyAnimController.controller +++ b/ldjam50/Assets/Sprites/Enemies/Standart/StandartEnemyAnimController.controller @@ -10,7 +10,8 @@ AnimatorState: m_Name: Run m_Speed: 1 m_CycleOffset: 0 - m_Transitions: [] + m_Transitions: + - {fileID: 319439843011162356} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -34,7 +35,13 @@ AnimatorController: m_PrefabAsset: {fileID: 0} m_Name: StandartEnemyAnimController serializedVersion: 5 - m_AnimatorParameters: [] + m_AnimatorParameters: + - m_Name: IsDeath + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -48,6 +55,57 @@ AnimatorController: m_IKPass: 0 m_SyncedLayerAffectsTiming: 0 m_Controller: {fileID: 9100000} +--- !u!1101 &319439843011162356 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: IsDeath + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1633349003487912558} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.5 + m_HasExitTime: 1 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1102 &1633349003487912558 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: ExplAnimation + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: f4b517d0e48d6aaa5ae0b063c62202e7, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: --- !u!1107 &8214928845230017319 AnimatorStateMachine: serializedVersion: 6 @@ -60,6 +118,9 @@ AnimatorStateMachine: - serializedVersion: 1 m_State: {fileID: -1351690705070559544} m_Position: {x: 280, y: 110, z: 0} + - serializedVersion: 1 + m_State: {fileID: 1633349003487912558} + m_Position: {x: 280, y: -40, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: []