diff --git a/Assets/Prefabs/Enemies/Enemy (Armadillo).prefab b/Assets/Prefabs/Enemies/Enemy (Armadillo).prefab index 488a8b5..8cfc548 100644 --- a/Assets/Prefabs/Enemies/Enemy (Armadillo).prefab +++ b/Assets/Prefabs/Enemies/Enemy (Armadillo).prefab @@ -173,7 +173,7 @@ MonoBehaviour: m_EditorClassIdentifier: SearchLayerMask: serializedVersion: 2 - m_Bits: 6145 + m_Bits: 4097 Radius: 6.5 ForgetRadius: 10 ForgetTimer: 1 diff --git a/Assets/Prefabs/Enemies/Enemy (Crab).prefab b/Assets/Prefabs/Enemies/Enemy (Crab).prefab index 55b02c0..37c3365 100644 --- a/Assets/Prefabs/Enemies/Enemy (Crab).prefab +++ b/Assets/Prefabs/Enemies/Enemy (Crab).prefab @@ -193,7 +193,7 @@ MonoBehaviour: m_EditorClassIdentifier: SearchLayerMask: serializedVersion: 2 - m_Bits: 6145 + m_Bits: 4097 Radius: 5 ForgetRadius: 6 ForgetTimer: 0 diff --git a/Assets/Prefabs/Enemies/Enemy (MobCat).prefab b/Assets/Prefabs/Enemies/Enemy (MobCat).prefab index d97af77..5cc405b 100644 --- a/Assets/Prefabs/Enemies/Enemy (MobCat).prefab +++ b/Assets/Prefabs/Enemies/Enemy (MobCat).prefab @@ -387,7 +387,7 @@ MonoBehaviour: m_EditorClassIdentifier: SearchLayerMask: serializedVersion: 2 - m_Bits: 6145 + m_Bits: 4097 Radius: 8 ForgetRadius: 10 ForgetTimer: 0.5 diff --git a/Assets/Prefabs/Enemies/Enemy (Stompy).prefab b/Assets/Prefabs/Enemies/Enemy (Stompy).prefab new file mode 100644 index 0000000..cc271cd --- /dev/null +++ b/Assets/Prefabs/Enemies/Enemy (Stompy).prefab @@ -0,0 +1,472 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &625748391495567275 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2854973662706080519} + - component: {fileID: 8122426731236002160} + - component: {fileID: 972927098289247134} + m_Layer: 0 + m_Name: Behaviour Display + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &2854973662706080519 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 625748391495567275} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.5, z: 0} + m_LocalScale: {x: 0.14999999, y: 0.14999999, z: 0.14999999} + m_Children: [] + m_Father: {fileID: 9068290227530804530} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &8122426731236002160 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 625748391495567275} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!102 &972927098289247134 +TextMesh: + serializedVersion: 3 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 625748391495567275} + m_Text: Hello World + m_OffsetZ: 0 + m_CharacterSize: 1 + m_LineSpacing: 1 + m_Anchor: 7 + m_Alignment: 0 + m_TabSize: 4 + m_FontSize: 0 + m_FontStyle: 0 + m_RichText: 1 + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_Color: + serializedVersion: 2 + rgba: 4294967295 +--- !u!1 &947970086354063522 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5157957521057034554} + - component: {fileID: 2509242968095414871} + m_Layer: 0 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5157957521057034554 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 947970086354063522} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 3, y: 3, z: 1} + m_Children: [] + m_Father: {fileID: 3089339161110515848} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &2509242968095414871 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 947970086354063522} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 03e6674a6969c5845b4d97a399c6a451, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: -947994997 + m_SortingLayer: 4 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 472874229c563e241bddc073ec2dbb90, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.5, y: 0.5} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!1 &7172521024034220328 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 9068290227530804530} + - component: {fileID: 6199689478484427753} + - component: {fileID: 2512220210600837749} + - component: {fileID: 8240867962699730048} + - component: {fileID: 1971343437007019825} + - component: {fileID: 3298507242274295284} + - component: {fileID: 812213791234167771} + - component: {fileID: 2207273045917293418} + - component: {fileID: 929886959371984162} + - component: {fileID: 1597248706952749124} + - component: {fileID: 306204271235849982} + - component: {fileID: 1868612617685668102} + - component: {fileID: 4780531466307745383} + - component: {fileID: 2085473810787565586} + m_Layer: 0 + m_Name: Enemy (Stompy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &9068290227530804530 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 3089339161110515848} + - {fileID: 2854973662706080519} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!50 &6199689478484427753 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 8 + m_LinearDrag: 8 + m_AngularDrag: 0 + m_GravityScale: 1 + m_Material: {fileID: 0} + m_Interpolate: 1 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 4 +--- !u!114 &2512220210600837749 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e796ba4c6f7efc449a10ed13ee42e34f, type: 3} + m_Name: + m_EditorClassIdentifier: + BobbedTransform: {fileID: 3089339161110515848} + BobbingMultiplier: 1 + BobbingGravity: 0.8 + BobbingLaunchSpeed: 0.12 + BobbingFrequency: 0 + BobbingDirection: {x: 0, y: 1} +--- !u!114 &8240867962699730048 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e649a6c117e18e1468ebe26330904cc8, type: 3} + m_Name: + m_EditorClassIdentifier: + Variety: 0.05 + Movement: {fileID: 1971343437007019825} + Bobbing: {fileID: 2512220210600837749} +--- !u!114 &1971343437007019825 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ba61752571d0d70478c63122f73914db, type: 3} + m_Name: + m_EditorClassIdentifier: + Bobbing: {fileID: 2512220210600837749} + Direction: {x: 0, y: 0} + MaxSpeed: 2.5 + AccelerationSpeed: 10 + DecelerationSpeed: 10 + AnimationSpeedModifier: 0 + AnimationSpeed: 0 +--- !u!114 &3298507242274295284 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a2110188365a59e4cb31d0e84789fbbd, type: 3} + m_Name: + m_EditorClassIdentifier: + BodypartPrefabs: + - {fileID: 90224928841595158, guid: fdbfbe32f3b9e014e9a8da46701b8c40, type: 3} + - {fileID: 1686931270822509091, guid: d9c92df0020929b47bc70b345f15ae8a, type: 3} + - {fileID: 6593460322437365382, guid: 3ea043b2b1dd80f45bb8198c3e7ada37, type: 3} + DebugExplode: 0 + ParticlesPerBodypart: 90 + BodypartMinCount: 5 + BodypartMaxCount: 7 + DebrisType: 0 + IsFurniture: 0 +--- !u!114 &812213791234167771 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7d43d0a4a6d1e2d46a74083bdecde13e, type: 3} + m_Name: + m_EditorClassIdentifier: + MaxHealth: 60 + CurrentHealth: 60 +--- !u!114 &2207273045917293418 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 173be6658a5fcba49b9b1f1c91fa5f33, type: 3} + m_Name: + m_EditorClassIdentifier: + SearchLayerMask: + serializedVersion: 2 + m_Bits: 4097 + Radius: 5 + ForgetRadius: 7 + ForgetTimer: 1 +--- !u!114 &929886959371984162 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 978bec54408eb8f42a36fd68d7447f5a, type: 3} + m_Name: + m_EditorClassIdentifier: + BehaviourDisplay: {fileID: 972927098289247134} + CurrentBehaviour: Nothing +--- !u!114 &1597248706952749124 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f7e23822f429fcc46a8fd9163e68f332, type: 3} + m_Name: + m_EditorClassIdentifier: + CurrentStatus: + Target: {fileID: 0} + CloseEnoughRadius: 2 + TargetPositionUpdateFrequency: 5 +--- !u!114 &306204271235849982 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bf838f73fb74f0046a5b6a86994c54ed, type: 3} + m_Name: + m_EditorClassIdentifier: + CurrentStatus: + MaxWalkingDistance: 5 + MinWalkingDistance: 2 + SubjectRadius: 1.5 + StopLength: 0.5 +--- !u!114 &1868612617685668102 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 73e92e72273f3c14986dd6fd574e03d1, type: 3} + m_Name: + m_EditorClassIdentifier: + CurrentStatus: + StompCooldown: 1.5 + StompDuration: 0.5 + StompExplosionTime: 0.25 + StompRadius: 2 + LoweredStompCooldown: 0.5 + LoweredStompCooldownRadius: 2.5 +--- !u!114 &4780531466307745383 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: db74dd1ea4837b04d9443f70b8fc1cec, type: 3} + m_Name: + m_EditorClassIdentifier: + Anim: {fileID: 0} +--- !u!58 &2085473810787565586 +CircleCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7172521024034220328} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + serializedVersion: 2 + m_Radius: 0.85 +--- !u!1 &8171859270208828205 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3089339161110515848} + m_Layer: 0 + m_Name: Bobbing Root + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3089339161110515848 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8171859270208828205} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 5157957521057034554} + m_Father: {fileID: 9068290227530804530} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Prefabs/Enemies/Enemy (Stompy).prefab.meta b/Assets/Prefabs/Enemies/Enemy (Stompy).prefab.meta new file mode 100644 index 0000000..2d243a5 --- /dev/null +++ b/Assets/Prefabs/Enemies/Enemy (Stompy).prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9c4657113b9708549a11cb06e07f0b7d +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/AI/Behaviours/Stomp.cs b/Assets/Scripts/AI/Behaviours/Stomp.cs new file mode 100644 index 0000000..8416a4d --- /dev/null +++ b/Assets/Scripts/AI/Behaviours/Stomp.cs @@ -0,0 +1,96 @@ +using UnityEngine; +using Saltosion.OneWeapon.Enemies; +using Saltosion.OneWeapon.Effects; + +namespace Saltosion.OneWeapon.AI.Behaviours { + enum StompState { + ReadyToStomp, + PreparingStomp, + RecoveringFromStomp, + CoolingDown, + } + + [RequireComponent(typeof(Follow))] + public class Stomp : AIBehaviour { + public float StompCooldown; + [Tooltip("How long the stomp animation is")] + public float StompDuration; + [Tooltip("If StompDuration is 1.0 and this is 0.75, the stomp explosion will happen after the first 3/4ths of the stomp animation.")] + public float StompExplosionTime; + public float StompRadius; + public float LoweredStompCooldown; + public float LoweredStompCooldownRadius; + + public bool Stomping { get { return State == StompState.PreparingStomp || State == StompState.RecoveringFromStomp; } } + public bool CoolingDown { get { return State == StompState.CoolingDown; } } + + private float CurrentCooldown; + private StompState State = StompState.ReadyToStomp; + + private Follow FollowBehaviour; + + private void Start() { + FollowBehaviour = GetComponent(); + } + + private void Update() { + if (CurrentCooldown > 0) { + CurrentCooldown -= Time.deltaTime; + } else { + // This is reached every time the cooldown reaches zero, for one frame + // (except when ReadyToStomp, when this is called every loop until the next stomp, + // since then the cooldown isn't reset to something >0) + switch (State) { + case StompState.PreparingStomp: + // TODO(jens): Consider adding squish and stretch animation for this + CurrentStatus = "STOMP"; + DoStomp(); + CurrentCooldown = StompDuration - StompExplosionTime; + State = StompState.RecoveringFromStomp; + break; + case StompState.RecoveringFromStomp: + CurrentStatus = "CoolingDown"; + CurrentCooldown = GetDistance() < LoweredStompCooldownRadius ? LoweredStompCooldown : StompCooldown; + State = StompState.CoolingDown; + break; + case StompState.CoolingDown: + CurrentStatus = "CooledDown"; + State = StompState.ReadyToStomp; + break; + case StompState.ReadyToStomp: + CurrentStatus = "ReadyToStomp"; + break; + } + } + + } + + public override bool CanBehave() { + return State != StompState.CoolingDown; + } + + public override void Execute() { + if (State == StompState.ReadyToStomp) { + CurrentCooldown = StompExplosionTime; + State = StompState.PreparingStomp; + CurrentStatus = "Stomping"; + } + } + + private float GetDistance() { + return FollowBehaviour.Target == null ? float.PositiveInfinity : (FollowBehaviour.Target.position - transform.position).magnitude; + } + + private void DoStomp() { + Debug.Log("STOMP"); + Camera.main.GetComponent().ScreenShake(7f); + } + + private void OnDrawGizmosSelected() { + Gizmos.color = new Color(1f, 0f, 0f, 0.3f); + Gizmos.DrawWireSphere(transform.position, LoweredStompCooldownRadius); + Gizmos.color = Color.red; + Gizmos.DrawWireSphere(transform.position, StompRadius); + } + } +} diff --git a/Assets/Scripts/AI/Behaviours/Stomp.cs.meta b/Assets/Scripts/AI/Behaviours/Stomp.cs.meta new file mode 100644 index 0000000..68f91bc --- /dev/null +++ b/Assets/Scripts/AI/Behaviours/Stomp.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 73e92e72273f3c14986dd6fd574e03d1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Enemies/Stompy.cs b/Assets/Scripts/Enemies/Stompy.cs new file mode 100644 index 0000000..9f90104 --- /dev/null +++ b/Assets/Scripts/Enemies/Stompy.cs @@ -0,0 +1,56 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Saltosion.OneWeapon.AI.Behaviours; +using Saltosion.OneWeapon.AI.Triggers; + +namespace Saltosion.OneWeapon.Enemies { + [RequireComponent(typeof(Enemy))] + [RequireComponent(typeof(PlayerSighted))] + [RequireComponent(typeof(Wander))] + [RequireComponent(typeof(Follow))] + [RequireComponent(typeof(Stomp))] + public class Stompy : MonoBehaviour { + public Animator Anim; + + private Enemy Enemy; + private PlayerSighted FollowTrigger; + private Wander WanderBehaviour; + private Follow FollowBehaviour; + private Stomp StompBehaviour; + + private void Start() { + Enemy = GetComponent(); + FollowTrigger = GetComponent(); + WanderBehaviour = GetComponent(); + FollowBehaviour = GetComponent(); + StompBehaviour = GetComponent(); + } + + private void Update() { + Enemy.CurrentBehaviour = ""; + if (FollowTrigger.IsTriggered()) { + FollowBehaviour.Target = FollowTrigger.Player.transform; + if (StompBehaviour.CanBehave()) { + // If seeing the player and stomping is possible, stomp + StompBehaviour.Execute(); + } else if (!StompBehaviour.Stomping) { + // If seeing the player but stomping was not possible, and am currently not stomping, + // get closer to the player. + FollowBehaviour.TryExecute(); + } + Enemy.CurrentBehaviour = "Stomp:" + StompBehaviour.CurrentStatus + ", " + "Follow:" + FollowBehaviour.CurrentStatus; + } else if (WanderBehaviour.TryExecute()) { + Enemy.CurrentBehaviour = "Wander:" + WanderBehaviour.CurrentStatus; + } + + /* TODO: Implement animations for Stompy + if (StompBehaviour.Stomping) { + Anim.Play("Attack"); + } else { + Anim.Play("Walk"); + } + Anim.SetFloat("Speed", Enemy.Movement.AnimationSpeed);*/ + } + } +} diff --git a/Assets/Scripts/Enemies/Stompy.cs.meta b/Assets/Scripts/Enemies/Stompy.cs.meta new file mode 100644 index 0000000..abbc64d --- /dev/null +++ b/Assets/Scripts/Enemies/Stompy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: db74dd1ea4837b04d9443f70b8fc1cec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: