Add armadillo behaviours

This commit is contained in:
Jens Pitkänen 2019-08-14 22:31:58 +03:00
parent 3227d41ef5
commit 0352309b97
23 changed files with 934 additions and 37 deletions

View File

@ -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
@ -62,7 +62,7 @@ AnimatorState:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Roll
m_Speed: 1
m_Speed: 3
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []

View File

@ -0,0 +1,499 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &592487110401094192
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 592487110401094196}
- component: {fileID: 592487110401094195}
- component: {fileID: 592487110401094194}
- component: {fileID: 592487110401094200}
- component: {fileID: 3068808787720623988}
- component: {fileID: 4248768674552437703}
- component: {fileID: 592487110401094193}
- component: {fileID: 3362493323285318061}
- component: {fileID: 5951030530186631518}
- component: {fileID: 2001250142692207685}
- component: {fileID: 5237857222030341603}
- component: {fileID: 51880594498256973}
m_Layer: 0
m_Name: Enemy (Armadillo)
m_TagString: Enemy
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &592487110401094196
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
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: 1801310824674407730}
- {fileID: 7620644064869685210}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &592487110401094195
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 1
m_UseAutoMass: 0
m_Mass: 5
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!61 &592487110401094194
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
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}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 0.8}
m_EdgeRadius: 0
--- !u!114 &592487110401094200
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 978bec54408eb8f42a36fd68d7447f5a, type: 3}
m_Name:
m_EditorClassIdentifier:
Movement: {fileID: 4248768674552437703}
BehaviourDisplay: {fileID: 8912829886182716132}
CurrentBehaviour: Nothing
--- !u!114 &3068808787720623988
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e796ba4c6f7efc449a10ed13ee42e34f, type: 3}
m_Name:
m_EditorClassIdentifier:
BobbedTransform: {fileID: 1801310824674407730}
BobbingMultiplier: 1
BobbingGravity: 0.8
BobbingLaunchSpeed: 0.12
BobbingFrequency: 0
BobbingDirection: {x: 0, y: 1}
--- !u!114 &4248768674552437703
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ba61752571d0d70478c63122f73914db, type: 3}
m_Name:
m_EditorClassIdentifier:
Body: {fileID: 592487110401094195}
Bobbing: {fileID: 3068808787720623988}
Direction: {x: 0, y: 0}
MaxSpeed: 5
AccelerationSpeed: 3
DecelerationSpeed: 15
--- !u!114 &592487110401094193
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a2110188365a59e4cb31d0e84789fbbd, type: 3}
m_Name:
m_EditorClassIdentifier:
BodypartPrefabs:
- {fileID: 3847767376140256459, guid: 398344b60d76e044ea67d2346d4d9b25, type: 3}
- {fileID: 3847767376140256459, guid: 876c3f18878bbd6498566af1f9234dcf, type: 3}
- {fileID: 3847767376140256459, guid: ef8e91f8ee034b54187172730881ede2, type: 3}
- {fileID: 3847767376140256459, guid: 18cee0d8962f9124cbe00dcb3e6a009b, type: 3}
DebugExplode: 0
KillOnZeroHealth: 1
--- !u!114 &3362493323285318061
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7d43d0a4a6d1e2d46a74083bdecde13e, type: 3}
m_Name:
m_EditorClassIdentifier:
MaxHealth: 30
CurrentHealth: 30
--- !u!114 &5951030530186631518
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 173be6658a5fcba49b9b1f1c91fa5f33, type: 3}
m_Name:
m_EditorClassIdentifier:
Radius: 5
ForgetRadius: 10
ForgetTimer: 1
--- !u!114 &2001250142692207685
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f7e23822f429fcc46a8fd9163e68f332, type: 3}
m_Name:
m_EditorClassIdentifier:
CurrentStatus:
Target: {fileID: 0}
CloseEnoughRadius: 1
TargetPositionUpdateFrequency: 2
--- !u!114 &5237857222030341603
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 691ecb02eb2bee744ae7734fe9aa5a52, type: 3}
m_Name:
m_EditorClassIdentifier:
CurrentStatus:
StartExplodingRadius: 3.5
ExplodeOnImpactRadius: 1.5
ExplosionRadius: 2.5
FuseDuration: 1.5
MinDamage: 7
MaxDamage: 13
SpriteRenderer: {fileID: 592487111066334295}
ExplosionAnimationTransform: {fileID: 592487111173795460}
ExplosionAnimationDuration: 0.3
BlinkingRate: 2
--- !u!114 &51880594498256973
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a5b93b6d03406294ca3652c770fe2638, type: 3}
m_Name:
m_EditorClassIdentifier:
Anim: {fileID: 5375970501711434365}
SpriteRenderer: {fileID: 592487111066334295}
--- !u!1 &592487111066334293
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 592487111066334294}
- component: {fileID: 592487111066334295}
- component: {fileID: 5375970501711434365}
m_Layer: 0
m_Name: Sprite
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &592487111066334294
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487111066334293}
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: []
m_Father: {fileID: 592487111173795460}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &592487111066334295
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487111066334293}
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: 76742abfacd1b17458fbe21d2628ca75, 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: 1
m_Sprite: {fileID: 7117592317043085607, guid: 624befa8cd9c18445aac1add2194562e,
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_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!95 &5375970501711434365
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487111066334293}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 8436f72dc0fe84f49b035fac8c9d2b97, 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 &592487111173795459
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 592487111173795460}
m_Layer: 0
m_Name: AttackingRoot
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &592487111173795460
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487111173795459}
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: 592487111066334294}
m_Father: {fileID: 1801310824674407730}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5800104731865852645
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7620644064869685210}
- component: {fileID: 1046432343665673627}
- component: {fileID: 8912829886182716132}
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 &7620644064869685210
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5800104731865852645}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.5, z: 0}
m_LocalScale: {x: 0.15, y: 0.15, z: 0.15}
m_Children: []
m_Father: {fileID: 592487110401094196}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1046432343665673627
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5800104731865852645}
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 &8912829886182716132
TextMesh:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5800104731865852645}
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 &7558423332818417733
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1801310824674407730}
m_Layer: 0
m_Name: Bobbing anim
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1801310824674407730
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7558423332818417733}
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: 592487111173795460}
m_Father: {fileID: 592487110401094196}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 72a58ef1f50bfb946ae1af6e6b9fa1c5
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -36,7 +36,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487110401094192}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.14, y: -1.57, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1801310824674407730}
@ -103,11 +103,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 978bec54408eb8f42a36fd68d7447f5a, type: 3}
m_Name:
m_EditorClassIdentifier:
MoveSpeed: 1
Movement: {fileID: 4248768674552437703}
BehaviourDisplay: {fileID: 8912829886182716132}
CurrentBehaviour: Nothing
Attacking: 0
--- !u!114 &3068808787720623988
MonoBehaviour:
m_ObjectHideFlags: 0
@ -143,6 +141,7 @@ MonoBehaviour:
Direction: {x: 0, y: 0}
MaxSpeed: 2.5
AccelerationSpeed: 10
DecelerationSpeed: 10
--- !u!114 &592487110401094193
MonoBehaviour:
m_ObjectHideFlags: 0
@ -188,6 +187,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
Radius: 5
ForgetRadius: 6
ForgetTimer: 0
--- !u!114 &2001250142692207685
MonoBehaviour:
m_ObjectHideFlags: 0
@ -222,6 +223,7 @@ MonoBehaviour:
AttackAnimationLength: 0.1
ReleaseAnimationLength: 0.25
CooldownLength: 0.7
Attacking: 0
--- !u!114 &8799261875116284856
MonoBehaviour:
m_ObjectHideFlags: 0
@ -324,7 +326,7 @@ SpriteRenderer:
m_SortingOrder: 1
m_Sprite: {fileID: 6754164815184778395, guid: 8d816068e3260f54f9cb041dcd165103,
type: 3}
m_Color: {r: 0.7873081, g: 1, b: 0.6839622, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0

View File

@ -0,0 +1,114 @@
using UnityEngine;
using Saltosion.OneWeapon.Enemies;
using Saltosion.OneWeapon.Effects;
using Saltosion.OneWeapon.Player;
namespace Saltosion.OneWeapon.AI.Behaviours {
[RequireComponent(typeof(Follow), typeof(Enemy), typeof(Explodable))]
public class ExplodeFollowed : AIBehaviour {
public float StartExplodingRadius;
public float ExplodeOnImpactRadius;
public float ExplosionRadius;
public float FuseDuration;
[Tooltip("The amount of damage when barely in the explosion radius")]
public float MinDamage;
[Tooltip("The amount of damage when in impact radius")]
public float MaxDamage;
[Header("Graphics")]
public SpriteRenderer SpriteRenderer;
public Transform ExplosionAnimationTransform;
public float ExplosionAnimationDuration;
public float BlinkingRate;
private Enemy Enemy;
private Follow Follow;
private Explodable Explodable;
private float OriginalFollowPositionUpdateFrequency;
private bool Exploding = false;
private float FuseStartTime;
private bool ExplosionStarted = false;
private float ExplosionProgress = 0.0f;
private void Start() {
Enemy = GetComponent<Enemy>();
Follow = GetComponent<Follow>();
Explodable = GetComponent<Explodable>();
OriginalFollowPositionUpdateFrequency = Follow.TargetPositionUpdateFrequency;
}
public override bool CanBehave() {
return true;
}
public override void Execute() {
float Distance = Follow.Target != null ? (Follow.Target.position - transform.position).magnitude : float.PositiveInfinity;
bool ImpactExplode = Distance <= ExplodeOnImpactRadius;
bool TimeExplode = Exploding && Time.time - FuseStartTime >= FuseDuration;
if (!ExplosionStarted && (ImpactExplode || TimeExplode)) {
ExplosionStarted = true;
CurrentStatus = "BOOM";
} else if (Distance <= StartExplodingRadius && !Exploding) {
Exploding = true;
FuseStartTime = Time.time;
Follow.SetUpdateFrequency(OriginalFollowPositionUpdateFrequency / 3f);
CurrentStatus = "CloseEnoughNow";
} else if (Exploding) {
CurrentStatus = "Exploding: " + (Time.time - FuseStartTime).ToString("0.0") + " > " + FuseDuration.ToString("0.0");
} else {
CurrentStatus = "NotCloseEnough";
}
// Animation
if (ExplosionStarted) {
if (ExplosionProgress >= 1.0f) {
Explode(Distance);
} else {
ExplosionProgress += Time.deltaTime / ExplosionAnimationDuration;
float AnimMidpoint = 0.5f;
if (ExplosionProgress < AnimMidpoint) {
float MinifyProgress = ExplosionProgress / AnimMidpoint;
ExplosionAnimationTransform.localScale = new Vector3(1, 1, 1) * (1.0f - MinifyProgress * 0.5f);
} else {
float ExpansionProgress = (ExplosionProgress - AnimMidpoint) / (1.0f - AnimMidpoint);
ExplosionAnimationTransform.localScale = new Vector3(1, 1, 1) * (0.5f + ExpansionProgress);
}
}
}
if (Exploding) {
float Intensity = Mathf.Sin(Time.time * Mathf.PI * 2.0f * BlinkingRate) * 0.5f + 0.5f;
SpriteRenderer.material.SetFloat("_Intensity", Intensity);
} else {
SpriteRenderer.material.SetFloat("_Intensity", 0.0f);
}
}
private void OnDrawGizmosSelected() {
Gizmos.color = new Color(1.0f, 0.2f, 0.2f, 0.8f);
Gizmos.DrawWireSphere(transform.position, ExplodeOnImpactRadius);
Gizmos.color = new Color(1.0f, 0.0f, 0.0f, 1.0f);
Gizmos.DrawWireSphere(transform.position, ExplosionRadius);
Gizmos.color = new Color(1.0f, 0.5f, 0.5f, 0.5f);
Gizmos.DrawWireSphere(transform.position, StartExplodingRadius);
}
private void Explode(float distance) {
Collider2D[] NearbyColliders = Physics2D.OverlapCircleAll(transform.position, ExplosionRadius);
foreach (Collider2D Collider in NearbyColliders) {
PlayerFun PlayerFun = Collider.GetComponent<PlayerFun>();
Health Health = Collider.GetComponent<Health>();
if (PlayerFun != null) {
PlayerFun.TakeExplosionDamage();
}
if (Health != null) {
float ScaledDistance = Mathf.Clamp((distance - ExplodeOnImpactRadius) / (ExplosionRadius - ExplodeOnImpactRadius), 0, 1);
float Damage = MinDamage + (MaxDamage - MinDamage) * (1.0f - ScaledDistance);
Vector2 Direction = (Collider.transform.position - transform.position).normalized;
Health.Damage(Damage, Direction, false);
}
}
Explodable.Explode(true);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 691ecb02eb2bee744ae7734fe9aa5a52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,7 +9,7 @@ namespace Saltosion.OneWeapon.AI.Behaviours {
public float TargetPositionUpdateFrequency = 5f;
private Enemy Enemy;
private Vector2 TargetPosition;
private Vector2 TargetDirection;
private float TargetPositionUpdateCooldown;
private void Start() {
@ -19,7 +19,7 @@ namespace Saltosion.OneWeapon.AI.Behaviours {
private void Update() {
if (Target != null && TargetPositionUpdateCooldown <= 0) {
TargetPositionUpdateCooldown = 1.0f / TargetPositionUpdateFrequency;
TargetPosition = Target.position;
TargetDirection = Target.position - Enemy.transform.position;
} else if (Target == null) {
TargetPositionUpdateCooldown = 0.0f;
} else {
@ -27,25 +27,31 @@ namespace Saltosion.OneWeapon.AI.Behaviours {
}
}
public void SetUpdateFrequency(float freq) {
TargetPositionUpdateFrequency = freq;
TargetPositionUpdateCooldown = Mathf.Min(TargetPositionUpdateCooldown, 1.0f / freq);
}
public override bool CanBehave() {
return Target != null;
bool TargetExists = Target != null;
if (!TargetExists) {
Enemy.StopMoving();
CurrentStatus = "NoTarget";
}
return TargetExists;
}
public override void Execute() {
if (Target != null) {
Vector2 position = Enemy.transform.position;
Vector2 delta = TargetPosition - position;
Vector2 delta = (Vector2)Target.position - position;
if (delta.magnitude > CloseEnoughRadius) {
delta -= delta.normalized * CloseEnoughRadius;
Enemy.StartMovingTo(position + delta);
Enemy.StartMovingTo(position + TargetDirection);
CurrentStatus = "Approach";
} else {
Enemy.StopMoving();
CurrentStatus = "CloseEnough";
}
} else {
Enemy.StopMoving();
CurrentStatus = "NoTarget";
}
}
}

View File

@ -12,6 +12,9 @@ namespace Saltosion.OneWeapon.AI.Behaviours {
public float ReleaseAnimationLength;
public float CooldownLength;
[HideInInspector]
public bool Attacking;
private Enemy Enemy;
private Follow Follow;
private bool AttackHit;
@ -47,17 +50,17 @@ namespace Saltosion.OneWeapon.AI.Behaviours {
public override bool CanBehave() {
bool CanBehave = Follow.Target != null && (Follow.Target.position - Enemy.transform.position).magnitude <= MeleeRange;
if (!CanBehave) {
Enemy.Attacking = false;
Attacking = false;
}
return CanBehave;
}
public override void Execute() {
if (CooldownProgress > 0) {
Enemy.Attacking = false;
Attacking = false;
return;
} else {
Enemy.Attacking = true;
Attacking = true;
}
Vector2 Root = AnimatableTransform.parent.position + LocalOrigin;

View File

@ -5,17 +5,36 @@ using Saltosion.OneWeapon.Enemies;
namespace Saltosion.OneWeapon.AI.Triggers {
public class PlayerSighted : Trigger {
[Tooltip("How close the player needs to be for the AI to notice them.")]
public float Radius;
[Tooltip("How far the player needs to escape for the AI to \"forget\" them.")]
public float ForgetRadius;
[Tooltip("How long does it take for the enemy to forget where the player was?")]
public float ForgetTimer;
public PlayerController Player { get; private set; }
private bool CountdownStarted = false;
private float ForgetCountdownStartTime = 0.0f;
public override bool IsTriggered() {
Player = Util.GetClosestTo<PlayerController>(transform, Radius, true);
PlayerController Sighted = Util.GetClosestTo<PlayerController>(transform, Player == null ? Radius : ForgetRadius, true);
if (Sighted != null) {
CountdownStarted = false;
Player = Sighted;
} else if (!CountdownStarted) {
CountdownStarted = true;
ForgetCountdownStartTime = Time.time;
} else if (Time.time - ForgetCountdownStartTime > ForgetTimer) {
Player = null;
}
return Player != null;
}
private void OnDrawGizmosSelected() {
Gizmos.color = Color.green;
Gizmos.DrawWireSphere(transform.position, Radius);
Gizmos.color = new Color(Color.green.r, Color.green.g, Color.green.b, 0.5f);
Gizmos.DrawWireSphere(transform.position, ForgetRadius);
}
}
}

View File

@ -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(Follow))]
[RequireComponent(typeof(ExplodeFollowed))]
public class Armadillo : MonoBehaviour {
public Animator Anim;
public SpriteRenderer SpriteRenderer;
private Enemy Enemy;
private PlayerSighted FollowTrigger;
private Follow FollowBehaviour;
private ExplodeFollowed ExplodeBehaviour;
private void Start() {
Enemy = GetComponent<Enemy>();
FollowTrigger = GetComponent<PlayerSighted>();
FollowBehaviour = GetComponent<Follow>();
ExplodeBehaviour = GetComponent<ExplodeFollowed>();
}
private void Update() {
bool Moving = false;
Enemy.CurrentBehaviour = "";
if (FollowTrigger.IsTriggered()) {
FollowBehaviour.Target = FollowTrigger.Player.transform;
Enemy.CurrentBehaviour += "PlayerSighted, ";
} else {
FollowBehaviour.Target = null;
}
if (ExplodeBehaviour.TryExecute()) {
Enemy.CurrentBehaviour += "Explode:" + ExplodeBehaviour.CurrentStatus + ", ";
}
if (FollowBehaviour.TryExecute()) {
Enemy.CurrentBehaviour += "Follow:" + FollowBehaviour.CurrentStatus;
Moving = true;
}
if (Moving) {
Anim.Play("Roll");
} else {
Anim.Play("Idle");
}
Anim.SetFloat("Speed", Enemy.Movement.SpeedPercentage);
if (Enemy.Movement.SpeedPercentage > 0.1) {
SpriteRenderer.flipX = Vector2.Dot(Enemy.Movement.Direction, Vector2.left) < 0;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a5b93b6d03406294ca3652c770fe2638
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -28,19 +28,20 @@ namespace Saltosion.OneWeapon.Enemies {
}
private void Update() {
Enemy.CurrentBehaviour = "Nothing";
Enemy.CurrentBehaviour = "";
if (FollowTrigger.IsTriggered()) {
FollowBehaviour.Target = FollowTrigger.Player.transform;
if (MeleeBehaviour.TryExecute()) {
Enemy.CurrentBehaviour = "Melee:" + MeleeBehaviour.CurrentStatus;
} else if (FollowBehaviour.TryExecute()) {
Enemy.CurrentBehaviour = "Follow:" + FollowBehaviour.CurrentStatus;
Enemy.CurrentBehaviour += "Melee:" + MeleeBehaviour.CurrentStatus + ", ";
}
if (FollowBehaviour.TryExecute()) {
Enemy.CurrentBehaviour += "Follow:" + FollowBehaviour.CurrentStatus;
}
} else if (WanderBehaviour.TryExecute()) {
Enemy.CurrentBehaviour = "Wander:" + WanderBehaviour.CurrentStatus;
Enemy.CurrentBehaviour += "Wander:" + WanderBehaviour.CurrentStatus;
}
if (Enemy.Attacking) {
if (MeleeBehaviour.Attacking) {
Anim.Play("Attack");
} else {
Anim.Play("Walk");

View File

@ -6,15 +6,13 @@ using Saltosion.OneWeapon.Utils;
namespace Saltosion.OneWeapon.Enemies {
[RequireComponent(typeof(Rigidbody2D))]
public class Enemy : MonoBehaviour {
public float MoveSpeed;
private static Enemy latestDebugHoveredEnemy = null;
public AcceleratedMovement Movement;
[Header("Debug Info")]
public TextMesh BehaviourDisplay;
public string CurrentBehaviour = "Nothing";
[HideInInspector]
public bool Attacking;
private Rigidbody2D Body;
private bool MovingToTarget = false;
private Vector2 TargetPosition;
@ -25,16 +23,17 @@ namespace Saltosion.OneWeapon.Enemies {
}
private void Update() {
bool DisplayDebugInfo = false;
if (Application.isEditor) {
Collider2D Hit = Physics2D.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition));
if (Hit != null && Hit.attachedRigidbody == Body) {
DisplayDebugInfo = true;
latestDebugHoveredEnemy = this;
}
}
bool DisplayDebugInfo = latestDebugHoveredEnemy == this;
BehaviourDisplay.gameObject.SetActive(DisplayDebugInfo);
if (DisplayDebugInfo) {
BehaviourDisplay.text = CurrentBehaviour;
BehaviourDisplay.text = CurrentBehaviour.Length == 0 ? "Nothing" : CurrentBehaviour;
}
}

View File

@ -15,9 +15,9 @@ namespace Saltosion.OneWeapon.Enemies {
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
}
public void Damage(float amount, Vector2 fromDirection) {
public void Damage(float amount, Vector2 fromDirection, bool applyPlayerDamageBoost) {
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(amount), 100f, 100);
CurrentHealth -= amount * (1 + PlayerFun.CurrentDamageBoost);
CurrentHealth -= amount * (1 + (applyPlayerDamageBoost ? PlayerFun.CurrentDamageBoost : 0.0f));
}
}
}

View File

@ -53,7 +53,7 @@ namespace Saltosion.OneWeapon.Guns {
VendingMachine VendingMachine = collider.GetComponent<VendingMachine>();
Vector2 Direction = (collider.transform.position - transform.position).normalized;
if (Health != null) {
Health.Damage(12f, -Direction);
Health.Damage(12f, -Direction, true);
} else if (VendingMachine != null) {
VendingMachine.ExpelGun();
} else if (Explodable != null) {

View File

@ -72,6 +72,10 @@ namespace Saltosion.OneWeapon.Player {
AddFun(-5f);
}
public void TakeExplosionDamage() {
AddFun(-10f);
}
public void ReceiveNewWeapon() {
AddFun(WeaponFun);
}

View File

@ -23,7 +23,7 @@ namespace Saltosion.OneWeapon.Player {
VendingMachine VendingMachine = collider.GetComponent<VendingMachine>();
Vector2 Direction = (collider.transform.position - transform.position).normalized;
if (Health != null) {
Health.Damage(8f, -Direction);
Health.Damage(8f, -Direction, true);
} else if (VendingMachine != null) {
VendingMachine.ExpelGun();
} else if (Explodable != null) {

View File

@ -13,6 +13,7 @@ namespace Saltosion.OneWeapon.Utils {
public Vector2 Direction = Vector2.zero;
public float MaxSpeed = 7;
public float AccelerationSpeed = 70;
public float DecelerationSpeed = 70;
public Vector2 CurrentVelocity { private set; get; }
public float SpeedPercentage { private set; get; }
@ -22,7 +23,7 @@ namespace Saltosion.OneWeapon.Utils {
if (Direction.magnitude > 0) {
CurrentSpeed += AccelerationSpeed * Time.deltaTime;
} else {
CurrentSpeed -= AccelerationSpeed * Time.deltaTime;
CurrentSpeed -= DecelerationSpeed * Time.deltaTime;
}
CurrentSpeed *= 1 - (Vector2.Angle(Direction, LastDirection) / 180);
CurrentSpeed = Mathf.Clamp(CurrentSpeed, 0, MaxSpeed);

8
Assets/Shaders.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3aa10e4f9c81de8429fc1991359cb231
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,60 @@
Shader "Custom/ExplodingSprite"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Intensity ("Intensity", Float) = 1
}
SubShader
{
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" "CanUseSpriteAtlas"="true" "PreviewType"="Plane" }
ZWrite Off
Cull Off
Blend One OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile _ PIXELSNAP_ON
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Intensity;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
col.r = min(1, col.r + _Intensity);
col.g = min(1, col.g + _Intensity);
col.b = min(1, col.b + _Intensity);
col.rgb *= col.a;
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1434422345737544399544f3eb31b6f9
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,79 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ExplodingSpriteMaterial
m_Shader: {fileID: 4800000, guid: 1434422345737544399544f3eb31b6f9, type: 3}
m_ShaderKeywords: ETC1_EXTERNAL_ALPHA
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _ExplosionIntensity: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Intensity: 0
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 76742abfacd1b17458fbe21d2628ca75
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant: