Skip to content

Commit de7e054

Browse files
committed
Added speed boost powerup
1 parent 7baaa89 commit de7e054

File tree

7 files changed

+157
-150
lines changed

7 files changed

+157
-150
lines changed

Assets/FluidBehaviorTree/Examples/CaptureTheFlag/CaptureTheFlag.unity

Lines changed: 88 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,11 @@ Transform:
402402
m_PrefabInternal: {fileID: 0}
403403
m_GameObject: {fileID: 266950472}
404404
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
405-
m_LocalPosition: {x: 11.6508255, y: -3.546875, z: -1.7632402}
405+
m_LocalPosition: {x: 0, y: 0, z: 0}
406406
m_LocalScale: {x: 1, y: 1, z: 1}
407407
m_Children:
408-
- {fileID: 732249243}
409-
- {fileID: 1112956654}
408+
- {fileID: 579005834}
409+
- {fileID: 1956749180}
410410
m_Father: {fileID: 0}
411411
m_RootOrder: 2
412412
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -602,6 +602,7 @@ MonoBehaviour:
602602
flag: {fileID: 288710216}
603603
goalRed: {fileID: 2006129114}
604604
goalBlue: {fileID: 791574214}
605+
speedBoost: {fileID: 0}
605606
flagStart: {fileID: 0}
606607
--- !u!4 &499955083
607608
Transform:
@@ -616,6 +617,48 @@ Transform:
616617
m_Father: {fileID: 0}
617618
m_RootOrder: 0
618619
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
620+
--- !u!1 &579005833
621+
GameObject:
622+
m_ObjectHideFlags: 0
623+
m_CorrespondingSourceObject: {fileID: 0}
624+
m_PrefabInternal: {fileID: 0}
625+
serializedVersion: 6
626+
m_Component:
627+
- component: {fileID: 579005834}
628+
- component: {fileID: 579005835}
629+
m_Layer: 0
630+
m_Name: Spawner
631+
m_TagString: Untagged
632+
m_Icon: {fileID: 0}
633+
m_NavMeshLayer: 0
634+
m_StaticEditorFlags: 0
635+
m_IsActive: 1
636+
--- !u!4 &579005834
637+
Transform:
638+
m_ObjectHideFlags: 0
639+
m_CorrespondingSourceObject: {fileID: 0}
640+
m_PrefabInternal: {fileID: 0}
641+
m_GameObject: {fileID: 579005833}
642+
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
643+
m_LocalPosition: {x: -20, y: 0.5, z: 0}
644+
m_LocalScale: {x: 1, y: 1, z: 1}
645+
m_Children: []
646+
m_Father: {fileID: 266950473}
647+
m_RootOrder: 0
648+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
649+
--- !u!114 &579005835
650+
MonoBehaviour:
651+
m_ObjectHideFlags: 0
652+
m_CorrespondingSourceObject: {fileID: 0}
653+
m_PrefabInternal: {fileID: 0}
654+
m_GameObject: {fileID: 579005833}
655+
m_Enabled: 1
656+
m_EditorHideFlags: 0
657+
m_Script: {fileID: 11500000, guid: 57ba63cd773e46a6bb63ac7c8762b277, type: 3}
658+
m_Name:
659+
m_EditorClassIdentifier:
660+
speedBoostPrefab: {fileID: 1275289305280740, guid: 0476a246c44a1384394acffb4e07dc63,
661+
type: 2}
619662
--- !u!1001 &627162091
620663
Prefab:
621664
m_ObjectHideFlags: 0
@@ -802,53 +845,6 @@ Transform:
802845
m_CorrespondingSourceObject: {fileID: 4658679412166198, guid: a7cb6cbf9ff67b34a9500e075f082575,
803846
type: 2}
804847
m_PrefabInternal: {fileID: 713892002}
805-
--- !u!1001 &732249242
806-
Prefab:
807-
m_ObjectHideFlags: 0
808-
serializedVersion: 2
809-
m_Modification:
810-
m_TransformParent: {fileID: 266950473}
811-
m_Modifications:
812-
- target: {fileID: 4798518362713584, guid: 0476a246c44a1384394acffb4e07dc63, type: 2}
813-
propertyPath: m_LocalPosition.x
814-
value: -31.650826
815-
objectReference: {fileID: 0}
816-
- target: {fileID: 4798518362713584, guid: 0476a246c44a1384394acffb4e07dc63, type: 2}
817-
propertyPath: m_LocalPosition.y
818-
value: 4.046875
819-
objectReference: {fileID: 0}
820-
- target: {fileID: 4798518362713584, guid: 0476a246c44a1384394acffb4e07dc63, type: 2}
821-
propertyPath: m_LocalPosition.z
822-
value: 1.7632402
823-
objectReference: {fileID: 0}
824-
- target: {fileID: 4798518362713584, guid: 0476a246c44a1384394acffb4e07dc63, type: 2}
825-
propertyPath: m_LocalRotation.x
826-
value: -0
827-
objectReference: {fileID: 0}
828-
- target: {fileID: 4798518362713584, guid: 0476a246c44a1384394acffb4e07dc63, type: 2}
829-
propertyPath: m_LocalRotation.y
830-
value: -0
831-
objectReference: {fileID: 0}
832-
- target: {fileID: 4798518362713584, guid: 0476a246c44a1384394acffb4e07dc63, type: 2}
833-
propertyPath: m_LocalRotation.z
834-
value: -0
835-
objectReference: {fileID: 0}
836-
- target: {fileID: 4798518362713584, guid: 0476a246c44a1384394acffb4e07dc63, type: 2}
837-
propertyPath: m_LocalRotation.w
838-
value: 1
839-
objectReference: {fileID: 0}
840-
- target: {fileID: 4798518362713584, guid: 0476a246c44a1384394acffb4e07dc63, type: 2}
841-
propertyPath: m_RootOrder
842-
value: 0
843-
objectReference: {fileID: 0}
844-
m_RemovedComponents: []
845-
m_SourcePrefab: {fileID: 100100000, guid: 0476a246c44a1384394acffb4e07dc63, type: 2}
846-
m_IsPrefabAsset: 0
847-
--- !u!4 &732249243 stripped
848-
Transform:
849-
m_CorrespondingSourceObject: {fileID: 4798518362713584, guid: 0476a246c44a1384394acffb4e07dc63,
850-
type: 2}
851-
m_PrefabInternal: {fileID: 732249242}
852848
--- !u!1001 &744881468
853849
Prefab:
854850
m_ObjectHideFlags: 0
@@ -1102,91 +1098,6 @@ Transform:
11021098
m_CorrespondingSourceObject: {fileID: 4944183167226686, guid: 0328c8f3f9bc6e446baa131a84e470f5,
11031099
type: 2}
11041100
m_PrefabInternal: {fileID: 996620352}
1105-
--- !u!1 &1112956653
1106-
GameObject:
1107-
m_ObjectHideFlags: 0
1108-
m_CorrespondingSourceObject: {fileID: 0}
1109-
m_PrefabInternal: {fileID: 0}
1110-
serializedVersion: 6
1111-
m_Component:
1112-
- component: {fileID: 1112956654}
1113-
- component: {fileID: 1112956657}
1114-
- component: {fileID: 1112956656}
1115-
- component: {fileID: 1112956655}
1116-
m_Layer: 0
1117-
m_Name: SpeedPowerup (1)
1118-
m_TagString: Untagged
1119-
m_Icon: {fileID: 0}
1120-
m_NavMeshLayer: 0
1121-
m_StaticEditorFlags: 0
1122-
m_IsActive: 1
1123-
--- !u!4 &1112956654
1124-
Transform:
1125-
m_ObjectHideFlags: 0
1126-
m_CorrespondingSourceObject: {fileID: 0}
1127-
m_PrefabInternal: {fileID: 0}
1128-
m_GameObject: {fileID: 1112956653}
1129-
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
1130-
m_LocalPosition: {x: 8.359175, y: 4.046875, z: 1.7632402}
1131-
m_LocalScale: {x: 1, y: 1, z: 1}
1132-
m_Children: []
1133-
m_Father: {fileID: 266950473}
1134-
m_RootOrder: 1
1135-
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1136-
--- !u!65 &1112956655
1137-
BoxCollider:
1138-
m_ObjectHideFlags: 0
1139-
m_CorrespondingSourceObject: {fileID: 0}
1140-
m_PrefabInternal: {fileID: 0}
1141-
m_GameObject: {fileID: 1112956653}
1142-
m_Material: {fileID: 0}
1143-
m_IsTrigger: 0
1144-
m_Enabled: 1
1145-
serializedVersion: 2
1146-
m_Size: {x: 1, y: 1, z: 1}
1147-
m_Center: {x: 0, y: 0, z: 0}
1148-
--- !u!23 &1112956656
1149-
MeshRenderer:
1150-
m_ObjectHideFlags: 0
1151-
m_CorrespondingSourceObject: {fileID: 0}
1152-
m_PrefabInternal: {fileID: 0}
1153-
m_GameObject: {fileID: 1112956653}
1154-
m_Enabled: 1
1155-
m_CastShadows: 1
1156-
m_ReceiveShadows: 1
1157-
m_DynamicOccludee: 1
1158-
m_MotionVectors: 1
1159-
m_LightProbeUsage: 1
1160-
m_ReflectionProbeUsage: 1
1161-
m_RenderingLayerMask: 4294967295
1162-
m_Materials:
1163-
- {fileID: 2100000, guid: 4b1f1a557e3eaae41bf05cc1023fdf0d, type: 2}
1164-
m_StaticBatchInfo:
1165-
firstSubMesh: 0
1166-
subMeshCount: 0
1167-
m_StaticBatchRoot: {fileID: 0}
1168-
m_ProbeAnchor: {fileID: 0}
1169-
m_LightProbeVolumeOverride: {fileID: 0}
1170-
m_ScaleInLightmap: 1
1171-
m_PreserveUVs: 0
1172-
m_IgnoreNormalsForChartDetection: 0
1173-
m_ImportantGI: 0
1174-
m_StitchLightmapSeams: 0
1175-
m_SelectedEditorRenderState: 3
1176-
m_MinimumChartSize: 4
1177-
m_AutoUVMaxDistance: 0.5
1178-
m_AutoUVMaxAngle: 89
1179-
m_LightmapParameters: {fileID: 0}
1180-
m_SortingLayerID: 0
1181-
m_SortingLayer: 0
1182-
m_SortingOrder: 0
1183-
--- !u!33 &1112956657
1184-
MeshFilter:
1185-
m_ObjectHideFlags: 0
1186-
m_CorrespondingSourceObject: {fileID: 0}
1187-
m_PrefabInternal: {fileID: 0}
1188-
m_GameObject: {fileID: 1112956653}
1189-
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
11901101
--- !u!1001 &1299962231
11911102
Prefab:
11921103
m_ObjectHideFlags: 0
@@ -1278,6 +1189,48 @@ Transform:
12781189
m_Father: {fileID: 0}
12791190
m_RootOrder: 3
12801191
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1192+
--- !u!1 &1956749179
1193+
GameObject:
1194+
m_ObjectHideFlags: 0
1195+
m_CorrespondingSourceObject: {fileID: 0}
1196+
m_PrefabInternal: {fileID: 0}
1197+
serializedVersion: 6
1198+
m_Component:
1199+
- component: {fileID: 1956749180}
1200+
- component: {fileID: 1956749181}
1201+
m_Layer: 0
1202+
m_Name: Spawner (1)
1203+
m_TagString: Untagged
1204+
m_Icon: {fileID: 0}
1205+
m_NavMeshLayer: 0
1206+
m_StaticEditorFlags: 0
1207+
m_IsActive: 1
1208+
--- !u!4 &1956749180
1209+
Transform:
1210+
m_ObjectHideFlags: 0
1211+
m_CorrespondingSourceObject: {fileID: 0}
1212+
m_PrefabInternal: {fileID: 0}
1213+
m_GameObject: {fileID: 1956749179}
1214+
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
1215+
m_LocalPosition: {x: 20, y: 0.5, z: 0}
1216+
m_LocalScale: {x: 1, y: 1, z: 1}
1217+
m_Children: []
1218+
m_Father: {fileID: 266950473}
1219+
m_RootOrder: 1
1220+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1221+
--- !u!114 &1956749181
1222+
MonoBehaviour:
1223+
m_ObjectHideFlags: 0
1224+
m_CorrespondingSourceObject: {fileID: 0}
1225+
m_PrefabInternal: {fileID: 0}
1226+
m_GameObject: {fileID: 1956749179}
1227+
m_Enabled: 1
1228+
m_EditorHideFlags: 0
1229+
m_Script: {fileID: 11500000, guid: 57ba63cd773e46a6bb63ac7c8762b277, type: 3}
1230+
m_Name:
1231+
m_EditorClassIdentifier:
1232+
speedBoostPrefab: {fileID: 1275289305280740, guid: 0476a246c44a1384394acffb4e07dc63,
1233+
type: 2}
12811234
--- !u!1 &2006129114 stripped
12821235
GameObject:
12831236
m_CorrespondingSourceObject: {fileID: 1255259902580470, guid: 81a1d0155a1c0a449843d0d7add20b04,

Assets/FluidBehaviorTree/Examples/CaptureTheFlag/Prefabs/Character.prefab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ MonoBehaviour:
186186
agent: {fileID: 195265657946772938}
187187
flagGraphic: {fileID: 1890313998322726}
188188
team: 0
189+
defender: 0
189190
--- !u!136 &136368325472492896
190191
CapsuleCollider:
191192
m_ObjectHideFlags: 1
@@ -211,7 +212,7 @@ NavMeshAgent:
211212
m_Speed: 10
212213
m_Acceleration: 8
213214
avoidancePriority: 50
214-
m_AngularSpeed: 120
215+
m_AngularSpeed: 500
215216
m_StoppingDistance: 0
216217
m_AutoTraverseOffMeshLink: 1
217218
m_AutoBraking: 1

Assets/FluidBehaviorTree/Examples/CaptureTheFlag/Prefabs/SpeedPowerup.prefab

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ GameObject:
2121
- component: {fileID: 4798518362713584}
2222
- component: {fileID: 33917241724278050}
2323
- component: {fileID: 23923354742556932}
24-
- component: {fileID: 65698696314734976}
2524
m_Layer: 0
2625
m_Name: SpeedPowerup
2726
m_TagString: Untagged
@@ -84,15 +83,3 @@ MeshFilter:
8483
m_PrefabInternal: {fileID: 100100000}
8584
m_GameObject: {fileID: 1275289305280740}
8685
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
87-
--- !u!65 &65698696314734976
88-
BoxCollider:
89-
m_ObjectHideFlags: 1
90-
m_CorrespondingSourceObject: {fileID: 0}
91-
m_PrefabInternal: {fileID: 100100000}
92-
m_GameObject: {fileID: 1275289305280740}
93-
m_Material: {fileID: 0}
94-
m_IsTrigger: 0
95-
m_Enabled: 1
96-
serializedVersion: 2
97-
m_Size: {x: 1, y: 1, z: 1}
98-
m_Center: {x: 0, y: 0, z: 0}

Assets/FluidBehaviorTree/Examples/CaptureTheFlag/Scripts/FlagChaser.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public enum Team {
1919
private Vector3 _origin;
2020
private BehaviorTree _tree;
2121
private bool _stun;
22+
private bool _speedBoosted;
2223

24+
private GameObject SpeedBoost => FlagManager.current.speedBoost;
2325
private GameObject Flag => FlagManager.current.flag;
2426

2527
private GameObject Goal => team == Team.Blue ?
@@ -31,6 +33,21 @@ private void Awake () {
3133
_tree = new BehaviorTreeBuilder(gameObject)
3234
.Selector()
3335
.Condition(() => _stun)
36+
.Sequence("Grab Speed Boost")
37+
.Condition("Not Carrying Flag", () => Flag != gameObject)
38+
.Condition("Not a Defender", () => !defender)
39+
.Condition("Speed Boost Spawned", () => SpeedBoost != null)
40+
.Condition("Not speed boosted", () => !_speedBoosted)
41+
.Do(() => {
42+
agent.SetDestination(SpeedBoost.transform.position);
43+
44+
if (Vector3.Distance(SpeedBoost.transform.position, transform.position) <= 1) {
45+
GrabSpeedBoost();
46+
}
47+
48+
return TaskStatus.Success;
49+
})
50+
.End()
3451
.Sequence("Capture Flag")
3552
.Condition("Not Carrying Flag", () => Flag != gameObject)
3653
.Selector()
@@ -56,7 +73,7 @@ private void Awake () {
5673
.Do(() => {
5774
agent.SetDestination(Goal.transform.position);
5875

59-
if (Vector3.Distance(Goal.transform.position, transform.position) <= 1) {
76+
if (Vector3.Distance(Goal.transform.position, transform.position) <= 2) {
6077
ScoreGoal();
6178
}
6279

@@ -98,6 +115,28 @@ private void GrabFlag () {
98115

99116
FlagManager.current.flag = gameObject;
100117
}
118+
119+
private void GrabSpeedBoost () {
120+
Destroy(SpeedBoost);
121+
122+
StopCoroutine(SpeedBoostLoop());
123+
StartCoroutine(SpeedBoostLoop());
124+
}
125+
126+
private IEnumerator SpeedBoostLoop () {
127+
var speed = agent.speed;
128+
var turning = agent.angularSpeed;
129+
130+
_speedBoosted = true;
131+
agent.speed += 5;
132+
agent.angularSpeed += 50;
133+
134+
yield return new WaitForSeconds(10);
135+
136+
_speedBoosted = false;
137+
agent.speed = speed;
138+
agent.angularSpeed = turning;
139+
}
101140

102141
private void Update () {
103142
_tree.Tick();

Assets/FluidBehaviorTree/Examples/CaptureTheFlag/Scripts/FlagManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class FlagManager : MonoBehaviour {
77
public GameObject flag;
88
public GameObject goalRed;
99
public GameObject goalBlue;
10+
public GameObject speedBoost;
1011

1112
[HideInInspector]
1213
public GameObject flagStart;

0 commit comments

Comments
 (0)