From f338283adb93d47fc2e84767fbdea550185186e9 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Fri, 25 Feb 2022 23:36:20 +0300 Subject: [PATCH] Shooting Animations Added --- .../Enemy/Shooting Patrolling Attack.anim | 53 +++ .../Shooting Patrolling Attack.anim.meta | 8 + .../Animations/Enemy/Shooting Patrolling.anim | 53 +++ .../Enemy/Shooting Patrolling.anim.meta | 8 + .../ShootingPatrollingEnemy_0.controller | 12 + .../ShootingPatrollingEnemy_0.controller.meta | 8 + ...c Shooting Patrolling Enemy Variant.prefab | 32 ++ .../Projectiles/Basic Projectile.prefab | 2 +- Assets/Scripts/AI/ShootingEnemyAI.cs | 9 +- .../Enemies/ShootingPatrollingEnemy.aseprite | Bin 0 -> 2031 bytes .../ShootingPatrollingEnemy.aseprite.meta | 7 + .../Enemies/ShootingPatrollingEnemy.png | Bin 0 -> 1027 bytes .../Enemies/ShootingPatrollingEnemy.png.meta | 342 ++++++++++++++++++ 13 files changed, 532 insertions(+), 2 deletions(-) create mode 100644 Assets/Animations/Enemy/Shooting Patrolling Attack.anim create mode 100644 Assets/Animations/Enemy/Shooting Patrolling Attack.anim.meta create mode 100644 Assets/Animations/Enemy/Shooting Patrolling.anim create mode 100644 Assets/Animations/Enemy/Shooting Patrolling.anim.meta create mode 100644 Assets/Animations/Enemy/ShootingPatrollingEnemy_0.controller create mode 100644 Assets/Animations/Enemy/ShootingPatrollingEnemy_0.controller.meta create mode 100644 Assets/Sprites/Enemies/ShootingPatrollingEnemy.aseprite create mode 100644 Assets/Sprites/Enemies/ShootingPatrollingEnemy.aseprite.meta create mode 100644 Assets/Sprites/Enemies/ShootingPatrollingEnemy.png create mode 100644 Assets/Sprites/Enemies/ShootingPatrollingEnemy.png.meta diff --git a/Assets/Animations/Enemy/Shooting Patrolling Attack.anim b/Assets/Animations/Enemy/Shooting Patrolling Attack.anim new file mode 100644 index 0000000..ab5022f --- /dev/null +++ b/Assets/Animations/Enemy/Shooting Patrolling Attack.anim @@ -0,0 +1,53 @@ +%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: Shooting Patrolling Attack + 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: [] + 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: [] + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 1 + 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/Assets/Animations/Enemy/Shooting Patrolling Attack.anim.meta b/Assets/Animations/Enemy/Shooting Patrolling Attack.anim.meta new file mode 100644 index 0000000..7f1bef9 --- /dev/null +++ b/Assets/Animations/Enemy/Shooting Patrolling Attack.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a19cbb84a96566a46b1f1fe22265331b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animations/Enemy/Shooting Patrolling.anim b/Assets/Animations/Enemy/Shooting Patrolling.anim new file mode 100644 index 0000000..9e2e777 --- /dev/null +++ b/Assets/Animations/Enemy/Shooting Patrolling.anim @@ -0,0 +1,53 @@ +%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: Shooting Patrolling + 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: [] + 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: [] + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 1 + 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/Assets/Animations/Enemy/Shooting Patrolling.anim.meta b/Assets/Animations/Enemy/Shooting Patrolling.anim.meta new file mode 100644 index 0000000..c62377b --- /dev/null +++ b/Assets/Animations/Enemy/Shooting Patrolling.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5d5c3517990910d4b80e8c4c92b28458 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animations/Enemy/ShootingPatrollingEnemy_0.controller b/Assets/Animations/Enemy/ShootingPatrollingEnemy_0.controller new file mode 100644 index 0000000..20c38ae --- /dev/null +++ b/Assets/Animations/Enemy/ShootingPatrollingEnemy_0.controller @@ -0,0 +1,12 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!91 &9100000 +AnimatorController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: ShootingPatrollingEnemy_0 + serializedVersion: 5 + m_AnimatorParameters: [] + m_AnimatorLayers: [] diff --git a/Assets/Animations/Enemy/ShootingPatrollingEnemy_0.controller.meta b/Assets/Animations/Enemy/ShootingPatrollingEnemy_0.controller.meta new file mode 100644 index 0000000..1e114d9 --- /dev/null +++ b/Assets/Animations/Enemy/ShootingPatrollingEnemy_0.controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a5f8ced7a993ac240887b1f90e5e97e9 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 9100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Enemies/Basic Shooting Patrolling Enemy Variant.prefab b/Assets/Prefabs/Enemies/Basic Shooting Patrolling Enemy Variant.prefab index 7d66df8..c20b753 100644 --- a/Assets/Prefabs/Enemies/Basic Shooting Patrolling Enemy Variant.prefab +++ b/Assets/Prefabs/Enemies/Basic Shooting Patrolling Enemy Variant.prefab @@ -63,6 +63,14 @@ PrefabInstance: propertyPath: m_CollisionDetection value: 1 objectReference: {fileID: 0} + - target: {fileID: 2564862039932993934, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_SpriteTilingProperty.newSize.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2564862039932993934, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_SpriteTilingProperty.newSize.y + value: 1 + objectReference: {fileID: 0} - target: {fileID: 3234632762428300599, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} propertyPath: m_RootOrder value: 0 @@ -107,10 +115,34 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 4927926253738514311, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_Controller + value: + objectReference: {fileID: 9100000, guid: a5f8ced7a993ac240887b1f90e5e97e9, type: 2} + - target: {fileID: 5120716685902934120, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_SpriteTilingProperty.newSize.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5120716685902934120, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_SpriteTilingProperty.newSize.y + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7391517555913877016, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} propertyPath: m_Name value: Basic Shooting Patrolling Enemy Variant objectReference: {fileID: 0} + - target: {fileID: 8510568918136408618, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_Size.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8510568918136408618, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_Size.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8510568918136408618, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: -1349788792, guid: 1efadb39977408e45afdf46717553bba, type: 3} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: c0a2079a443363b4da73a0d425221f6c, type: 3} --- !u!4 &2215831379607469555 stripped diff --git a/Assets/Resources/Projectiles/Basic Projectile.prefab b/Assets/Resources/Projectiles/Basic Projectile.prefab index cd0d761..409a740 100644 --- a/Assets/Resources/Projectiles/Basic Projectile.prefab +++ b/Assets/Resources/Projectiles/Basic Projectile.prefab @@ -14,7 +14,7 @@ GameObject: - component: {fileID: 5084819958108693599} - component: {fileID: 6837629660644296000} - component: {fileID: 2154021251853475818} - m_Layer: 0 + m_Layer: 9 m_Name: Basic Projectile m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Scripts/AI/ShootingEnemyAI.cs b/Assets/Scripts/AI/ShootingEnemyAI.cs index 8895937..1649b01 100644 --- a/Assets/Scripts/AI/ShootingEnemyAI.cs +++ b/Assets/Scripts/AI/ShootingEnemyAI.cs @@ -20,6 +20,8 @@ namespace AI protected Transform target = null; protected bool isShooting = false; protected IMovement movement = null; + protected Animator animator = null; + protected int layerMask = ~(1 << 9); protected bool canShoot => target != null && (target.transform.position - transform.position).sqrMagnitude < attackRangeSquared; @@ -41,6 +43,7 @@ namespace AI protected virtual void Start() { movement = transform.GetComponentInParent(); + animator = transform.GetComponentInParent(); UpdateTarget(FindObjectOfType()?.transform); } @@ -57,8 +60,11 @@ namespace AI isShooting = true; float movementBaseSpeed = movement.BaseSpeed; movement.BaseSpeed = 0f; + animator.SetBool("isAttacking", true); + animator.speed = 0f; yield return new WaitForSeconds(focusingTime); + animator.speed = 1f; while (canShoot) { @@ -67,6 +73,7 @@ namespace AI yield return null; } movement.BaseSpeed = movementBaseSpeed; + animator.SetBool("isAttacking", false); isShooting = false; } @@ -77,7 +84,7 @@ namespace AI Vector3 velocity = GetVelocityForProjectile(timeForProjectileToHit); - RaycastHit2D raycastHit2D = Physics2D.Raycast(transform.position, target.position - transform.position, attackRange); + RaycastHit2D raycastHit2D = Physics2D.Raycast(transform.position, target.position - transform.position, attackRange, layerMask); if (raycastHit2D.transform != target) velocity = GetVelocityForProjectile(timeForProjectileToHit * 2); diff --git a/Assets/Sprites/Enemies/ShootingPatrollingEnemy.aseprite b/Assets/Sprites/Enemies/ShootingPatrollingEnemy.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..8632a184b216cc61a529990d234f813fe8857021 GIT binary patch literal 2031 zcmaFQ&cN_sDHnqP5GpV*GB7Zt05Jk^Fff7y8CZaj79bR8`mc|yU|U&%7Ki~cy8_rs zBNI+i2`#%FiszWf4T#*n9Brh(j1CrmK&jFI#&i4Vygmu+G(k46Q zzYKpjBkK(#=HKvh5`@*ouo%t$r>wKA|X_#{@Q7AY7m0diOs7=T7F zGW=(Psp4bcXQ-HyoN$0|+uZlR`43qv+1S)ldiDQ)+xg7L6wGwLFy3W3{J$_^gAHG8 zf~mpo1c^v}z1kO57ryZA*w?!{i}MxpN=G(rp(M$$@bsn^|9=>S@W$|qJigl8QuxZT zT$yjL#vkXst~}*sTa6j6HXC;E3LSo|wqcHM8JEOihMxZ8_7YVEFIZQzGqkzpD{KTh z>(@s{aG-*Mav>0d+|0nhgyd!c20nFs@ycRZP`ZDxB_x5T?Q zS?LU~n3DyhRoo7&{b0b5Si&IeZqCf`GQMCw?ZfvaFnqa>1A~_1RlNOPku_qz|LcVe z@9-FXIdsXi z7#LQEl!k6Y3*TkX@MXfDh*@r*`~H_bQ76d4@zAbU|L@N`&zLMQTkKauUem+>76uV= z?RFcaX2crwtP!7XS7Mt{#U6A2Sm;)kuZ>q0G+(_slLwfP|35w)V5;$p@!p>^CAiq8)Ms+D<+!vfd=;RK+;+OWOA>Xs#X# zSq~Jl$SHXmG^80(vK}8S>tQc0?6x{==6vNG)~v&J6j*4~{5p`8Pg5PeVO^lf6pUNUL5Sac-N!lE)OsrB=9gB*!jrK2F8=cm!_-C3~~>W zmrO@BI3uF#;XV3G$p3&-SK7NYsbso z3-ceZifa1hkd<%%n9ce)Upj~FR#N@dIy7g^gE|XT%p%HK9$-}kE^Fb*R6-#!_Ur%r^UoU$JA8G&I{be4?m$!Fs@9pj zhi`m2aAomo*UQEkSMy^+Pj3J@!j311naRQI@T*roO|KSaB}nM?y%RI3m3X%3xU!u! r|5q`?J2$VMV=xg1mVy%`_`bq}(X4#I>Z6O;*YGi1o|Lt3C?-z;hM>iI literal 0 HcmV?d00001 diff --git a/Assets/Sprites/Enemies/ShootingPatrollingEnemy.aseprite.meta b/Assets/Sprites/Enemies/ShootingPatrollingEnemy.aseprite.meta new file mode 100644 index 0000000..fbd3d2d --- /dev/null +++ b/Assets/Sprites/Enemies/ShootingPatrollingEnemy.aseprite.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 758415e4d54d56144944f456ea7349ef +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/Enemies/ShootingPatrollingEnemy.png b/Assets/Sprites/Enemies/ShootingPatrollingEnemy.png new file mode 100644 index 0000000000000000000000000000000000000000..66618e8bc6699c612ce9c9ae09fa6558f74c4eb6 GIT binary patch literal 1027 zcmV+e1pNDnP)Px&y-7qtRA_bkjjYlyXk3!nab~K1yCm=|^sD9f4 z^a`&N5Hw#D!|Y3`vPK_O0N80L0D$?)am@djNdf?K(@WjTCs1^vpI8J?0bn*B)di=) z01&$YG$vpH?gaD+-<5vd3ZyWSX&DoQ2VMf&EcP+qmHw`rfp!TD3f~R7_7VA4pc}yR zy<~*6vTz`rOd*C`N9LWAy%YS9}(4vrk;>Cx#?M?@I)LNklFZ!s2Pm z&7F&+^My|MTK|_^xA#0<{uD(iBdnit*{`sU{BZT2j}r}5bWAgJ_>bc)oXxk*RB30?#w+2mV>R(%KR2bv(@$8`UTuCYyH3j7d%K+ME)MC30_okkUgphl&tDR8>E6JF!k*@;W32?HK2q%9>F5phT x=^A6_2eNfM_`oN*NQi_JvhGLAd(git{%=oq2IeJd)6oC`002ovPDHLkV1nL(