Skip to content

Commit

Permalink
Implement charger gremlin (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
12joan authored Dec 28, 2024
1 parent dcfe730 commit d76ed9c
Show file tree
Hide file tree
Showing 10 changed files with 471 additions and 7 deletions.
211 changes: 211 additions & 0 deletions Assets/Unity/Prefabs/Enemies/Charger Gremlin.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7395253680585668139
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2090889806084682781}
- component: {fileID: 8691424312494069922}
m_Layer: 8
m_Name: Charger Gremlin Attack AI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2090889806084682781
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7395253680585668139}
serializedVersion: 2
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7674314308645791106}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8691424312494069922
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7395253680585668139}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e994ffc91b3c2424d8b1f553b6d50799, type: 3}
m_Name:
m_EditorClassIdentifier:
IsActive: 0
<Speed>k__BackingField: 20
PrepareSpeed: 2
RecoverSpeed: 5
WiggleAmplitude: 10
PrepareWiggleSpeed: 30
ChargeWiggleSpeed: 30
RecoverWiggleSpeed: 10
PrepareDuration: 1.5
MaxChargeDuration: 2
RecoverDuration: 4
Damage: 20
--- !u!1001 &8161433874373683611
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1871121786428654615, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: Maximum
value: 60
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4399600734961214489, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6683697602069921621, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: CircleSpeed
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6683697602069921621, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: TooFarDistance
value: 9
objectReference: {fileID: 0}
- target: {fileID: 6683697602069921621, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: TooCloseDistance
value: 3.375
objectReference: {fileID: 0}
- target: {fileID: 6683697602069921621, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: BackOffToDistance
value: 4.5
objectReference: {fileID: 0}
- target: {fileID: 6683697602069921621, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: ApproachToDistance
value: 5.625
objectReference: {fileID: 0}
- target: {fileID: 7238508906334667609, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_Name
value: Charger Gremlin AI
objectReference: {fileID: 0}
- target: {fileID: 7343680986649598625, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: AttackAI
value:
objectReference: {fileID: 8691424312494069922}
- target: {fileID: 7343680986649598625, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: AttackInterval
value: 4
objectReference: {fileID: 0}
- target: {fileID: 7343680986649598625, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: RandomnessFactor
value: 0.25
objectReference: {fileID: 0}
- target: {fileID: 7343680986649598625, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: MinDelayBeforeAttack
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7343680986649598625, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: InterruptWhenOutOfRange
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7764934233349782288, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_Color.b
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7764934233349782288, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_Color.g
value: 0.65377206
objectReference: {fileID: 0}
- target: {fileID: 7764934233349782288, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_Color.r
value: 0.6367924
objectReference: {fileID: 0}
- target: {fileID: 8188467070782874524, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
propertyPath: m_Name
value: Charger Gremlin
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: 2000610790513937433, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
insertIndex: -1
addedObject: {fileID: 2090889806084682781}
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 104942a13dd3f4497992f707511fee7d, type: 3}
--- !u!4 &7674314308645791106 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2000610790513937433, guid: 104942a13dd3f4497992f707511fee7d,
type: 3}
m_PrefabInstance: {fileID: 8161433874373683611}
m_PrefabAsset: {fileID: 0}
7 changes: 7 additions & 0 deletions Assets/Unity/Prefabs/Enemies/Charger Gremlin.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions Assets/Unity/Scenes/Level 3.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,74 @@ Transform:
- {fileID: 725285167}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1090866498
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 63186410946759175, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_Name
value: Charger Gremlin
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalPosition.x
value: -14
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalPosition.y
value: 2.8682303
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5498254477281136002, guid: 4689c689dfa584f528d46af9cac12117,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4689c689dfa584f528d46af9cac12117, type: 3}
--- !u!1001 &1123202356
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2989,3 +3057,4 @@ SceneRoots:
- {fileID: 1535711301}
- {fileID: 521433781861264990}
- {fileID: 50370136}
- {fileID: 1090866498}
12 changes: 12 additions & 0 deletions Assets/src/AEnemyAI2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ protected virtual void OnActivate() { }
protected virtual void OnDeactivate() { }
protected virtual void UseChildAIs(Action<AGenericEnemyAI> useChild) { }

protected virtual bool ShouldAvoidInterruption() => false;

// Used only by AMovementEnemyAI
protected virtual AMovementEnemyAI InternalUseMovementAI() {
return null;
Expand Down Expand Up @@ -97,6 +99,16 @@ private void DeactivateChildAI(AEnemyAI2 child) {
child.Deactivate();
}

protected bool AnyDescendant(Func<AEnemyAI2, bool> condition) {
if (condition(this))
return true;

return ActiveChildAIs.Any(child => child.AnyDescendant(condition));
}

protected bool AvoidingInterruption
=> AnyDescendant(ai => ai.ShouldAvoidInterruption());

private EnemyAIHelper MakeHelper() => new EnemyAIHelper(
ai: this,
gameObject: GetRootTransform().gameObject,
Expand Down
Loading

0 comments on commit d76ed9c

Please sign in to comment.