Added Conversions To and From WXYZ Quaternion Representations #295
|
@ -1,4 +1,4 @@
|
||||||
Start in Fullscreen: false
|
Start in Fullscreen: false
|
||||||
Starting Scene ID: 94246101
|
Starting Scene ID: 97158628
|
||||||
Window Size: {x: 1920, y: 1080}
|
Window Size: {x: 1920, y: 1080}
|
||||||
Window Title: SHADE Engine
|
Window Title: SHADE Engine
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,8 @@
|
||||||
|
- VertexShader: 39210065
|
||||||
|
FragmentShader: 46377769
|
||||||
|
SubPass: G-Buffer Write
|
||||||
|
Properties:
|
||||||
|
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
data.textureIndex: 54797199
|
||||||
|
data.alpha: 0
|
||||||
|
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: MT_Homeowner
|
||||||
|
ID: 129495479
|
||||||
|
Type: 7
|
|
@ -0,0 +1,8 @@
|
||||||
|
- VertexShader: 46580970
|
||||||
|
FragmentShader: 35983630
|
||||||
|
SubPass: G-Buffer Write
|
||||||
|
Properties:
|
||||||
|
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
data.textureIndex: 54324293
|
||||||
|
data.alpha: 0
|
||||||
|
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: UIMat_LoseScene
|
||||||
|
ID: 123313564
|
||||||
|
Type: 7
|
|
@ -0,0 +1,8 @@
|
||||||
|
- VertexShader: 46580970
|
||||||
|
FragmentShader: 35983630
|
||||||
|
SubPass: G-Buffer Write
|
||||||
|
Properties:
|
||||||
|
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
data.textureIndex: 54429632
|
||||||
|
data.alpha: 0
|
||||||
|
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: UIMat_MainMenu
|
||||||
|
ID: 121834459
|
||||||
|
Type: 7
|
|
@ -0,0 +1,8 @@
|
||||||
|
- VertexShader: 46580970
|
||||||
|
FragmentShader: 35983630
|
||||||
|
SubPass: G-Buffer Write
|
||||||
|
Properties:
|
||||||
|
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
data.textureIndex: 57302694
|
||||||
|
data.alpha: 0
|
||||||
|
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: UIMat_WinScene
|
||||||
|
ID: 129138332
|
||||||
|
Type: 7
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1,46 @@
|
||||||
|
Name: MD_BreakableObjects1
|
||||||
|
ID: 68661596
|
||||||
|
Type: 4
|
||||||
|
Sub Assets:
|
||||||
|
Name: Plate01_Unshattered
|
||||||
|
ID: 140964851
|
||||||
|
Type: 8
|
||||||
|
Name: Plate01_Shattered.004
|
||||||
|
ID: 136742160
|
||||||
|
Type: 8
|
||||||
|
Name: Plate01_Shattered.001
|
||||||
|
ID: 146557542
|
||||||
|
Type: 8
|
||||||
|
Name: Plate01_Shattered.002
|
||||||
|
ID: 145439064
|
||||||
|
Type: 8
|
||||||
|
Name: Plate01_Shattered.003
|
||||||
|
ID: 139411134
|
||||||
|
Type: 8
|
||||||
|
Name: Bowl01_Unshattered
|
||||||
|
ID: 144894491
|
||||||
|
Type: 8
|
||||||
|
Name: Bowl01_Shattered.001
|
||||||
|
ID: 140591337
|
||||||
|
Type: 8
|
||||||
|
Name: Bowl01_Shattered.002
|
||||||
|
ID: 148464002
|
||||||
|
Type: 8
|
||||||
|
Name: Bowl01_Shattered.003
|
||||||
|
ID: 144132426
|
||||||
|
Type: 8
|
||||||
|
Name: Cup01_Unshattered
|
||||||
|
ID: 134951952
|
||||||
|
Type: 8
|
||||||
|
Name: Cup01_Shattered.001
|
||||||
|
ID: 140710075
|
||||||
|
Type: 8
|
||||||
|
Name: Cup01_Shattered.002
|
||||||
|
ID: 147241586
|
||||||
|
Type: 8
|
||||||
|
Name: Cup01_Shattered.003
|
||||||
|
ID: 141067850
|
||||||
|
Type: 8
|
||||||
|
Name: Cup01_Shattered.004
|
||||||
|
ID: 142028102
|
||||||
|
Type: 8
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1,13 @@
|
||||||
|
Name: MD_FoodItems
|
||||||
|
ID: 79293496
|
||||||
|
Type: 4
|
||||||
|
Sub Assets:
|
||||||
|
Name: Cheese
|
||||||
|
ID: 141841143
|
||||||
|
Type: 8
|
||||||
|
Name: Apple
|
||||||
|
ID: 144128170
|
||||||
|
Type: 8
|
||||||
|
Name: Meat
|
||||||
|
ID: 136892700
|
||||||
|
Type: 8
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1,7 @@
|
||||||
|
Name: MD_Homeowner-NoRig
|
||||||
|
ID: 69970713
|
||||||
|
Type: 4
|
||||||
|
Sub Assets:
|
||||||
|
Name: BodyLow
|
||||||
|
ID: 140697366
|
||||||
|
Type: 8
|
|
@ -0,0 +1,276 @@
|
||||||
|
- EID: 0
|
||||||
|
Name: Main Camera
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 0.472120881, z: 2.53064919}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Camera Component:
|
||||||
|
Position: {x: 0, y: 0.472120881, z: 2.53064919}
|
||||||
|
Pitch: 0
|
||||||
|
Yaw: 0
|
||||||
|
Roll: 0
|
||||||
|
Width: 1920
|
||||||
|
Height: 1080
|
||||||
|
Near: 0.00999999978
|
||||||
|
Far: 10000
|
||||||
|
Perspective: true
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 2
|
||||||
|
Name: Light
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Light Component:
|
||||||
|
Position: {x: 0, y: 0, z: 0}
|
||||||
|
Type: Directional
|
||||||
|
Direction: {x: 0, y: 0, z: 1}
|
||||||
|
Color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
Layer: 4294967295
|
||||||
|
Strength: 0
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 1
|
||||||
|
Name: Plate
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 4
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0.00451920554, y: 0.829197884, z: 1.75}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 0.999979734, y: 1, z: 0.999979734}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 140964851
|
||||||
|
Material: 126974645
|
||||||
|
IsActive: true
|
||||||
|
RigidBody Component:
|
||||||
|
Type: Dynamic
|
||||||
|
Drag: 0.00999999978
|
||||||
|
Angular Drag: 0.00999999978
|
||||||
|
Use Gravity: true
|
||||||
|
Interpolate: true
|
||||||
|
Sleeping Enabled: true
|
||||||
|
Freeze Position X: false
|
||||||
|
Freeze Position Y: false
|
||||||
|
Freeze Position Z: false
|
||||||
|
Freeze Rotation X: false
|
||||||
|
Freeze Rotation Y: false
|
||||||
|
Freeze Rotation Z: false
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 0.200000003, y: 0.100000001, z: 0.200000003}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
IsActive: true
|
||||||
|
Scripts:
|
||||||
|
- Type: Breakable
|
||||||
|
Enabled: true
|
||||||
|
threshHold: 0
|
||||||
|
force: 1
|
||||||
|
- EID: 4
|
||||||
|
Name: Piece1
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 3.2922253e-07, y: 0, z: -0.0171992779}
|
||||||
|
Rotate: {x: -1.31316483e-07, y: 3.60887498e-09, z: 5.27542454e-11}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 146557542
|
||||||
|
Material: 124370424
|
||||||
|
IsActive: true
|
||||||
|
RigidBody Component:
|
||||||
|
Type: Dynamic
|
||||||
|
Drag: 0.00999999978
|
||||||
|
Angular Drag: 0.00999999978
|
||||||
|
Use Gravity: true
|
||||||
|
Interpolate: true
|
||||||
|
Sleeping Enabled: true
|
||||||
|
Freeze Position X: false
|
||||||
|
Freeze Position Y: false
|
||||||
|
Freeze Position Z: false
|
||||||
|
Freeze Rotation X: false
|
||||||
|
Freeze Rotation Y: false
|
||||||
|
Freeze Rotation Z: false
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 0.100000001, y: 0.0500000007, z: 0.150000006}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 5
|
||||||
|
Name: Piece2
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 2.47731805e-07, y: 0, z: 0.0325666666}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 145439064
|
||||||
|
Material: 124370424
|
||||||
|
IsActive: true
|
||||||
|
RigidBody Component:
|
||||||
|
Type: Dynamic
|
||||||
|
Drag: 0.00999999978
|
||||||
|
Angular Drag: 0.00999999978
|
||||||
|
Use Gravity: true
|
||||||
|
Interpolate: true
|
||||||
|
Sleeping Enabled: true
|
||||||
|
Freeze Position X: false
|
||||||
|
Freeze Position Y: false
|
||||||
|
Freeze Position Z: false
|
||||||
|
Freeze Rotation X: false
|
||||||
|
Freeze Rotation Y: false
|
||||||
|
Freeze Rotation Z: false
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 0.100000001, y: 0.0500000007, z: 0.200000003}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 6
|
||||||
|
Name: Piece3
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: -0.0502781346, y: 1.18017197e-05, z: 6.97374344e-05}
|
||||||
|
Rotate: {x: 0.021297913, y: 0.00146768149, z: -5.48749846e-08}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 139411134
|
||||||
|
Material: 124370424
|
||||||
|
IsActive: true
|
||||||
|
RigidBody Component:
|
||||||
|
Type: Dynamic
|
||||||
|
Drag: 0.00999999978
|
||||||
|
Angular Drag: 0.00999999978
|
||||||
|
Use Gravity: true
|
||||||
|
Interpolate: true
|
||||||
|
Sleeping Enabled: true
|
||||||
|
Freeze Position X: false
|
||||||
|
Freeze Position Y: false
|
||||||
|
Freeze Position Z: false
|
||||||
|
Freeze Rotation X: false
|
||||||
|
Freeze Rotation Y: false
|
||||||
|
Freeze Rotation Z: false
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 0.100000001, y: 0.0500000007, z: 0.150000006}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 7
|
||||||
|
Name: Piece4
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0.0364143178, y: 7.39097595e-06, z: 6.61611557e-05}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 136742160
|
||||||
|
Material: 124370424
|
||||||
|
IsActive: true
|
||||||
|
RigidBody Component:
|
||||||
|
Type: Dynamic
|
||||||
|
Drag: 0.00999999978
|
||||||
|
Angular Drag: 0.00999999978
|
||||||
|
Use Gravity: true
|
||||||
|
Interpolate: true
|
||||||
|
Sleeping Enabled: true
|
||||||
|
Freeze Position X: false
|
||||||
|
Freeze Position Y: false
|
||||||
|
Freeze Position Z: false
|
||||||
|
Freeze Rotation X: false
|
||||||
|
Freeze Rotation Y: false
|
||||||
|
Freeze Rotation Z: false
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 0.100000001, y: 0.0500000007, z: 0.150000006}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 3
|
||||||
|
Name: Ground
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: -0.414889663, z: 0}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 5, y: 1, z: 5}
|
||||||
|
IsActive: true
|
||||||
|
RigidBody Component:
|
||||||
|
Type: Static
|
||||||
|
Drag: 0.00999999978
|
||||||
|
Angular Drag: 0.00999999978
|
||||||
|
Use Gravity: true
|
||||||
|
Interpolate: true
|
||||||
|
Sleeping Enabled: true
|
||||||
|
Freeze Position X: false
|
||||||
|
Freeze Position Y: false
|
||||||
|
Freeze Position Z: false
|
||||||
|
Freeze Rotation X: false
|
||||||
|
Freeze Rotation Y: false
|
||||||
|
Freeze Rotation Z: false
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 1}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: Breakables
|
||||||
|
ID: 85040588
|
||||||
|
Type: 5
|
|
@ -0,0 +1,71 @@
|
||||||
|
- EID: 0
|
||||||
|
Name: Light
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Light Component:
|
||||||
|
Position: {x: 0, y: 0, z: 0}
|
||||||
|
Type: Directional
|
||||||
|
Direction: {x: 0, y: 0, z: 1}
|
||||||
|
Color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
Layer: 4294967295
|
||||||
|
Strength: 0
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 1
|
||||||
|
Name: Canvas
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 1
|
||||||
|
Components:
|
||||||
|
Canvas Component:
|
||||||
|
Canvas Width: 1920
|
||||||
|
Canvas Height: 1080
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 2
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 0, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 1920, y: 1080, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 141771688
|
||||||
|
Material: 123313564
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 3
|
||||||
|
Name: Camera
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 0, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Camera Component:
|
||||||
|
Position: {x: 0, y: 0, z: 0}
|
||||||
|
Pitch: 0
|
||||||
|
Yaw: 0
|
||||||
|
Roll: 0
|
||||||
|
Width: 1920
|
||||||
|
Height: 1080
|
||||||
|
Near: 0.00999999978
|
||||||
|
Far: 10000
|
||||||
|
Perspective: true
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 4
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components: ~
|
||||||
|
Scripts:
|
||||||
|
- Type: EndScene
|
||||||
|
Enabled: true
|
||||||
|
mainGameScene: 86098106
|
||||||
|
mainMainScene: 97158628
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: LoseScene
|
||||||
|
ID: 91685359
|
||||||
|
Type: 5
|
|
@ -82,7 +82,7 @@
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 0, y: 4.28833103, z: 0}
|
Translate: {x: 0, y: 4.28833103, z: 0}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 0, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
RigidBody Component:
|
||||||
Type: Dynamic
|
Type: Dynamic
|
||||||
|
@ -108,14 +108,6 @@
|
||||||
Density: 1
|
Density: 1
|
||||||
Position Offset: {x: 0, y: 0, z: 0}
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
Rotation Offset: {x: 0, y: 0, z: 0}
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
- Is Trigger: false
|
|
||||||
Type: Box
|
|
||||||
Half Extents: {x: 2, y: 2, z: 2}
|
|
||||||
Friction: 0.400000006
|
|
||||||
Bounciness: 0
|
|
||||||
Density: 1
|
|
||||||
Position Offset: {x: 0, y: 0, z: 0}
|
|
||||||
Rotation Offset: {x: 0, y: 0, z: 0}
|
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 65537
|
- EID: 65537
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,3 @@
|
||||||
|
Name: MainGameWithAI
|
||||||
|
ID: 96052853
|
||||||
|
Type: 5
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,3 @@
|
||||||
|
Name: MainGameWithAIFixed
|
||||||
|
ID: 89830755
|
||||||
|
Type: 5
|
|
@ -1,8 +1,12 @@
|
||||||
- EID: 0
|
- EID: 0
|
||||||
Name: Default
|
Name: Canvas
|
||||||
IsActive: true
|
IsActive: true
|
||||||
NumberOfChildren: 1
|
NumberOfChildren: 1
|
||||||
Components: ~
|
Components:
|
||||||
|
Canvas Component:
|
||||||
|
Canvas Width: 1920
|
||||||
|
Canvas Height: 1080
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 1
|
- EID: 1
|
||||||
Name: Default
|
Name: Default
|
||||||
|
@ -16,11 +20,11 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Renderable Component:
|
Renderable Component:
|
||||||
Mesh: 141771688
|
Mesh: 141771688
|
||||||
Material: 129340704
|
Material: 121834459
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 2
|
- EID: 2
|
||||||
Name: Default
|
Name: Light
|
||||||
IsActive: true
|
IsActive: true
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
|
@ -34,7 +38,7 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 3
|
- EID: 3
|
||||||
Name: Default
|
Name: Camera
|
||||||
IsActive: true
|
IsActive: true
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
|
@ -55,3 +59,11 @@
|
||||||
Perspective: true
|
Perspective: true
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
|
- EID: 4
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components: ~
|
||||||
|
Scripts:
|
||||||
|
- Type: MainMenu
|
||||||
|
Enabled: true
|
|
@ -0,0 +1,74 @@
|
||||||
|
- EID: 0
|
||||||
|
Name: Mesh_Homeowner
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 0, z: -1}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 140697366
|
||||||
|
Material: 129495479
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 1
|
||||||
|
Name: Light_Ambient
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Light Component:
|
||||||
|
Position: {x: 0, y: 0, z: 0}
|
||||||
|
Type: Ambient
|
||||||
|
Direction: {x: 0, y: 0, z: 1}
|
||||||
|
Color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
Layer: 4294967295
|
||||||
|
Strength: 1
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 2
|
||||||
|
Name: Mesh_Apple
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 0, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 144128170
|
||||||
|
Material: 131956078
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 3
|
||||||
|
Name: Mesh_Cheese
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 2.5, y: 0, z: 0}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 141841143
|
||||||
|
Material: 131956078
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 4
|
||||||
|
Name: Mesh_Meat
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 1, y: 0, z: 0}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 136892700
|
||||||
|
Material: 131956078
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: MeshImport
|
||||||
|
ID: 95609584
|
||||||
|
Type: 5
|
|
@ -104,6 +104,7 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: PlayerController
|
- Type: PlayerController
|
||||||
|
Enabled: true
|
||||||
currentState: 0
|
currentState: 0
|
||||||
maxMoveVel: 4
|
maxMoveVel: 4
|
||||||
moveForce: 50
|
moveForce: 50
|
||||||
|
@ -116,11 +117,13 @@
|
||||||
mediumMultiper: 0.5
|
mediumMultiper: 0.5
|
||||||
heavyMultiper: 0.25
|
heavyMultiper: 0.25
|
||||||
- Type: PickAndThrow
|
- Type: PickAndThrow
|
||||||
|
Enabled: true
|
||||||
throwForce: [300, 300, 300]
|
throwForce: [300, 300, 300]
|
||||||
delayTimer: 1
|
delayTimer: 1
|
||||||
aimingLength: 1.5
|
aimingLength: 1.5
|
||||||
- Type: StateMachine
|
- Type: StateMachine
|
||||||
currentStateName: Idle State
|
Enabled: true
|
||||||
|
currentStateName: ""
|
||||||
currentAnimName: ""
|
currentAnimName: ""
|
||||||
- EID: 3
|
- EID: 3
|
||||||
Name: HoldingPoint
|
Name: HoldingPoint
|
||||||
|
@ -140,13 +143,13 @@
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 0, y: 0, z: 0}
|
Translate: {x: 0, y: 0, z: 0}
|
||||||
Rotate: {x: -0.361278683, y: 4.97423792, z: 0}
|
Rotate: {x: -0.738241911, y: 0.48064509, z: 0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Camera Component:
|
Camera Component:
|
||||||
Position: {x: 0.330392599, y: -2.72767258, z: 5.02710676}
|
Position: {x: -0.0897406489, y: -4.07369709, z: 3.6087606}
|
||||||
Pitch: -42.2981491
|
Pitch: -42.2981453
|
||||||
Yaw: 16.4989166
|
Yaw: 16.4989109
|
||||||
Roll: 0
|
Roll: 0
|
||||||
Width: 1920
|
Width: 1920
|
||||||
Height: 1080
|
Height: 1080
|
||||||
|
@ -156,6 +159,7 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: SHADE_Scripting.ThirdPersonCamera
|
- Type: SHADE_Scripting.ThirdPersonCamera
|
||||||
|
Enabled: true
|
||||||
armLength: 2
|
armLength: 2
|
||||||
turnSpeedPitch: 0.300000012
|
turnSpeedPitch: 0.300000012
|
||||||
turnSpeedYaw: 0.5
|
turnSpeedYaw: 0.5
|
||||||
|
@ -273,16 +277,17 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: GameManager
|
- Type: GameManager
|
||||||
|
Enabled: true
|
||||||
itemPool: 12
|
itemPool: 12
|
||||||
zonePool: 15
|
zonePool: 15
|
||||||
currGameState: 3
|
currGameState: 0
|
||||||
totalItemCount: 2
|
totalItemCount: 0
|
||||||
Score: 0
|
Score: 0
|
||||||
timer: 4.00741768
|
timer: 50
|
||||||
- EID: 12
|
- EID: 12
|
||||||
Name: ItemPool
|
Name: ItemPool
|
||||||
IsActive: true
|
IsActive: true
|
||||||
NumberOfChildren: 2
|
NumberOfChildren: 3
|
||||||
Components: ~
|
Components: ~
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 10
|
- EID: 10
|
||||||
|
@ -334,6 +339,7 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: Item
|
- Type: Item
|
||||||
|
Enabled: true
|
||||||
Score: 1
|
Score: 1
|
||||||
currCategory: 0
|
currCategory: 0
|
||||||
- EID: 5
|
- EID: 5
|
||||||
|
@ -385,8 +391,57 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: Item
|
- Type: Item
|
||||||
|
Enabled: true
|
||||||
Score: 1
|
Score: 1
|
||||||
currCategory: 0
|
currCategory: 0
|
||||||
|
- EID: 16
|
||||||
|
Name: Mesh_Apple
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: -2.57231402, y: -3.27855849, z: 0}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 144128170
|
||||||
|
Material: 131956078
|
||||||
|
IsActive: true
|
||||||
|
RigidBody Component:
|
||||||
|
Type: Dynamic
|
||||||
|
Drag: 0.00999999978
|
||||||
|
Angular Drag: 0.00999999978
|
||||||
|
Use Gravity: true
|
||||||
|
Interpolate: true
|
||||||
|
Sleeping Enabled: true
|
||||||
|
Freeze Position X: false
|
||||||
|
Freeze Position Y: false
|
||||||
|
Freeze Position Z: false
|
||||||
|
Freeze Rotation X: false
|
||||||
|
Freeze Rotation Y: false
|
||||||
|
Freeze Rotation Z: false
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 0.100000001, y: 0.100000001, z: 0.100000001}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
- Is Trigger: true
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 0.300000012, y: 0.300000012, z: 0.300000012}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
- EID: 15
|
- EID: 15
|
||||||
Name: ScoreZonePool
|
Name: ScoreZonePool
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -430,6 +485,7 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: ScoringZone
|
- Type: ScoringZone
|
||||||
|
Enabled: true
|
||||||
- EID: 14
|
- EID: 14
|
||||||
Name: ScoreZone
|
Name: ScoreZone
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -467,3 +523,4 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts:
|
Scripts:
|
||||||
- Type: ScoringZone
|
- Type: ScoringZone
|
||||||
|
Enabled: true
|
|
@ -0,0 +1,71 @@
|
||||||
|
- EID: 0
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Light Component:
|
||||||
|
Position: {x: 0, y: 0, z: 0}
|
||||||
|
Type: Directional
|
||||||
|
Direction: {x: 0, y: 0, z: 1}
|
||||||
|
Color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
Layer: 4294967295
|
||||||
|
Strength: 0
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 1
|
||||||
|
Name: Canvas
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 1
|
||||||
|
Components:
|
||||||
|
Canvas Component:
|
||||||
|
Canvas Width: 1920
|
||||||
|
Canvas Height: 1080
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 2
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 0, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 1920, y: 1080, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Renderable Component:
|
||||||
|
Mesh: 141771688
|
||||||
|
Material: 129138332
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 3
|
||||||
|
Name: Camera
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 0, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Camera Component:
|
||||||
|
Position: {x: 0, y: 0, z: 0}
|
||||||
|
Pitch: 0
|
||||||
|
Yaw: 0
|
||||||
|
Roll: 0
|
||||||
|
Width: 1920
|
||||||
|
Height: 1080
|
||||||
|
Near: 0.00999999978
|
||||||
|
Far: 10000
|
||||||
|
Perspective: true
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 4
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components: ~
|
||||||
|
Scripts:
|
||||||
|
- Type: EndScene
|
||||||
|
Enabled: true
|
||||||
|
mainGameScene: 86098106
|
||||||
|
mainMainScene: 97158628
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: WinScene
|
||||||
|
ID: 92009475
|
||||||
|
Type: 5
|
|
@ -1,183 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SHADE;
|
|
||||||
|
|
||||||
public class AIPrototype : Script
|
|
||||||
{
|
|
||||||
//This object's relevant components
|
|
||||||
private Transform transform;
|
|
||||||
private RigidBody rb;
|
|
||||||
|
|
||||||
/*[SerializeField]
|
|
||||||
[Tooltip("The list of waypoints that the object will move around on")]
|
|
||||||
private Vector3[] waypoints;*/
|
|
||||||
|
|
||||||
private Vector3[] waypoints = { new Vector3(-8.0f, -2.0f, 3.5f), new Vector3(-8.0f, -2.0f, -13.0f), new Vector3(8.0f, -2.0f, -13.0f), new Vector3(8.0f, -2.0f, 3.5f) };
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
[Tooltip("How much force is applied in movement")]
|
|
||||||
private float movementForceMultiplier = 100.0f;
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
[Tooltip("How fast the object moves about waypoints")]
|
|
||||||
private float patrolSpeed = 0.4f;
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
[Tooltip("How fast the object moves while chasing")]
|
|
||||||
private float chaseSpeed = 0.8f;
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
[Tooltip("How near the player must be to the AI for capture")]
|
|
||||||
private float distanceToCapture = 1.2f;
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
[Tooltip("How near the player must be for the chase to begin. Should be less than distanceToEndChase")]
|
|
||||||
private float distanceToStartChase = 2.0f;
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
[Tooltip("How far the player must be for the chase to end. Should be greater than distanceToStartChase")]
|
|
||||||
private float distanceToEndChase = 2.5f;
|
|
||||||
|
|
||||||
//Whether the AI is chasing or not
|
|
||||||
private bool chaseMode;
|
|
||||||
|
|
||||||
//To cycle depending on the length of waypoints
|
|
||||||
private int currentTargetWaypointIndex;
|
|
||||||
|
|
||||||
private GameObject? player;
|
|
||||||
|
|
||||||
|
|
||||||
protected override void awake()
|
|
||||||
{
|
|
||||||
transform = GetComponent<Transform>();
|
|
||||||
if (transform == null)
|
|
||||||
{
|
|
||||||
Debug.LogError("Transform is NULL!");
|
|
||||||
}
|
|
||||||
|
|
||||||
rb = GetComponent<RigidBody>();
|
|
||||||
if (rb == null)
|
|
||||||
{
|
|
||||||
Debug.LogError("Rigidbody is NULL!");
|
|
||||||
}
|
|
||||||
|
|
||||||
currentTargetWaypointIndex = 0;
|
|
||||||
|
|
||||||
player = GameObject.Find("Player");
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
Debug.LogError("Player is NULL!");
|
|
||||||
}
|
|
||||||
|
|
||||||
chaseMode = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void fixedUpdate()
|
|
||||||
{
|
|
||||||
//Patrolling
|
|
||||||
if (!chaseMode)
|
|
||||||
{
|
|
||||||
//Head towards the next target
|
|
||||||
Vector3 normalisedDifference = waypoints[currentTargetWaypointIndex] - transform.GlobalPosition;
|
|
||||||
normalisedDifference /= normalisedDifference.GetMagnitude();
|
|
||||||
|
|
||||||
//transform.GlobalPosition += normalisedDifference * moveSpeed * (float)Time.DeltaTime;
|
|
||||||
//rb.LinearVelocity = normalisedDifference * patrolSpeed;
|
|
||||||
|
|
||||||
//ORIGINAL INTENDED CODE
|
|
||||||
/*rb.AddForce(new Vector3(normalisedDifference.x, 0.0f, normalisedDifference.z) * movementForceMultiplier);
|
|
||||||
float currentSpeed = MathF.Sqrt(rb.LinearVelocity.x * rb.LinearVelocity.x + rb.LinearVelocity.z * rb.LinearVelocity.z);
|
|
||||||
if (currentSpeed > patrolSpeed)
|
|
||||||
{
|
|
||||||
float adjustmentFactor = patrolSpeed / currentSpeed;
|
|
||||||
Vector3 adjustedVelocity = rb.LinearVelocity;
|
|
||||||
//adjustedVelocity *= adjustmentFactor;
|
|
||||||
adjustedVelocity.x = patrolSpeed;
|
|
||||||
adjustedVelocity.z = patrolSpeed;
|
|
||||||
rb.LinearVelocity = adjustedVelocity;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//TODO delete this when original intended code above works with velocity being limited correctly
|
|
||||||
rb.LinearVelocity = normalisedDifference * patrolSpeed;
|
|
||||||
|
|
||||||
//transform.GlobalRotation.SetLookRotation(waypoints[currentTargetWaypointIndex], Vector3.Up);
|
|
||||||
|
|
||||||
//Cycle to next waypoint if near enough current waypoint
|
|
||||||
if ((waypoints[currentTargetWaypointIndex] - transform.GlobalPosition).GetSqrMagnitude() <= 0.5f)
|
|
||||||
{
|
|
||||||
++currentTargetWaypointIndex;
|
|
||||||
if (currentTargetWaypointIndex >= waypoints.Length)
|
|
||||||
{
|
|
||||||
currentTargetWaypointIndex = 0; //Recycle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Go chase if near enough to player
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
Transform pTransform = player.GetValueOrDefault().GetComponent<Transform>();
|
|
||||||
if ((pTransform.GlobalPosition - transform.GlobalPosition).GetMagnitude() <= distanceToStartChase)
|
|
||||||
{
|
|
||||||
//Start the chase
|
|
||||||
chaseMode = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else //Chasing
|
|
||||||
{
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
Transform pTransform = player.GetValueOrDefault().GetComponent<Transform>();
|
|
||||||
|
|
||||||
//Chase the player
|
|
||||||
Vector3 normalisedDifference = pTransform.GlobalPosition - transform.GlobalPosition;
|
|
||||||
normalisedDifference /= normalisedDifference.GetMagnitude();
|
|
||||||
|
|
||||||
//transform.GlobalPosition += normalisedDifference * moveSpeed * (float)Time.DeltaTime;
|
|
||||||
|
|
||||||
//ORIGINAL INTENDED CODE
|
|
||||||
/*rb.AddForce(new Vector3(normalisedDifference.x, 0.0f, normalisedDifference.z) * movementForceMultiplier);
|
|
||||||
float currentSpeed = MathF.Sqrt(rb.LinearVelocity.x * rb.LinearVelocity.x + rb.LinearVelocity.z * rb.LinearVelocity.z);
|
|
||||||
if (currentSpeed > chaseSpeed)
|
|
||||||
{
|
|
||||||
float adjustmentFactor = chaseSpeed / currentSpeed;
|
|
||||||
Vector3 adjustedVelocity = rb.LinearVelocity;
|
|
||||||
adjustedVelocity *= adjustmentFactor;
|
|
||||||
rb.LinearVelocity = adjustedVelocity;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//TODO delete this when original intended code above works with velocity being limited correctly
|
|
||||||
rb.LinearVelocity = normalisedDifference * chaseSpeed;
|
|
||||||
|
|
||||||
//Capture player if near enough
|
|
||||||
if ((pTransform.GlobalPosition - transform.GlobalPosition).GetMagnitude() <= distanceToCapture)
|
|
||||||
{
|
|
||||||
player.GetValueOrDefault().GetScript<PlayerController>().currentState = PlayerController.RaccoonStates.CAUGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
//End chase if too far
|
|
||||||
if ((pTransform.GlobalPosition - transform.GlobalPosition).GetMagnitude() >= distanceToEndChase)
|
|
||||||
{
|
|
||||||
//Stop the chase
|
|
||||||
chaseMode = false;
|
|
||||||
|
|
||||||
//Find the nearest waypoint to go instead
|
|
||||||
float nearestWaypointDistance = 99999999999999.9f;
|
|
||||||
for (int i = 0; i < waypoints.Length; ++i)
|
|
||||||
{
|
|
||||||
if ((waypoints[i] - transform.GlobalPosition).GetSqrMagnitude() < nearestWaypointDistance)
|
|
||||||
{
|
|
||||||
nearestWaypointDistance = waypoints[i].GetSqrMagnitude();
|
|
||||||
currentTargetWaypointIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
Name: AIPrototype
|
|
||||||
ID: 163215061
|
|
||||||
Type: 9
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file BehaviourTree.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief Based off Kheng Ian's SC_BTTree.cs
|
||||||
|
* Abstract class to be inherited as the "core" of any entity's AI
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
using SHADE;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.Design;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SHADE_Scripting.AIBehaviour.BehaviourTree
|
||||||
|
{
|
||||||
|
public abstract partial class BehaviourTree : Script
|
||||||
|
{
|
||||||
|
//The root of the tree, it should not have any parent
|
||||||
|
private BehaviourTreeNode _root = null;
|
||||||
|
protected BehaviourTreeNode root { get => _root; set => _root = value; }
|
||||||
|
|
||||||
|
//Events of the behaviour tree
|
||||||
|
public abstract BehaviourTreeEvents events { get; }
|
||||||
|
|
||||||
|
//Dictionary containing every single node in the tree
|
||||||
|
//Key is the node's unique name
|
||||||
|
public Dictionary<string, BehaviourTreeNode> nodeDictionary = new Dictionary<string, BehaviourTreeNode>();
|
||||||
|
|
||||||
|
//When inheriting from the class, this is where you would define your tree structure
|
||||||
|
|
||||||
|
//Very important
|
||||||
|
//Override this to construct the behaviour tree of any AI
|
||||||
|
protected abstract BehaviourTreeNode CreateTree();
|
||||||
|
|
||||||
|
//awake and update functions
|
||||||
|
//the only segment in the entire AI that is dependent on the engine
|
||||||
|
protected override void awake()
|
||||||
|
{
|
||||||
|
_root = CreateTree();
|
||||||
|
_root.InitialiseNode(this);
|
||||||
|
Initialise();
|
||||||
|
}
|
||||||
|
protected override void update()
|
||||||
|
{
|
||||||
|
_root?.Evaluate();
|
||||||
|
Tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void Initialise();
|
||||||
|
protected abstract void Tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
//BLACKBOARD SYSTEM///////////////////////////////////////////////////////////
|
||||||
|
//Shared data within the tree, implemented as a dictionary of objects
|
||||||
|
public abstract partial class BehaviourTree : Script
|
||||||
|
{
|
||||||
|
//Data to be shared among nodes
|
||||||
|
public Dictionary<string, object> blackboard = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
//Getters and setters for the blackboard
|
||||||
|
public object GetData(string key)
|
||||||
|
{
|
||||||
|
//Debug.Log("Getting Data " + key);
|
||||||
|
object outData = null;
|
||||||
|
if (blackboard.TryGetValue(key, out outData))
|
||||||
|
{
|
||||||
|
return outData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Debug.LogError("Cannot retrieve data " + key);
|
||||||
|
return outData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void SetData(string key, object data)
|
||||||
|
{
|
||||||
|
blackboard[key] = data;
|
||||||
|
}
|
||||||
|
public bool ClearData(string key)
|
||||||
|
{
|
||||||
|
if (blackboard.ContainsKey(key))
|
||||||
|
{
|
||||||
|
blackboard.Remove(key);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: BehaviourTree
|
||||||
|
ID: 156799455
|
||||||
|
Type: 9
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file BehaviourTreeEvents.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief Based off Kheng Ian's SC_BTEvents.cs
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
namespace SHADE_Scripting.AIBehaviour.BehaviourTree
|
||||||
|
{
|
||||||
|
public abstract class BehaviourTreeEvents
|
||||||
|
{
|
||||||
|
public BehaviourTree tree;
|
||||||
|
public BehaviourTreeEvents(BehaviourTree tree)
|
||||||
|
{
|
||||||
|
this.tree = tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called at the start
|
||||||
|
public abstract void Initialise();
|
||||||
|
//Called at every tick
|
||||||
|
public abstract void Tick();
|
||||||
|
|
||||||
|
public void OnEnterAddListener(string name, Delegate action)
|
||||||
|
{
|
||||||
|
BehaviourTreeNode targetNode;
|
||||||
|
tree.nodeDictionary.TryGetValue(name, out targetNode);
|
||||||
|
targetNode.onEnterEvent += (EventHandler)action;
|
||||||
|
}
|
||||||
|
public void OnExitAddListener(string name, Delegate action)
|
||||||
|
{
|
||||||
|
BehaviourTreeNode targetNode;
|
||||||
|
tree.nodeDictionary.TryGetValue(name, out targetNode);
|
||||||
|
targetNode.onExitEvent += (EventHandler)action;
|
||||||
|
}
|
||||||
|
public void OnEnterRemoveListener(string name, Delegate action)
|
||||||
|
{
|
||||||
|
BehaviourTreeNode targetNode;
|
||||||
|
tree.nodeDictionary.TryGetValue(name, out targetNode);
|
||||||
|
targetNode.onEnterEvent -= (EventHandler)action;
|
||||||
|
}
|
||||||
|
public void OnExitRemoveListener(string name, Delegate action)
|
||||||
|
{
|
||||||
|
BehaviourTreeNode targetNode;
|
||||||
|
tree.nodeDictionary.TryGetValue(name, out targetNode);
|
||||||
|
targetNode.onExitEvent -= (EventHandler)action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: BehaviourTreeEvents
|
||||||
|
ID: 157306586
|
||||||
|
Type: 9
|
|
@ -0,0 +1,143 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file BehaviourTreeNode.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief Based off Kheng Ian's SC_BTNode.cs
|
||||||
|
* Abstract implementation of individual nodes of a behaviour tree
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SHADE_Scripting.AIBehaviour.BehaviourTree
|
||||||
|
{
|
||||||
|
//ENUMERATIONS FOR NODE STATUS////////////////////////////////////////////////
|
||||||
|
public enum BehaviourTreeNodeStatus
|
||||||
|
{
|
||||||
|
RUNNING, //Node has not finished evaluating, to be re-evaluated
|
||||||
|
SUCCESS, //Node has been evaluated to be a success
|
||||||
|
FAILURE //Node has been evaluated to be a failure
|
||||||
|
}
|
||||||
|
|
||||||
|
//CORE TRAVERSAL SYSTEM OF BEHAVIOUR TREE/////////////////////////////////////
|
||||||
|
public partial class BehaviourTreeNode
|
||||||
|
{
|
||||||
|
//The main tree structure that the node is in
|
||||||
|
//This needs to be specified by the root node so that it can permutate to its children
|
||||||
|
public BehaviourTree tree;
|
||||||
|
|
||||||
|
//This portion functions similar to a doubly-linked list,
|
||||||
|
//only having a list of children instead of a single reference
|
||||||
|
public BehaviourTreeNode parent;
|
||||||
|
protected List<BehaviourTreeNode> children = new List<BehaviourTreeNode>();
|
||||||
|
|
||||||
|
//Current status of the node
|
||||||
|
//Technically redundant as nodes already return their status via the
|
||||||
|
//Evaluate() function
|
||||||
|
protected BehaviourTreeNodeStatus status;
|
||||||
|
|
||||||
|
//Constructors, to be overriden by its children as needed
|
||||||
|
public BehaviourTreeNode(string name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
parent = null;
|
||||||
|
}
|
||||||
|
public BehaviourTreeNode(string name, List<BehaviourTreeNode> children)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
foreach (BehaviourTreeNode child in children)
|
||||||
|
Attach(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Attach a child node to a BT node
|
||||||
|
private void Attach(BehaviourTreeNode child)
|
||||||
|
{
|
||||||
|
child.parent = this;
|
||||||
|
children.Add(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Very important
|
||||||
|
//Must be overriden by its derived classes (control flow / leaf / decorators)
|
||||||
|
//Defines the traversal method of the node
|
||||||
|
//Called every frame via the root from the BT
|
||||||
|
public virtual BehaviourTreeNodeStatus Evaluate()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("Missing implementation of Evaluate() function!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//To attach the tree, called in the Start() tick AFTER creation of the tree
|
||||||
|
public void InitialiseNode(BehaviourTree tree)
|
||||||
|
{
|
||||||
|
this.tree = tree;
|
||||||
|
|
||||||
|
//Add itself to the tree's node dictionary
|
||||||
|
if (tree.nodeDictionary.ContainsKey(name))
|
||||||
|
throw new Exception("Node name: " + name + " is not unique! Please assign a unique name to each node!");
|
||||||
|
else
|
||||||
|
tree.nodeDictionary.Add(name, this);
|
||||||
|
|
||||||
|
//TODO initialise its events
|
||||||
|
//onEnterEvent = new
|
||||||
|
//onExitEvent = new
|
||||||
|
|
||||||
|
//Recurse InitialiseNode() in children
|
||||||
|
foreach (BehaviourTreeNode child in children)
|
||||||
|
child.InitialiseNode(tree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//BLACKBOARD SYSTEM///////////////////////////////////////////////////////////
|
||||||
|
//To be able to access tree's data from any node in the tree
|
||||||
|
public partial class BehaviourTreeNode
|
||||||
|
{
|
||||||
|
//Getter and setter functions for blackboard data
|
||||||
|
public object GetNodeData(string key)
|
||||||
|
{
|
||||||
|
return tree.GetData(key);
|
||||||
|
}
|
||||||
|
public void SetNodeData(string key, object data)
|
||||||
|
{
|
||||||
|
tree.SetData(key, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Removes blackboard data of name key
|
||||||
|
public bool ClearNodeData(string key)
|
||||||
|
{
|
||||||
|
return tree.ClearData(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//EVENT/CALLBACK SYSTEM///////////////////////////////////////////////////////
|
||||||
|
public class BehaviourTreeEventArgs : System.EventArgs
|
||||||
|
{
|
||||||
|
public BehaviourTreeNodeStatus returnStatus { get; set; }
|
||||||
|
public BehaviourTreeEventArgs(BehaviourTreeNodeStatus status) { returnStatus = status; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class BehaviourTreeNode
|
||||||
|
{
|
||||||
|
//Mainly used for the callback system
|
||||||
|
//"name" must be unique to each node instance
|
||||||
|
//Events must be replaced by custom engine counterpart
|
||||||
|
public string name;
|
||||||
|
public System.EventHandler onEnterEvent;
|
||||||
|
public System.EventHandler onExitEvent;
|
||||||
|
public void onEnter(BehaviourTreeNodeStatus status)
|
||||||
|
{
|
||||||
|
onEnterEvent?.Invoke(this, new BehaviourTreeEventArgs(status));
|
||||||
|
}
|
||||||
|
public void onExit(BehaviourTreeNodeStatus status)
|
||||||
|
{
|
||||||
|
onExitEvent?.Invoke(this, new BehaviourTreeEventArgs(status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: BehaviourTreeNode
|
||||||
|
ID: 159032454
|
||||||
|
Type: 9
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file BehaviourTreeSelector.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief Based off Kheng Ian's SC_BTSelector.cs
|
||||||
|
* Selectors function like "OR" nodes, returning success on the
|
||||||
|
* first successful child and stopping operation
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SHADE_Scripting.AIBehaviour.BehaviourTree
|
||||||
|
{
|
||||||
|
public class BehaviourTreeSelector : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
public BehaviourTreeSelector(string name) : base(name) { }
|
||||||
|
public BehaviourTreeSelector(string name, List<BehaviourTreeNode> children) :
|
||||||
|
base(name, children)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public override BehaviourTreeNodeStatus Evaluate()
|
||||||
|
{
|
||||||
|
onEnter(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
for (int i = 0; i < children.Count; ++i)
|
||||||
|
{
|
||||||
|
switch (children[i].Evaluate())
|
||||||
|
{
|
||||||
|
case BehaviourTreeNodeStatus.RUNNING:
|
||||||
|
status = BehaviourTreeNodeStatus.RUNNING;
|
||||||
|
onExit(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
return status;
|
||||||
|
case BehaviourTreeNodeStatus.SUCCESS:
|
||||||
|
status = BehaviourTreeNodeStatus.SUCCESS;
|
||||||
|
onExit(BehaviourTreeNodeStatus.SUCCESS);
|
||||||
|
return status;
|
||||||
|
case BehaviourTreeNodeStatus.FAILURE:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: BehaviourTreeSelector
|
||||||
|
ID: 167568513
|
||||||
|
Type: 9
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file BehaviourTreeSequence.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief Based off Kheng Ian's SC_BTSelector.cs
|
||||||
|
* Sequences function like "AND" nodes, having to process every child
|
||||||
|
* successfully to return a success. Returns a failure on the first
|
||||||
|
* child that fails
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SHADE_Scripting.AIBehaviour.BehaviourTree
|
||||||
|
{
|
||||||
|
public class BehaviourTreeSequence : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
public BehaviourTreeSequence(string name) : base(name) { }
|
||||||
|
public BehaviourTreeSequence(string name, List<BehaviourTreeNode> children) :
|
||||||
|
base(name, children) { }
|
||||||
|
|
||||||
|
public override BehaviourTreeNodeStatus Evaluate()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
onEnter(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
for (int i = 0; i < children.Count; ++i)
|
||||||
|
{
|
||||||
|
switch (children[i].Evaluate())
|
||||||
|
{
|
||||||
|
case BehaviourTreeNodeStatus.SUCCESS:
|
||||||
|
continue;
|
||||||
|
case BehaviourTreeNodeStatus.RUNNING:
|
||||||
|
status = BehaviourTreeNodeStatus.RUNNING;
|
||||||
|
onExit(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
return status;
|
||||||
|
case BehaviourTreeNodeStatus.FAILURE:
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status = BehaviourTreeNodeStatus.SUCCESS;
|
||||||
|
onExit(BehaviourTreeNodeStatus.SUCCESS);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: BehaviourTreeSequence
|
||||||
|
ID: 154302585
|
||||||
|
Type: 9
|
|
@ -0,0 +1,173 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file Homeowner1.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief The implemented behaviour tree for the homeowner
|
||||||
|
* A prototype to prove that behaviour trees can be worked and expanded
|
||||||
|
* on in the custom engine for GAM300 Milestone 3 and expanded over
|
||||||
|
* GAM350
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
using SHADE;
|
||||||
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//Variables required for the AI to function
|
||||||
|
//To be attached to the game object via the inspector
|
||||||
|
public partial class Homeowner1 : BehaviourTree
|
||||||
|
{
|
||||||
|
private BehaviourTreeEvents _events { get; set; }
|
||||||
|
public override BehaviourTreeEvents events { get => _events; }
|
||||||
|
|
||||||
|
//PATROL FIELDS///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("The list of waypoints for the AI to cycle around")]
|
||||||
|
private GameObject waypointsPool;
|
||||||
|
|
||||||
|
private List<GameObject> waypoints;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("The AI will patrol at this speed")]
|
||||||
|
private float patrolSpeed;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("The speed at which the AI will chase the player if sighted")]
|
||||||
|
private float chaseSpeed;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("Turning speed multiplier of the AI. 10 is good")]
|
||||||
|
private float turningSpeed;
|
||||||
|
|
||||||
|
//FIELD OF VISION/////////////////////////////////////////////////////////////
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("How far the AI can see up to")]
|
||||||
|
private float sightDistance;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("How far the eyes are offset from the AI's actual position")]
|
||||||
|
private Vector3 eyeOffset;
|
||||||
|
|
||||||
|
//ATTACKING///////////////////////////////////////////////////////////////////
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("How near the player mut be to the AI for capture")]
|
||||||
|
private float distanceToCapture;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("How long the player should be in the attack range for successful capture")]
|
||||||
|
private float captureTime;
|
||||||
|
|
||||||
|
|
||||||
|
//There's definitely a better way to do this
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("TO BE REMOVED IN 350. Interval multiplier between footsteps")]
|
||||||
|
private float footstepSFXIntervalMultiplier;
|
||||||
|
|
||||||
|
private float footstepTimeRemaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
//AI tree
|
||||||
|
public partial class Homeowner1 : BehaviourTree
|
||||||
|
{
|
||||||
|
//Called at the start
|
||||||
|
protected override void Initialise()
|
||||||
|
{
|
||||||
|
_events = new Homeowner1Events(this);
|
||||||
|
events.Initialise();
|
||||||
|
|
||||||
|
//(25 Nov) DO NOT Initialise the data here
|
||||||
|
/*if (waypointsPool)
|
||||||
|
{
|
||||||
|
waypoints = (List<GameObject>)waypointsPool.GetChildren();
|
||||||
|
SetData("waypoints", waypoints);
|
||||||
|
}
|
||||||
|
SetData("transform", GetComponent<Transform>());
|
||||||
|
SetData("rigidBody", GetComponent<RigidBody>());
|
||||||
|
SetData("eyeOffset", eyeOffset);
|
||||||
|
SetData("sightDistance", sightDistance);
|
||||||
|
SetData("patrolSpeed", patrolSpeed);
|
||||||
|
SetData("chaseSpeed", chaseSpeed);
|
||||||
|
SetData("turningSpeed", turningSpeed);
|
||||||
|
SetData("distanceToCapture", distanceToCapture);
|
||||||
|
SetData("baseCaptureTime", captureTime);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called every tick
|
||||||
|
protected override void Tick()
|
||||||
|
{
|
||||||
|
//Debug.Log("Ticking");
|
||||||
|
//Update data
|
||||||
|
if (GetData("waypoints") == null)
|
||||||
|
{
|
||||||
|
if (waypointsPool != GameObject.Null)
|
||||||
|
SetData("waypoints", (List<GameObject>)waypointsPool.GetChildren());
|
||||||
|
else
|
||||||
|
Debug.LogError("No waypoints, no AI");
|
||||||
|
}
|
||||||
|
if (GetData("transform") == null)
|
||||||
|
SetData("transform", GetComponent<Transform>());
|
||||||
|
if (GetData("rigidBody") == null)
|
||||||
|
SetData("rigidBody", GetComponent<RigidBody>());
|
||||||
|
if (GetData("eyeOffset") == null || (Vector3)GetData("eyeOffset") != eyeOffset)
|
||||||
|
SetData("eyeOffset", eyeOffset);
|
||||||
|
if (GetData("sightDistance") == null || (float)GetData("sightDistance") != sightDistance)
|
||||||
|
SetData("sightDistance", sightDistance);
|
||||||
|
if (GetData("patrolSpeed") == null || (float)GetData("patrolSpeed") != patrolSpeed)
|
||||||
|
SetData("patrolSpeed", patrolSpeed);
|
||||||
|
if (GetData("chaseSpeed") == null || (float)GetData("chaseSpeed") != chaseSpeed)
|
||||||
|
SetData("chaseSpeed", chaseSpeed);
|
||||||
|
if (GetData("turningSpeed") == null || (float)GetData("turningSpeed") != turningSpeed)
|
||||||
|
SetData("turningSpeed", turningSpeed);
|
||||||
|
if (GetData("distanceToCapture") == null || (float)GetData("distanceToCapture") != distanceToCapture)
|
||||||
|
SetData("distanceToCapture", distanceToCapture);
|
||||||
|
if (GetData("baseCaptureTime") == null || (float)GetData("baseCaptureTime") != captureTime)
|
||||||
|
SetData("baseCaptureTime", captureTime);
|
||||||
|
|
||||||
|
|
||||||
|
events.Tick();
|
||||||
|
|
||||||
|
//Footsteps SFX, move them somewhere else soon
|
||||||
|
float velocity = GetComponent<RigidBody>().LinearVelocity.GetMagnitude();
|
||||||
|
|
||||||
|
footstepTimeRemaining -= velocity * Time.DeltaTimeF;
|
||||||
|
if (footstepTimeRemaining < 0.0f)
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_footsteps");
|
||||||
|
footstepTimeRemaining = footstepSFXIntervalMultiplier;
|
||||||
|
}
|
||||||
|
//Debug.Log("Ticked");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Define the behaviour tree here
|
||||||
|
//Order of which nodes are created affects order of execution
|
||||||
|
//The tree is called from the root every tick
|
||||||
|
protected override BehaviourTreeNode CreateTree()
|
||||||
|
{
|
||||||
|
//Debug.Log("Creating Tree");
|
||||||
|
//Start from the root, structure it like this to make it look like a tree
|
||||||
|
BehaviourTreeNode root = new BehaviourTreeSelector("Root", new List<BehaviourTreeNode>
|
||||||
|
{
|
||||||
|
new BehaviourTreeSequence("Alerted", new List<BehaviourTreeNode>
|
||||||
|
{
|
||||||
|
new LeafSearch("SearchFOV"),
|
||||||
|
new BehaviourTreeSequence("CatchPlayer", new List<BehaviourTreeNode>
|
||||||
|
{
|
||||||
|
new LeafChase("Chasing"),
|
||||||
|
new LeafAttack("Attacking")
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
new LeafPatrol("Patrol")
|
||||||
|
});
|
||||||
|
//Debug.Log("Tree Created");
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: Homeowner1
|
||||||
|
ID: 159563628
|
||||||
|
Type: 9
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file Homeowner1Events.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief The implemented events for the homeowner
|
||||||
|
* Presently unused for GAM300
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
public partial class Homeowner1Events : BehaviourTreeEvents
|
||||||
|
{
|
||||||
|
public Homeowner1Events(BehaviourTree tree) : base(tree) { }
|
||||||
|
|
||||||
|
//Called at the start
|
||||||
|
public override void Initialise()
|
||||||
|
{
|
||||||
|
//Tree.GetNode("Search FOV").onExitEvent += (s, e) => { PlayScreamSFX(s, e); };
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called at every tick
|
||||||
|
public override void Tick()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: Homeowner1Events
|
||||||
|
ID: 156914017
|
||||||
|
Type: 9
|
|
@ -0,0 +1,109 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file LeafAttack.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief Leaf node implementation for AI attacking the player
|
||||||
|
* when the AI is close enough after chasing
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
using SHADE;
|
||||||
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//VARIABLES
|
||||||
|
public partial class LeafAttack : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
//Holds the player game object that is to be targeted
|
||||||
|
private GameObject player;
|
||||||
|
}
|
||||||
|
|
||||||
|
//FUNCTIONS
|
||||||
|
public partial class LeafAttack : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
public LeafAttack(string name) : base (name)
|
||||||
|
{
|
||||||
|
//Debug.Log("LeafAttack ctor");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Helper, find the nearest unobstructed waypoint to return to when chase is over
|
||||||
|
public void reevaluateWaypoint()
|
||||||
|
{
|
||||||
|
List<GameObject> waypoints = (List<GameObject>)GetNodeData("waypoints");
|
||||||
|
Transform transform = (Transform)GetNodeData("transform");
|
||||||
|
|
||||||
|
if (waypoints == null || transform == null)
|
||||||
|
{
|
||||||
|
SetNodeData("currentWaypointIndex", 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nearestWaypointIndex = 0;
|
||||||
|
for (int i = 0; i < waypoints.Count; ++i)
|
||||||
|
{
|
||||||
|
if ((transform.GlobalPosition - waypoints[i].GetComponent<Transform>().GlobalPosition).GetSqrMagnitude() <
|
||||||
|
(transform.GlobalPosition - waypoints[nearestWaypointIndex].GetComponent<Transform>().GlobalPosition).GetSqrMagnitude())
|
||||||
|
{
|
||||||
|
nearestWaypointIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetNodeData("currentWaypointIndex", nearestWaypointIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override BehaviourTreeNodeStatus Evaluate()
|
||||||
|
{
|
||||||
|
//Debug.LogWarning("LeafAttack");
|
||||||
|
//Fail if no target in blackboard?
|
||||||
|
|
||||||
|
onEnter(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
|
||||||
|
//Get Data
|
||||||
|
float? captureTime;
|
||||||
|
if (GetNodeData("captureTimeLeft") == null)
|
||||||
|
{
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
captureTime = (float)GetNodeData("captureTimeLeft");
|
||||||
|
|
||||||
|
if (GameObject.Find("Player") == null)
|
||||||
|
{
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player = GameObject.Find("Player").GetValueOrDefault();
|
||||||
|
|
||||||
|
//Succeed when stand in hurt box for long enough
|
||||||
|
//Debug.Log("Attempting to get blackboard data");
|
||||||
|
//Debug.Log("Got blackboard data");
|
||||||
|
captureTime -= Time.DeltaTimeF;
|
||||||
|
SetNodeData("captureTimeLeft", captureTime);
|
||||||
|
//Debug.Log(captureTime.ToString());
|
||||||
|
if (captureTime <= 0.0f)
|
||||||
|
{
|
||||||
|
//Catch player when in range for long enough
|
||||||
|
//Debug.Log("Success: Caught");
|
||||||
|
player.GetScript<PlayerController>().currentState = PlayerController.RaccoonStates.CAUGHT;
|
||||||
|
status = BehaviourTreeNodeStatus.SUCCESS;
|
||||||
|
onExit(BehaviourTreeNodeStatus.SUCCESS);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return running if not success
|
||||||
|
//Debug.Log("Running: About to capture in " + captureTimeLeft);
|
||||||
|
status = BehaviourTreeNodeStatus.RUNNING;
|
||||||
|
onExit(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: LeafAttack
|
||||||
|
ID: 162827155
|
||||||
|
Type: 9
|
|
@ -0,0 +1,194 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file LeafChase.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief Leaf node implementation for AI chasing the player
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
using SHADE;
|
||||||
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//VARIABLES
|
||||||
|
public partial class LeafChase : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
//Used to move entity around
|
||||||
|
private Transform transform;
|
||||||
|
private RigidBody rb;
|
||||||
|
private float chaseSpeed;
|
||||||
|
private float turningSpeed;
|
||||||
|
private float captureDistance;
|
||||||
|
private float baseCaptureTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
//FUNCTIONS
|
||||||
|
public partial class LeafChase : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
//Despite inheriting from BehaviourTreeNode, we don't have children to this node,
|
||||||
|
//and hence we don't need to inherit its constructors
|
||||||
|
public LeafChase(string name) : base (name)
|
||||||
|
{
|
||||||
|
//Debug.Log("LeafChase ctor");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Helper, find which waypoint player is closest to
|
||||||
|
private void determinePlayerWaypoint()
|
||||||
|
{
|
||||||
|
List<GameObject> waypoints = (List<GameObject>)GetNodeData("waypoints");
|
||||||
|
Transform target = (Transform)GetNodeData("target");
|
||||||
|
if (waypoints == null || target == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nearestWaypointIndex = 0;
|
||||||
|
for (int i = 0; i < waypoints.Count; ++i)
|
||||||
|
{
|
||||||
|
if ((target.GlobalPosition - waypoints[i].GetComponent<Transform>().GlobalPosition).GetSqrMagnitude() <
|
||||||
|
(target.GlobalPosition - waypoints[nearestWaypointIndex].GetComponent<Transform>().GlobalPosition).GetSqrMagnitude())
|
||||||
|
{
|
||||||
|
nearestWaypointIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Debug.Log("Player is nearest " + nearestWaypointIndex);
|
||||||
|
//Debug.Log("I'm at " + (int)GetNodeData("currentWaypointIndex"));
|
||||||
|
SetNodeData("playerLastSightedWaypointIndex", nearestWaypointIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override BehaviourTreeNodeStatus Evaluate()
|
||||||
|
{
|
||||||
|
//Debug.LogWarning("LeafChase");
|
||||||
|
|
||||||
|
onEnter(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
|
||||||
|
//Get Data
|
||||||
|
if (GetNodeData("transform") == null ||
|
||||||
|
GetNodeData("rigidBody") == null ||
|
||||||
|
GetNodeData("turningSpeed") == null ||
|
||||||
|
GetNodeData("chaseSpeed") == null ||
|
||||||
|
GetNodeData("distanceToCapture") == null ||
|
||||||
|
GetNodeData("baseCaptureTime") == null)
|
||||||
|
{
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transform = (Transform)GetNodeData("transform");
|
||||||
|
rb = (RigidBody)GetNodeData("rigidBody");
|
||||||
|
chaseSpeed = (float)GetNodeData("chaseSpeed");
|
||||||
|
turningSpeed = (float)GetNodeData("turningSpeed");
|
||||||
|
captureDistance = (float)GetNodeData("distanceToCapture");
|
||||||
|
baseCaptureTime = (float)GetNodeData("baseCaptureTime");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Fail if no target in blackboard
|
||||||
|
if (GetNodeData("target") == null)
|
||||||
|
{
|
||||||
|
//Debug.Log("Failure: No target in blackboard");
|
||||||
|
return BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
}
|
||||||
|
Transform target = (Transform)GetNodeData("target");
|
||||||
|
|
||||||
|
Vector3 normalisedDifference = target.GlobalPosition - transform.GlobalPosition;
|
||||||
|
normalisedDifference.y = 0.0f; //Do not consider Y
|
||||||
|
normalisedDifference /= normalisedDifference.GetMagnitude();
|
||||||
|
|
||||||
|
//Over maximum distance, stop chase
|
||||||
|
if ((transform.GlobalPosition - target.GlobalPosition).GetMagnitude() > 1000.0f)
|
||||||
|
{
|
||||||
|
//Debug.Log("Failure: Over maximum distance");
|
||||||
|
ClearNodeData("target");
|
||||||
|
|
||||||
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
|
||||||
|
}
|
||||||
|
SetNodeData("isAlert", false);
|
||||||
|
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
else if (false) //TODO If collided against a wall
|
||||||
|
{
|
||||||
|
//Debug.Log("Running: Collided against wall");
|
||||||
|
SetNodeData("isPathfinding", true);
|
||||||
|
|
||||||
|
status = BehaviourTreeNodeStatus.RUNNING;
|
||||||
|
onExit(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
return BehaviourTreeNodeStatus.RUNNING;
|
||||||
|
}
|
||||||
|
//Keep chasing
|
||||||
|
else if ((transform.GlobalPosition - target.GlobalPosition).GetMagnitude() > captureDistance)
|
||||||
|
{
|
||||||
|
//Debug.Log("Running: Chasing");
|
||||||
|
Quaternion targetRotation = Quaternion.LookRotation(normalisedDifference, new Vector3(0.0f, 1.0f, 0.0f));
|
||||||
|
transform.LocalRotation = Quaternion.Slerp(transform.LocalRotation, targetRotation, turningSpeed * Time.DeltaTimeF);
|
||||||
|
|
||||||
|
|
||||||
|
//Determine the player's nearest waypoint as long as the AI can see the player
|
||||||
|
//Head towards that waypoint in an attempt to chase the player
|
||||||
|
determinePlayerWaypoint();
|
||||||
|
|
||||||
|
//TODO delete this when original intendd code above works with velocity being limited correctly
|
||||||
|
//Only chase the player directly if the player's waypoint matches the AI's own
|
||||||
|
if (GetNodeData("currentWaypointIndex") != null && GetNodeData("playerLastSightedWaypointIndex") != null)
|
||||||
|
{
|
||||||
|
if ((int)GetNodeData("currentWaypointIndex") == (int)GetNodeData("playerLastSightedWaypointIndex"))
|
||||||
|
{
|
||||||
|
//Debug.Log("Waypoint indicees matching. Chasing directly");
|
||||||
|
rb.LinearVelocity = normalisedDifference * chaseSpeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reset capture timing to base
|
||||||
|
SetNodeData("captureTimeLeft", baseCaptureTime);
|
||||||
|
|
||||||
|
//Not capturing, don't play SFX
|
||||||
|
SetNodeData("isCapturing", false);
|
||||||
|
|
||||||
|
status = BehaviourTreeNodeStatus.RUNNING;
|
||||||
|
onExit(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
return BehaviourTreeNodeStatus.RUNNING;
|
||||||
|
}
|
||||||
|
//Once player is close enough, perform attack
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Debug.Log("Success: Near enough. Begin attack");
|
||||||
|
//Look at the correct direction
|
||||||
|
Quaternion targetRotation = Quaternion.LookRotation(normalisedDifference, new Vector3(0.0f, 1.0f, 0.0f));
|
||||||
|
transform.LocalRotation = Quaternion.Slerp(transform.LocalRotation, targetRotation, turningSpeed * Time.DeltaTimeF);
|
||||||
|
|
||||||
|
//Play SFX
|
||||||
|
if (GetNodeData("isCapturing") != null && (bool)GetNodeData("isCapturing") == false)
|
||||||
|
{
|
||||||
|
//Debug.Log("AI Play capturing SFX");
|
||||||
|
}
|
||||||
|
SetNodeData("isCapturing", true);
|
||||||
|
|
||||||
|
//TODO resetting the capture time once it's less than 0 doesn't work as
|
||||||
|
//there is quite some time (about .1 seconds) after the timer falls below 0
|
||||||
|
//that the capture actually happens
|
||||||
|
|
||||||
|
status = BehaviourTreeNodeStatus.SUCCESS;
|
||||||
|
onExit(BehaviourTreeNodeStatus.SUCCESS);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: LeafChase
|
||||||
|
ID: 151301333
|
||||||
|
Type: 9
|
|
@ -0,0 +1,268 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file LeafPatrol.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief Leaf node implementation for patrolling AI
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
using SHADE;
|
||||||
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//VARIABLES HERE
|
||||||
|
public partial class LeafPatrol : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
//Waypoints and movement
|
||||||
|
private Transform transform;
|
||||||
|
private List<GameObject>? waypoints;
|
||||||
|
private RigidBody rb;
|
||||||
|
private float patrolSpeed;
|
||||||
|
private float chaseSpeed;
|
||||||
|
private float turningSpeed;
|
||||||
|
private float retreatTimer = 0.0f;
|
||||||
|
private int currentWaypointIndex = 0;
|
||||||
|
private bool retreatState = false;
|
||||||
|
private bool goingForwards = true;
|
||||||
|
|
||||||
|
//Small delays between waypoints
|
||||||
|
private bool isWaiting = false;
|
||||||
|
private const float waitDuration = 2.0f;
|
||||||
|
private float waitCounter = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
//FUNCTIONS HERE
|
||||||
|
public partial class LeafPatrol : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
//Constructor, establish values here
|
||||||
|
//Despite inheriting from BehaviourTreeNode, we don't have children to this
|
||||||
|
//node, and hence we do not need to inherit its constructors
|
||||||
|
public LeafPatrol(string name) : base(name)
|
||||||
|
{
|
||||||
|
currentWaypointIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//When it comes to evaluating,
|
||||||
|
//le this node keep returning RUNNING as it is the last fallback node on tree
|
||||||
|
public override BehaviourTreeNodeStatus Evaluate()
|
||||||
|
{
|
||||||
|
//Debug.LogWarning("LeafPatrol");
|
||||||
|
onEnter(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
|
||||||
|
//Get data
|
||||||
|
if (GetNodeData("transform") == null ||
|
||||||
|
GetNodeData("patrolSpeed") == null ||
|
||||||
|
GetNodeData("chaseSpeed") == null ||
|
||||||
|
GetNodeData("turningSpeed") == null ||
|
||||||
|
GetNodeData("rigidBody") == null)
|
||||||
|
{
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transform = (Transform)GetNodeData("transform");
|
||||||
|
patrolSpeed = (float)GetNodeData("patrolSpeed");
|
||||||
|
chaseSpeed = (float)GetNodeData("chaseSpeed");
|
||||||
|
turningSpeed = (float)GetNodeData("turningSpeed");
|
||||||
|
rb = (RigidBody)GetNodeData("rigidBody");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetNodeData("currentWaypointIndex") == null)
|
||||||
|
{
|
||||||
|
SetNodeData("currentWaypointIndex", 0);
|
||||||
|
}
|
||||||
|
if (isWaiting) DelayAtWaypoint();
|
||||||
|
else MoveToWaypoint();
|
||||||
|
|
||||||
|
status = BehaviourTreeNodeStatus.RUNNING;
|
||||||
|
onExit(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Move and cycle between waypoints
|
||||||
|
private void MoveToWaypoint()
|
||||||
|
{
|
||||||
|
//Debug.Log("MoveToWaypoint");
|
||||||
|
//Waiting, do not move
|
||||||
|
if (GetNodeData("isWaiting") != null)
|
||||||
|
{
|
||||||
|
//Only wait to change waypoints if not alert
|
||||||
|
if (GetNodeData("isAlert") != null && !(bool)GetNodeData("isAlert"))
|
||||||
|
waitCounter = 0.0f;
|
||||||
|
|
||||||
|
isWaiting = true;
|
||||||
|
ClearNodeData("isWaiting");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
waypoints = (List<GameObject>)GetNodeData("waypoints");
|
||||||
|
if (waypoints == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Vector3 targetPosition = waypoints[currentWaypointIndex].GetComponent<Transform>().GlobalPosition;
|
||||||
|
//Reach waypoint by X and Z being near enough
|
||||||
|
//Do not consider Y of waypoints yet
|
||||||
|
Vector3 remainingDistance = targetPosition - transform.GlobalPosition;
|
||||||
|
remainingDistance.y = 0.0f;
|
||||||
|
//Reached waypoint, cycle
|
||||||
|
if (remainingDistance.GetSqrMagnitude() < 0.1f)
|
||||||
|
{
|
||||||
|
//If alert, may reverse
|
||||||
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert"))
|
||||||
|
{
|
||||||
|
//If alert, may reverse if it's closer to the player
|
||||||
|
if (GetNodeData("playerLastSightedWaypointIndex") != null)
|
||||||
|
{
|
||||||
|
int playerWaypoint = (int)GetNodeData("playerLastSightedWaypointIndex");
|
||||||
|
int forwardDistance = 0;
|
||||||
|
int backDistance = 0;
|
||||||
|
if (playerWaypoint < currentWaypointIndex)
|
||||||
|
{
|
||||||
|
//Player waypoint is behind current waypoint
|
||||||
|
forwardDistance = playerWaypoint + waypoints.Count() - currentWaypointIndex;
|
||||||
|
backDistance = currentWaypointIndex - playerWaypoint;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Player waypoint is ahead of current waypoint (or same)
|
||||||
|
forwardDistance = playerWaypoint - currentWaypointIndex;
|
||||||
|
backDistance = currentWaypointIndex + waypoints.Count() - playerWaypoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backDistance < forwardDistance)
|
||||||
|
{
|
||||||
|
//Go backwards
|
||||||
|
goingForwards = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Go forward
|
||||||
|
goingForwards = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Fallback if no player waypoint data, go forward
|
||||||
|
goingForwards = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Cycle waypoints
|
||||||
|
if (goingForwards)
|
||||||
|
{
|
||||||
|
++currentWaypointIndex;
|
||||||
|
if (currentWaypointIndex >= waypoints.Count())
|
||||||
|
currentWaypointIndex = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
--currentWaypointIndex;
|
||||||
|
if (currentWaypointIndex < 0)
|
||||||
|
currentWaypointIndex = waypoints.Count() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Write to blackboard
|
||||||
|
SetNodeData("currentWaypointIndex", currentWaypointIndex);
|
||||||
|
|
||||||
|
//Only wait to change waypoints if not alert
|
||||||
|
if (GetNodeData("isAlert") != null && !(bool)GetNodeData("isAlert"))
|
||||||
|
waitCounter = 0.0f;
|
||||||
|
|
||||||
|
isWaiting = true;
|
||||||
|
}
|
||||||
|
else if (false /*Physics.OverlapSphere(_selfTransform.position, 0.3f, 1 << 8).Length > 0 && retreatState == false*/)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
//This main segment is to check if the NPC is walking into a solid wall
|
||||||
|
//If they are, do a raycast to find the nearest unobstructed waypoint and head there instead
|
||||||
|
}
|
||||||
|
else //Proceed to waypoint as usual
|
||||||
|
{
|
||||||
|
//Get the difference vector to the waypoint
|
||||||
|
//Debug.Log("Current Waypoint " + waypoints[currentWaypointIndex].x.ToString() + " " + waypoints[currentWaypointIndex].y.ToString() + " " + waypoints[currentWaypointIndex].z.ToString());
|
||||||
|
//Debug.Log("AI is at " + transform.GlobalPosition.x.ToString() + " " + transform.GlobalPosition.y.ToString() + " " + transform.GlobalPosition.z.ToString());
|
||||||
|
Vector3 normalisedDifference = targetPosition - transform.GlobalPosition;
|
||||||
|
normalisedDifference.y = 0.0f; //Do not move vertically
|
||||||
|
normalisedDifference /= normalisedDifference.GetMagnitude();
|
||||||
|
//Debug.Log("Normalised Difference x " + normalisedDifference.x.ToString() + " z " + normalisedDifference.z.ToString());
|
||||||
|
|
||||||
|
//Look at the correct direction
|
||||||
|
Quaternion targetRotation = Quaternion.LookRotation(normalisedDifference, new Vector3(0.0f, 1.0f, 0.0f));
|
||||||
|
transform.LocalRotation = Quaternion.Slerp(transform.LocalRotation, targetRotation, turningSpeed * Time.DeltaTimeF);
|
||||||
|
|
||||||
|
//transform.GlobalPosition += normalisedDifference * moveSpeed * (float)Time.DeltaTime;
|
||||||
|
//rb.LinearVelocity = normalisedDifference * patrolSpeed;
|
||||||
|
|
||||||
|
//ORIGINAL INTENDED CODE
|
||||||
|
/*rb.AddForce(new Vector3(normalisedDifference.x, 0.0f, normalisedDifference.z) * movementForceMultiplier);
|
||||||
|
float currentSpeed = MathF.Sqrt(rb.LinearVelocity.x * rb.LinearVelocity.x + rb.LinearVelocity.z * rb.LinearVelocity.z);
|
||||||
|
if (currentSpeed > patrolSpeed)
|
||||||
|
{
|
||||||
|
float adjustmentFactor = patrolSpeed / currentSpeed;
|
||||||
|
Vector3 adjustedVelocity = rb.LinearVelocity;
|
||||||
|
//adjustedVelocity *= adjustmentFactor;
|
||||||
|
adjustedVelocity.x = patrolSpeed;
|
||||||
|
adjustedVelocity.z = patrolSpeed;
|
||||||
|
rb.LinearVelocity = adjustedVelocity;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//TODO delete this when original intended code above works with velocity being limited correctly
|
||||||
|
if (rb != null)
|
||||||
|
{
|
||||||
|
//Move quickly if alert
|
||||||
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert"))
|
||||||
|
{
|
||||||
|
//Debug.Log("Fast Patrol");
|
||||||
|
rb.LinearVelocity = normalisedDifference * chaseSpeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rb.LinearVelocity = normalisedDifference * patrolSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Unalert if AI reaches player nearest
|
||||||
|
if (GetNodeData("currentWaypointIndex") != null && GetNodeData("playerLastSightedWaypointIndex") != null)
|
||||||
|
{
|
||||||
|
if ((int)GetNodeData("currentWaypointIndex") == (int)GetNodeData("playerLastSightedWaypointIndex"))
|
||||||
|
{
|
||||||
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert"))
|
||||||
|
{
|
||||||
|
//Debug.Log("Unalert");
|
||||||
|
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
|
||||||
|
}
|
||||||
|
SetNodeData("isAlert", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (retreatState)
|
||||||
|
{
|
||||||
|
if (retreatTimer < 1.0f) retreatTimer += Time.DeltaTimeF;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retreatState = false;
|
||||||
|
retreatTimer = 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DelayAtWaypoint()
|
||||||
|
{
|
||||||
|
waitCounter += Time.DeltaTimeF;
|
||||||
|
if (waitCounter >= waitDuration)
|
||||||
|
isWaiting = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: LeafPatrol
|
||||||
|
ID: 160826340
|
||||||
|
Type: 9
|
|
@ -0,0 +1,210 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* \file LeafSearch.cs
|
||||||
|
* \author Ryan Wang Nian Jing
|
||||||
|
* \brief Leaf node implementation for AI searching for player
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \copyright Copyright (c) 2022 DigiPen Institute of Technology. Reproduction
|
||||||
|
or disclosure of this file or its contents without the prior written
|
||||||
|
consent of DigiPen Institute of Technology is prohibited.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
using SHADE;
|
||||||
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//VARIABLES HERE
|
||||||
|
public partial class LeafSearch : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
private Transform transform;
|
||||||
|
private Vector3 eyeOffset;
|
||||||
|
private float sightDistance;
|
||||||
|
private GameObject? player; //To be searched for and marked
|
||||||
|
}
|
||||||
|
|
||||||
|
//FUNCTIONS HERE
|
||||||
|
public partial class LeafSearch : BehaviourTreeNode
|
||||||
|
{
|
||||||
|
public LeafSearch(string name) : base(name)
|
||||||
|
{
|
||||||
|
//Debug.Log("LeafSearch ctor");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Helper, find the nearest unobstructed waypoint to return to when chase is over
|
||||||
|
public void reevaluateWaypoint()
|
||||||
|
{
|
||||||
|
List<GameObject> waypoints = (List<GameObject>)GetNodeData("waypoints");
|
||||||
|
|
||||||
|
if (waypoints == null)
|
||||||
|
{
|
||||||
|
SetNodeData("currentWaypointIndex", 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nearestWaypointIndex = 0;
|
||||||
|
for (int i = 0; i < waypoints.Count; ++i)
|
||||||
|
{
|
||||||
|
if ((transform.GlobalPosition - waypoints[i].GetComponent<Transform>().GlobalPosition).GetSqrMagnitude() <
|
||||||
|
(transform.GlobalPosition - waypoints[nearestWaypointIndex].GetComponent<Transform>().GlobalPosition).GetSqrMagnitude())
|
||||||
|
{
|
||||||
|
nearestWaypointIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetNodeData("currentWaypointIndex", nearestWaypointIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Helper for handling being alert
|
||||||
|
|
||||||
|
//Helper for handling stopping of chases
|
||||||
|
private void handleChaseStop()
|
||||||
|
{
|
||||||
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
|
||||||
|
reevaluateWaypoint();
|
||||||
|
}
|
||||||
|
SetNodeData("isAlert", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override BehaviourTreeNodeStatus Evaluate()
|
||||||
|
{
|
||||||
|
//Debug.LogWarning("LeafSearch");
|
||||||
|
onEnter(BehaviourTreeNodeStatus.RUNNING);
|
||||||
|
|
||||||
|
//Get data
|
||||||
|
if (GetNodeData("transform") == null ||
|
||||||
|
GetNodeData("eyeOffset") == null ||
|
||||||
|
GetNodeData("sightDistance") == null)
|
||||||
|
{
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transform = (Transform)GetNodeData("transform");
|
||||||
|
eyeOffset = (Vector3)GetNodeData("eyeOffset");
|
||||||
|
sightDistance = (float)GetNodeData("sightDistance");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Search for player
|
||||||
|
player = GameObject.Find("Player");
|
||||||
|
|
||||||
|
//Automatically fail if no player is found
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
SetNodeData("isAlert", false);
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Fail if unable to find a player
|
||||||
|
//Get player's transform
|
||||||
|
Transform plrT = player.GetValueOrDefault().GetComponent<Transform>();
|
||||||
|
|
||||||
|
//DELETE THIS
|
||||||
|
//Debug.Log("X " + MathF.Sin(transform.LocalEulerAngles.y).ToString() + " Z " + MathF.Cos(transform.LocalEulerAngles.y).ToString());
|
||||||
|
//Debug.Log("Looking at: " + transform.LocalRotation.y.ToString() + " To player is: " + temporary.ToString());
|
||||||
|
//Debug.Log("Look difference is: " + (transform.LocalRotation.y - differenceDirection.y).ToString());
|
||||||
|
//Debug.Log("Dot: " + Quaternion.Dot(differenceDirection, transform.GlobalRotation));
|
||||||
|
|
||||||
|
//Fail if too far from vision range
|
||||||
|
if ((plrT.GlobalPosition - transform.GlobalPosition).GetMagnitude() > sightDistance)
|
||||||
|
{
|
||||||
|
//Debug.Log("Failure: Too far");
|
||||||
|
//handleChaseStop();
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Fail if player is out of FOV
|
||||||
|
//TODO currently a simple dot product against negative is done, this makes it essentially be a semicircle in front at which AI can see
|
||||||
|
Vector3 difference = plrT.GlobalPosition - transform.GlobalPosition;
|
||||||
|
difference.y = 0.0f; //Disregard Y axis
|
||||||
|
Vector3 lookDirection = new Vector3(MathF.Sin(transform.LocalEulerAngles.y), 0.0f, MathF.Cos(transform.LocalEulerAngles.y));
|
||||||
|
//Debug.Log("Dot: " + Vector3.Dot(difference, lookDirection));
|
||||||
|
if (Vector3.Dot(difference, lookDirection) < 0.0f)
|
||||||
|
{
|
||||||
|
//Debug.Log("Failure: Out of FOV");
|
||||||
|
//handleChaseStop();
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//LocalRotation is between -1 and 1, which are essentially the same.
|
||||||
|
//0 and -1/1 are 180 deg apart
|
||||||
|
//Quaternion differenceDirection = Quaternion.FromToRotation(Vector3.Forward, plrT.GlobalPosition - transform.GlobalPosition);
|
||||||
|
//Debug.Log("Looking at: " + transform.LocalRotation.y.ToString() + " To player is: " + differenceDirection.y.ToString());
|
||||||
|
|
||||||
|
//Draw a ray, succeed if ray is unobstructed
|
||||||
|
Vector3 eyePosition = transform.GlobalPosition + eyeOffset;
|
||||||
|
BoxCollider playerCollider = player.GetValueOrDefault().GetComponent<Collider>().GetCollisionShape<BoxCollider>(0);
|
||||||
|
if (playerCollider == null)
|
||||||
|
{
|
||||||
|
//Debug.Log("Failure: Player has no collider");
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
//Ray destination to target the centre of the player's collider instead of transform position
|
||||||
|
//Since transform position is often the raccoon's base and the ray needs to hit somewhere higher to be more reliable
|
||||||
|
Vector3 rayDestination = plrT.GlobalPosition + plrT.GlobalScale * playerCollider.PositionOffset;
|
||||||
|
Ray sightRay = new Ray(eyePosition, rayDestination - eyePosition);
|
||||||
|
RaycastHit sightRayHit = Physics.Raycast(sightRay);
|
||||||
|
//As of November 2022, RaycastHit contains only the FIRST object hit by
|
||||||
|
//the ray in the Other GameObject data member
|
||||||
|
//Diren may likely add ALL objects hit by the ray over December
|
||||||
|
if (sightRayHit.Hit && sightRayHit.Other != player)
|
||||||
|
{
|
||||||
|
//TODO sometimes the ray doesn't hit the player even if he's in plain sight because the ray hits the floor the player is on instead???
|
||||||
|
//Debug.Log("Failure: Ray hit obstacle named " + sightRayHit.Other.GetValueOrDefault().Name + " ID" + sightRayHit.Other.GetValueOrDefault().EntityId);
|
||||||
|
//handleChaseStop();
|
||||||
|
status = BehaviourTreeNodeStatus.FAILURE;
|
||||||
|
onExit(BehaviourTreeNodeStatus.FAILURE);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
else if (sightRayHit.Hit && sightRayHit.Other == player)
|
||||||
|
{
|
||||||
|
//Debug.Log("Ray hit player");
|
||||||
|
}
|
||||||
|
|
||||||
|
//All checks for now succeeded
|
||||||
|
//Debug.Log("Success: Homeowner has sighted player");
|
||||||
|
//Write player's transform into the blackboard
|
||||||
|
SetNodeData("target", plrT);
|
||||||
|
|
||||||
|
if (GetNodeData("isAlert") == null)
|
||||||
|
{
|
||||||
|
SetNodeData("isAlert", true);
|
||||||
|
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_detect_raccoon");
|
||||||
|
Audio.PlaySFXOnce2D("event:/Music/stingers/player_detected");
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
Audio.PlayBGMOnce2D("event:/Music/player_detected");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == false)
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_detect_raccoon");
|
||||||
|
Audio.PlaySFXOnce2D("event:/Music/stingers/player_detected");
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
Audio.PlayBGMOnce2D("event:/Music/player_detected");
|
||||||
|
}
|
||||||
|
SetNodeData("isAlert", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
status = BehaviourTreeNodeStatus.SUCCESS;
|
||||||
|
onExit(BehaviourTreeNodeStatus.SUCCESS);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: LeafSearch
|
||||||
|
ID: 166109634
|
||||||
|
Type: 9
|
|
@ -0,0 +1,65 @@
|
||||||
|
using SHADE;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
public class Breakable : Script
|
||||||
|
{
|
||||||
|
public float threshHold = 1.0f;
|
||||||
|
public float force = 2.0f;
|
||||||
|
private RigidBody rb;
|
||||||
|
private Transform trans;
|
||||||
|
private bool isBreak = false;
|
||||||
|
private List<GameObject> itemPieces = new List<GameObject>();
|
||||||
|
private Random ran = new Random();
|
||||||
|
protected override void awake()
|
||||||
|
{
|
||||||
|
rb = GetComponent<RigidBody>();
|
||||||
|
if (!rb)
|
||||||
|
Debug.LogError("RIGIDBODY EMPTY");
|
||||||
|
|
||||||
|
trans = GetComponent<Transform>();
|
||||||
|
if(!trans)
|
||||||
|
Debug.LogError("TRANSFORM EMPTY");
|
||||||
|
|
||||||
|
foreach (GameObject pieces in GameObject)
|
||||||
|
{
|
||||||
|
itemPieces.Add(pieces);
|
||||||
|
pieces.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void update()
|
||||||
|
{
|
||||||
|
if (isBreak)
|
||||||
|
Break();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onCollisionEnter(CollisionInfo info)
|
||||||
|
{
|
||||||
|
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold)
|
||||||
|
{
|
||||||
|
isBreak = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected override void onTriggerEnter(CollisionInfo info)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Break()
|
||||||
|
{
|
||||||
|
foreach (GameObject item in itemPieces)
|
||||||
|
{
|
||||||
|
item.SetActive(true);
|
||||||
|
item.GetComponent<Transform>().GlobalPosition = trans.LocalPosition + item.GetComponent<Transform>().LocalPosition;
|
||||||
|
GameObject gO = item;
|
||||||
|
gO.Parent = GameObject.Null;
|
||||||
|
}
|
||||||
|
|
||||||
|
isBreak = false;
|
||||||
|
Audio.PlaySFXOnce2D("event:/Props/impact_break");
|
||||||
|
Owner.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: SC_Breakable
|
||||||
|
ID: 161935110
|
||||||
|
Type: 9
|
|
@ -13,23 +13,15 @@ public class Item : Script
|
||||||
|
|
||||||
public ItemCategory currCategory;
|
public ItemCategory currCategory;
|
||||||
private RigidBody rb;
|
private RigidBody rb;
|
||||||
private Collider collider;
|
|
||||||
private bool once = false;
|
private bool once = false;
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
collider = GetComponent<Collider>();
|
|
||||||
if (collider)
|
|
||||||
{
|
|
||||||
collider.GetCollisionShape(0).Density = 1;
|
|
||||||
}
|
|
||||||
rb = GetComponent<RigidBody>();
|
rb = GetComponent<RigidBody>();
|
||||||
if (rb)
|
}
|
||||||
{
|
|
||||||
rb.FreezeRotationX = false;
|
protected override void update()
|
||||||
rb.FreezeRotationY = false;
|
{
|
||||||
rb.FreezeRotationZ = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void onCollisionEnter(CollisionInfo info)
|
protected override void onCollisionEnter(CollisionInfo info)
|
||||||
|
@ -37,9 +29,9 @@ public class Item : Script
|
||||||
if (once)
|
if (once)
|
||||||
{
|
{
|
||||||
if(currCategory == ItemCategory.LIGHT)
|
if(currCategory == ItemCategory.LIGHT)
|
||||||
Audio.PlayBGMOnce2D("event:/Props/impact_elastic");
|
Audio.PlaySFXOnce2D("event:/Props/impact_elastic");
|
||||||
else if (currCategory == ItemCategory.MEDIUM || currCategory == ItemCategory.HEAVY)
|
else if (currCategory == ItemCategory.MEDIUM || currCategory == ItemCategory.HEAVY)
|
||||||
Audio.PlayBGMOnce2D("event:/Props/impact_hard");
|
Audio.PlaySFXOnce2D("event:/Props/impact_hard");
|
||||||
once = false;
|
once = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ public class PlayerRunState : BaseState
|
||||||
|
|
||||||
if (timer > delay)
|
if (timer > delay)
|
||||||
{
|
{
|
||||||
Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_footsteps");
|
Audio.PlaySFXOnce2D("event:/Raccoon/raccoon_footsteps");
|
||||||
timer = 0;
|
timer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ public class PlayerWalkState : BaseState
|
||||||
|
|
||||||
if (timer > delay)
|
if (timer > delay)
|
||||||
{
|
{
|
||||||
Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_footsteps");
|
Audio.PlaySFXOnce2D("event:/Raccoon/raccoon_footsteps");
|
||||||
timer = 0;
|
timer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,93 +2,111 @@
|
||||||
using SHADE_Scripting;
|
using SHADE_Scripting;
|
||||||
using System;
|
using System;
|
||||||
using static PlayerController;
|
using static PlayerController;
|
||||||
|
using static Item;
|
||||||
|
|
||||||
public class PickAndThrow : Script
|
public class PickAndThrow : Script
|
||||||
{
|
{
|
||||||
public Vector3 throwForce = new Vector3(100.0f, 200.0f, 100.0f);
|
public Vector3 throwForce = new Vector3(100.0f, 200.0f, 100.0f);
|
||||||
|
public Vector3 cameraArmOffSet = new Vector3(0.0f, 0.25f, 0.0f);
|
||||||
public GameObject item { get; set; }
|
public GameObject item { get; set; }
|
||||||
public float delayTimer = 1.0f;
|
public float delayTimer = 1.0f;
|
||||||
public float aimingLength = 1.5f;
|
public float aimingLength = 1.5f;
|
||||||
|
|
||||||
private float timer;
|
private float timer;
|
||||||
private PlayerController pc;
|
private PlayerController pc;
|
||||||
private Camera cam;
|
|
||||||
private Transform itemTransform;
|
private Transform itemTransform;
|
||||||
private RigidBody itemRidibody;
|
private RigidBody itemRidigBody;
|
||||||
|
private Collider itemCollider;
|
||||||
|
private Item itemScript;
|
||||||
private Transform raccoonHoldLocation;
|
private Transform raccoonHoldLocation;
|
||||||
private Transform playerTran;
|
|
||||||
private ThirdPersonCamera tpc;
|
private ThirdPersonCamera tpc;
|
||||||
private float lastXDir;
|
private float lastXDir;
|
||||||
private float lastZDir;
|
private float lastZDir;
|
||||||
private bool inRange = false;
|
private bool inRange = false;
|
||||||
|
public bool throwItem = false;
|
||||||
|
|
||||||
|
[Tooltip("Lenght of ray")]
|
||||||
|
public float rayDistance = 1;
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
playerTran = GetComponent<Transform>();
|
|
||||||
if (!playerTran)
|
|
||||||
Debug.Log("PLAYERTRANSFORM EMPTY"); ;
|
|
||||||
|
|
||||||
pc = GetScript<PlayerController>();
|
pc = GetScript<PlayerController>();
|
||||||
if(!pc)
|
if(!pc)
|
||||||
Debug.Log("PLAYER CONTROLLER EMPTY");
|
Debug.LogError("PLAYER CONTROLLER EMPTY");
|
||||||
|
|
||||||
raccoonHoldLocation = GetComponentInChildren<Transform>();
|
raccoonHoldLocation = GetComponentInChildren<Transform>();
|
||||||
if (!raccoonHoldLocation)
|
if (!raccoonHoldLocation)
|
||||||
Debug.Log("CHILD EMPTY");
|
Debug.LogError("CHILD EMPTY");
|
||||||
|
|
||||||
tpc = GetScriptInChildren<ThirdPersonCamera>();
|
tpc = GetScriptInChildren<ThirdPersonCamera>();
|
||||||
if(!tpc)
|
if(!tpc)
|
||||||
Debug.Log("TPC EMPTY");
|
Debug.LogError("TPC EMPTY");
|
||||||
|
|
||||||
timer = delayTimer;
|
timer = delayTimer;
|
||||||
}
|
}
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(timer <= delayTimer)
|
if(timer <= delayTimer)
|
||||||
timer += Time.DeltaTimeF;
|
timer += Time.DeltaTimeF;
|
||||||
|
|
||||||
CalculateDir();
|
CalculateDir();
|
||||||
|
CastRay();
|
||||||
|
|
||||||
if (pc && itemRidibody && itemTransform)
|
if (pc && itemRidigBody && itemTransform && itemCollider)
|
||||||
{
|
{
|
||||||
if (pc.holdItem)
|
if (pc.holdItem)
|
||||||
{
|
{
|
||||||
itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition;
|
itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition;
|
||||||
itemTransform.LocalRotation = playerTran.LocalRotation;
|
itemTransform.LocalRotation = pc.tranform.LocalRotation;
|
||||||
|
itemRidigBody.LinearVelocity = Vector3.Zero;
|
||||||
|
itemRidigBody.AngularVelocity = Vector3.Zero;
|
||||||
|
|
||||||
if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
|
if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
|
||||||
{
|
{
|
||||||
Debug.Log("AIMING");
|
|
||||||
pc.isAiming = true;
|
pc.isAiming = true;
|
||||||
pc.camArm.ArmLength = aimingLength;
|
pc.camArm.ArmLength = aimingLength;
|
||||||
|
pc.camArm.TargetOffset = cameraArmOffSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
|
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
|
||||||
{
|
{
|
||||||
Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_throw");
|
Audio.PlaySFXOnce2D("event:/Raccoon/raccoon_throw");
|
||||||
|
itemRidigBody.IsGravityEnabled = true;
|
||||||
|
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
||||||
pc.isAiming = false;
|
pc.isAiming = false;
|
||||||
if(tpc)
|
pc.camArm.TargetOffset = Vector3.Zero;
|
||||||
|
if (tpc)
|
||||||
pc.camArm.ArmLength = tpc.armLength;
|
pc.camArm.ArmLength = tpc.armLength;
|
||||||
pc.holdItem = false;
|
pc.holdItem = false;
|
||||||
inRange = false;
|
inRange = false;
|
||||||
itemRidibody.IsGravityEnabled = true;
|
throwItem = true;
|
||||||
itemRidibody.AddForce(new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir));
|
|
||||||
itemRidibody.LinearVelocity += pc.rb.LinearVelocity;
|
|
||||||
ResetItemObject();
|
|
||||||
timer = 0.0f;
|
timer = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton))
|
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && !pc.isAiming)
|
||||||
{
|
{
|
||||||
pc.holdItem = false;
|
pc.holdItem = false;
|
||||||
inRange = false;
|
inRange = false;
|
||||||
itemRidibody.IsGravityEnabled = true;
|
itemRidigBody.IsGravityEnabled = true;
|
||||||
|
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
||||||
ResetItemObject();
|
ResetItemObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming)
|
||||||
|
{
|
||||||
|
pc.isAiming = false;
|
||||||
|
pc.camArm.TargetOffset = Vector3.Zero;
|
||||||
|
if (tpc)
|
||||||
|
pc.camArm.ArmLength = tpc.armLength;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!pc.holdItem)
|
else if (!pc.holdItem)
|
||||||
itemRidibody.IsGravityEnabled = true;
|
{
|
||||||
|
itemRidigBody.IsGravityEnabled = true;
|
||||||
|
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timer > delayTimer && pc && !pc.holdItem && inRange && Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
|
if (timer > delayTimer && pc && !pc.holdItem && inRange && Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
|
||||||
|
@ -101,46 +119,75 @@ public class PickAndThrow : Script
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void fixedUpdate()
|
||||||
|
{
|
||||||
|
if (throwItem && itemRidigBody && pc)
|
||||||
|
{
|
||||||
|
if (itemScript)
|
||||||
|
{
|
||||||
|
Vector3 vec = new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir);
|
||||||
|
if (itemScript.currCategory == ItemCategory.LIGHT)
|
||||||
|
itemRidigBody.AddForce(vec * 0.2f);
|
||||||
|
if (itemScript.currCategory == ItemCategory.MEDIUM)
|
||||||
|
itemRidigBody.AddForce(vec * 0.75f);
|
||||||
|
if (itemScript.currCategory == ItemCategory.HEAVY)
|
||||||
|
itemRidigBody.AddForce(vec);
|
||||||
|
}
|
||||||
|
itemRidigBody.LinearVelocity += pc.rb.LinearVelocity;
|
||||||
|
throwItem = false;
|
||||||
|
ResetItemObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ResetItemObject()
|
private void ResetItemObject()
|
||||||
{
|
{
|
||||||
itemRidibody = null;
|
itemRidigBody = null;
|
||||||
itemTransform = null;
|
itemTransform = null;
|
||||||
|
itemCollider = null;
|
||||||
|
itemScript = null;
|
||||||
item = new GameObject();
|
item = new GameObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RetrieveItemComponets()
|
private void RetrieveItemComponets()
|
||||||
{
|
{
|
||||||
//get the transform of the given item
|
//get the transform of the given item
|
||||||
if (item.GetScript<Item>() && itemTransform == null && itemRidibody == null)
|
if (item.GetScript<Item>() && !itemTransform && !itemRidigBody)
|
||||||
{
|
{
|
||||||
itemRidibody = item.GetComponent<RigidBody>();
|
itemRidigBody = item.GetComponent<RigidBody>();
|
||||||
if (itemRidibody == null)
|
if (!itemRidigBody)
|
||||||
Debug.Log("Item rb EMPTY");
|
Debug.Log("Item rb EMPTY");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
itemRidibody.IsGravityEnabled = false;
|
itemRidigBody.IsGravityEnabled = false;
|
||||||
itemRidibody.LinearVelocity = Vector3.Zero;
|
|
||||||
itemRidibody.AngularVelocity = Vector3.Zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemTransform = item.GetComponent<Transform>();
|
itemTransform = item.GetComponent<Transform>();
|
||||||
if (itemTransform == null)
|
if (!itemTransform)
|
||||||
Debug.Log("Item transform EMPTY");
|
Debug.Log("Item transform EMPTY");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
itemTransform.LocalEulerAngles = Vector3.Zero;
|
itemTransform.LocalEulerAngles = Vector3.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
itemCollider = item.GetComponent<Collider>();
|
||||||
|
if (!itemCollider)
|
||||||
|
Debug.Log("Item collider EMPTY");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemCollider.GetCollisionShape(0).IsTrigger = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
itemScript = item.GetScript<Item>();
|
||||||
|
if(!itemScript)
|
||||||
|
Debug.Log("Item script EMPTY");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CalculateDir()
|
private void CalculateDir()
|
||||||
{
|
{
|
||||||
if (cam == null)
|
if (pc && pc.cam)
|
||||||
cam = GetComponentInChildren<Camera>();
|
|
||||||
else if (cam)
|
|
||||||
{
|
{
|
||||||
Vector3 camerAixs = cam.GetForward();
|
Vector3 camerAixs = pc.cam.GetForward();
|
||||||
camerAixs.y = 0;
|
camerAixs.y = 0;
|
||||||
camerAixs.Normalise();
|
camerAixs.Normalise();
|
||||||
lastXDir = camerAixs.x;
|
lastXDir = camerAixs.x;
|
||||||
|
@ -148,33 +195,36 @@ public class PickAndThrow : Script
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DelayCheck()
|
private void CastRay()
|
||||||
{
|
{
|
||||||
timer += Time.DeltaTimeF;
|
if (pc != null)
|
||||||
|
{
|
||||||
|
Vector3 dirNor = pc.tranform.Forward;
|
||||||
|
Vector3 playerRayPos = pc.tranform.GlobalPosition;
|
||||||
|
playerRayPos.y += 0.05f;
|
||||||
|
dirNor.Normalise();
|
||||||
|
RaycastHit ray1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance);
|
||||||
|
RaycastHit ray2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance);
|
||||||
|
RaycastHit ray3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f);
|
||||||
|
inRange = CheckForItem(ray1) || CheckForItem(ray2) || CheckForItem(ray3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void onCollisionEnter(CollisionInfo info)
|
private bool CheckForItem(RaycastHit ray)
|
||||||
{
|
{
|
||||||
}
|
if (ray.Hit)
|
||||||
protected override void onTriggerEnter(CollisionInfo info)
|
|
||||||
{
|
|
||||||
if (info.GameObject.GetScript<Item>() && !pc.holdItem)
|
|
||||||
{
|
{
|
||||||
item = info.GameObject;
|
if (ray.Other.Value.GetScript<Item>() && !pc.holdItem)
|
||||||
inRange = true;
|
{
|
||||||
}
|
item = ray.Other.Value;
|
||||||
}
|
return true;
|
||||||
protected override void onTriggerStay(CollisionInfo info)
|
}
|
||||||
{
|
else
|
||||||
//Debug.Log("STAY");
|
return false;
|
||||||
}
|
|
||||||
protected override void onTriggerExit(CollisionInfo info)
|
|
||||||
{
|
|
||||||
//Debug.Log("EXIT");
|
|
||||||
if (info.GameObject.GetScript<Item>() != null && !pc.holdItem)
|
|
||||||
{
|
|
||||||
inRange = false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,18 +17,18 @@ public class PlayerController : Script
|
||||||
TOTAL
|
TOTAL
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum WalkingState
|
/* public enum WalkingState
|
||||||
{
|
{
|
||||||
CARRY,
|
CARRY,
|
||||||
AIMING,
|
AIMING,
|
||||||
THROW,
|
THROW,
|
||||||
WALK,
|
WALK,
|
||||||
TOTAL
|
TOTAL
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public RigidBody rb { get; set; }
|
public RigidBody rb { get; set; }
|
||||||
private Transform tranform;
|
public Transform tranform { get; set; }
|
||||||
private Camera cam;
|
public Camera cam { get; set; }
|
||||||
public CameraArm camArm { get; set; }
|
public CameraArm camArm { get; set; }
|
||||||
private PickAndThrow pat;
|
private PickAndThrow pat;
|
||||||
private StateMachine stateMachine;
|
private StateMachine stateMachine;
|
||||||
|
@ -36,16 +36,20 @@ public class PlayerController : Script
|
||||||
public bool holdItem { get; set; }
|
public bool holdItem { get; set; }
|
||||||
public bool isAiming { get; set; }
|
public bool isAiming { get; set; }
|
||||||
|
|
||||||
|
[Tooltip("The game object for where the player will respawn to")]
|
||||||
|
public GameObject respawnPoint;
|
||||||
|
private float delayTimer = 0.0f;
|
||||||
|
|
||||||
[Tooltip("The current state fo the raccoon")]
|
[Tooltip("The current state fo the raccoon")]
|
||||||
public RaccoonStates currentState = RaccoonStates.IDLE;
|
public RaccoonStates currentState = RaccoonStates.IDLE;
|
||||||
|
|
||||||
//Movement variables============================================================
|
//Movement variables============================================================
|
||||||
[Tooltip("Max vel for walking")]
|
[Tooltip("Max vel for walking")]
|
||||||
public float maxMoveVel = 2.0f;
|
public float maxMoveVel = 3.0f;
|
||||||
[Tooltip("how much force is apply for walking")]
|
[Tooltip("how much force is apply for walking")]
|
||||||
public float moveForce = 2.0f;
|
public float moveForce = 50.0f;
|
||||||
[Tooltip("increase the moveForce and maxMoveVel by its amt")]
|
[Tooltip("increase the moveForce and maxMoveVel by its amt")]
|
||||||
public float sprintMultiplier = 2.0f;
|
public float sprintMultiplier = 1.5f;
|
||||||
|
|
||||||
private float oldForce;
|
private float oldForce;
|
||||||
private float maxOldVel;
|
private float maxOldVel;
|
||||||
|
@ -56,15 +60,15 @@ public class PlayerController : Script
|
||||||
public bool isMoveKeyPress { get; set; }
|
public bool isMoveKeyPress { get; set; }
|
||||||
|
|
||||||
[Tooltip("How fast player will turn")]
|
[Tooltip("How fast player will turn")]
|
||||||
public float rotationFactorPerFrame = 1.0f;
|
public float rotationFactorPerFrame = 5.0f;
|
||||||
|
|
||||||
//Jumping vars==================================================================
|
//Jumping vars==================================================================
|
||||||
[Tooltip("max height of the jump")]
|
[Tooltip("max height of the jump")]
|
||||||
public float maxJumpHeight = 4.0f;
|
public float maxJumpHeight = 1.0f;
|
||||||
[Tooltip("max amt of time it will take for the jump")]
|
[Tooltip("max amt of time it will take for the jump")]
|
||||||
public float maxJumpTime = 0.75f;
|
public float maxJumpTime = 0.5f;
|
||||||
[Tooltip("increase gravity when falling")]
|
[Tooltip("increase gravity when falling")]
|
||||||
public float fallMultipler = 2.0f;
|
public float fallMultipler = 3.0f;
|
||||||
private float initialJumpVel;
|
private float initialJumpVel;
|
||||||
private bool isGrounded = true;
|
private bool isGrounded = true;
|
||||||
private float gravity = -9.8f;
|
private float gravity = -9.8f;
|
||||||
|
@ -92,19 +96,14 @@ public class PlayerController : Script
|
||||||
|
|
||||||
//rigidbody check
|
//rigidbody check
|
||||||
rb = GetComponent<RigidBody>();
|
rb = GetComponent<RigidBody>();
|
||||||
if (rb == null)
|
if (!rb)
|
||||||
Debug.LogError("RigidBody is NULL!");
|
Debug.LogError("RigidBody is NULL!");
|
||||||
|
|
||||||
//Transform check
|
//Transform check
|
||||||
tranform = GetComponent<Transform>();
|
tranform = GetComponent<Transform>();
|
||||||
if(tranform == null)
|
if(!tranform)
|
||||||
Debug.LogError("tranform is NULL!");
|
Debug.LogError("tranform is NULL!");
|
||||||
|
|
||||||
//PickAndThrow check
|
|
||||||
pat = GetScript<PickAndThrow>();
|
|
||||||
if (pat == null)
|
|
||||||
Debug.LogError("PickAndThrow is NULL!");
|
|
||||||
|
|
||||||
stateMachine = AddScript<StateMachine>();
|
stateMachine = AddScript<StateMachine>();
|
||||||
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
|
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
|
||||||
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine));
|
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine));
|
||||||
|
@ -118,14 +117,41 @@ public class PlayerController : Script
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void lateUpdate()
|
||||||
|
{
|
||||||
|
}
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
|
if (delayTimer <= 1)
|
||||||
|
delayTimer += Time.DeltaTimeF;
|
||||||
|
|
||||||
|
if (delayTimer < 1)
|
||||||
|
{
|
||||||
|
if (tranform && respawnPoint && rb)
|
||||||
|
{
|
||||||
|
rb.LinearVelocity = Vector3.Zero;
|
||||||
|
tranform.LocalPosition = respawnPoint.GetComponent<Transform>().LocalPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rb.FreezePositionY = false;
|
||||||
|
}
|
||||||
|
//PickAndThrow check
|
||||||
|
if (!pat)
|
||||||
|
{
|
||||||
|
pat = GetScript<PickAndThrow>();
|
||||||
|
if(!pat)
|
||||||
|
Debug.LogError("PickAndThrow is NULL!");
|
||||||
|
}
|
||||||
|
|
||||||
if (!cam)
|
if (!cam)
|
||||||
cam = GetComponentInChildren<Camera>();
|
cam = GetComponentInChildren<Camera>();
|
||||||
if(!camArm)
|
if(!camArm)
|
||||||
camArm = GetComponentInChildren<CameraArm>();
|
camArm = GetComponentInChildren<CameraArm>();
|
||||||
|
|
||||||
Rotation();
|
Rotation();
|
||||||
|
Jump();
|
||||||
GotCaught();
|
GotCaught();
|
||||||
//Debug.Log($"{currentState}");
|
//Debug.Log($"{currentState}");
|
||||||
//Debug.Log($" axisX: {axisMove.x} axisY:{axisMove.y}");
|
//Debug.Log($" axisX: {axisMove.x} axisY:{axisMove.y}");
|
||||||
|
@ -135,10 +161,10 @@ public class PlayerController : Script
|
||||||
|
|
||||||
protected override void fixedUpdate()
|
protected override void fixedUpdate()
|
||||||
{
|
{
|
||||||
|
|
||||||
MoveKey();
|
MoveKey();
|
||||||
Move();
|
Move();
|
||||||
Sprint();
|
Sprint();
|
||||||
Jump();
|
|
||||||
Gravity();
|
Gravity();
|
||||||
//Debug.Log($"X: {rb.LinearVelocity.x}" + $" Z: {rb.LinearVelocity.z}");
|
//Debug.Log($"X: {rb.LinearVelocity.x}" + $" Z: {rb.LinearVelocity.z}");
|
||||||
}
|
}
|
||||||
|
@ -288,13 +314,13 @@ public class PlayerController : Script
|
||||||
{
|
{
|
||||||
Quaternion currentRotation = tranform.LocalRotation;
|
Quaternion currentRotation = tranform.LocalRotation;
|
||||||
Quaternion targetRotation = Quaternion.LookRotation(new Vector3(axisMove.x, 0.0f, axisMove.y), new Vector3(0.0f, 1.0f, 0.0f));
|
Quaternion targetRotation = Quaternion.LookRotation(new Vector3(axisMove.x, 0.0f, axisMove.y), new Vector3(0.0f, 1.0f, 0.0f));
|
||||||
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.DeltaTime);
|
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.FixedDeltaTime);
|
||||||
}
|
}
|
||||||
else if (camArm && tranform && isAiming)
|
else if (camArm && tranform && isAiming)
|
||||||
{
|
{
|
||||||
Quaternion currentRotation = tranform.LocalRotation;
|
Quaternion currentRotation = tranform.LocalRotation;
|
||||||
Quaternion targetRotation = Quaternion.Euler(0.0f, SHADE.Math.DegreesToRadians(camArm.Yaw + 180.0f), 0.0f);
|
Quaternion targetRotation = Quaternion.Euler(0.0f, SHADE.Math.DegreesToRadians(camArm.Yaw + 180.0f), 0.0f);
|
||||||
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.DeltaTime);
|
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.FixedDeltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,14 +345,14 @@ public class PlayerController : Script
|
||||||
else if (currentState == RaccoonStates.FALLING)
|
else if (currentState == RaccoonStates.FALLING)
|
||||||
{
|
{
|
||||||
float prevYVel = v.y;
|
float prevYVel = v.y;
|
||||||
float newYVel = v.y + (gravity * fallMultipler * (float)Time.DeltaTime);
|
float newYVel = v.y + (gravity * fallMultipler * (float)Time.FixedDeltaTime);
|
||||||
float nextYVel = (prevYVel + newYVel) * 0.5f;
|
float nextYVel = (prevYVel + newYVel) * 0.5f;
|
||||||
v.y = nextYVel;
|
v.y = nextYVel;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float prevYVel = v.y;
|
float prevYVel = v.y;
|
||||||
float newYVel = v.y + (gravity * (float)Time.DeltaTime);
|
float newYVel = v.y + (gravity * (float)Time.FixedDeltaTime);
|
||||||
float nextYVel = (prevYVel + newYVel) * 0.5f;
|
float nextYVel = (prevYVel + newYVel) * 0.5f;
|
||||||
v.y = nextYVel;
|
v.y = nextYVel;
|
||||||
}
|
}
|
||||||
|
@ -338,12 +364,12 @@ public class PlayerController : Script
|
||||||
|
|
||||||
private void GotCaught()
|
private void GotCaught()
|
||||||
{
|
{
|
||||||
if (currentState == RaccoonStates.CAUGHT && tranform != null)
|
if (currentState == RaccoonStates.CAUGHT && tranform && respawnPoint)
|
||||||
{
|
{
|
||||||
currentState = RaccoonStates.IDLE;
|
currentState = RaccoonStates.IDLE;
|
||||||
if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState)))
|
if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState)))
|
||||||
stateMachine.SetState(typeof(PlayerIdleState));
|
stateMachine.SetState(typeof(PlayerIdleState));
|
||||||
tranform.LocalPosition = new Vector3(-3.0f, -2.0f, -5.0f);
|
tranform.LocalPosition = respawnPoint.GetComponent<Transform>().LocalPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace SHADE_Scripting
|
||||||
public float turnSpeedPitch = 0.3f;
|
public float turnSpeedPitch = 0.3f;
|
||||||
public float turnSpeedYaw = 0.5f;
|
public float turnSpeedYaw = 0.5f;
|
||||||
public float pitchClamp = 45.0f;
|
public float pitchClamp = 45.0f;
|
||||||
|
public bool inverseXControls = false;
|
||||||
|
public bool inverseYControls = false;
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
|
@ -29,6 +31,10 @@ namespace SHADE_Scripting
|
||||||
{
|
{
|
||||||
AddComponent<CameraArm>();
|
AddComponent<CameraArm>();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void start()
|
||||||
|
{
|
||||||
GetComponent<CameraArm>().ArmLength = armLength;
|
GetComponent<CameraArm>().ArmLength = armLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +44,15 @@ namespace SHADE_Scripting
|
||||||
if (arm)
|
if (arm)
|
||||||
{
|
{
|
||||||
Vector2 vel = Input.GetMouseVelocity();
|
Vector2 vel = Input.GetMouseVelocity();
|
||||||
arm.Pitch -= vel.y * turnSpeedPitch * Time.DeltaTimeF;
|
if(inverseYControls)
|
||||||
arm.Yaw += vel.x * turnSpeedYaw * Time.DeltaTimeF;
|
arm.Pitch -= vel.y * turnSpeedPitch * Time.DeltaTimeF;
|
||||||
|
else
|
||||||
|
arm.Pitch += vel.y * turnSpeedPitch * Time.DeltaTimeF;
|
||||||
|
|
||||||
|
if (inverseXControls)
|
||||||
|
arm.Yaw -= vel.x * turnSpeedYaw * Time.DeltaTimeF;
|
||||||
|
else
|
||||||
|
arm.Yaw += vel.x * turnSpeedYaw * Time.DeltaTimeF;
|
||||||
|
|
||||||
if (arm.Pitch > pitchClamp)
|
if (arm.Pitch > pitchClamp)
|
||||||
{
|
{
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: SC_ThirdPersonCamera
|
||||||
|
ID: 166247489
|
||||||
|
Type: 9
|
|
@ -1,3 +0,0 @@
|
||||||
Name: ThirdPersonCamera
|
|
||||||
ID: 154161201
|
|
||||||
Type: 9
|
|
|
@ -6,17 +6,19 @@ public class GameManager : Script
|
||||||
{
|
{
|
||||||
public enum GameState
|
public enum GameState
|
||||||
{
|
{
|
||||||
MAINMENU,
|
|
||||||
START,
|
START,
|
||||||
WIN,
|
WIN,
|
||||||
LOSE,
|
LOSE
|
||||||
TOTAL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject itemPool;
|
public GameObject itemPool;
|
||||||
public GameObject zonePool;
|
public GameObject zonePool;
|
||||||
public GameState currGameState;
|
|
||||||
|
|
||||||
|
public uint winScene = 92009475;
|
||||||
|
public uint loseScene = 91685359;
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
public GameState currGameState;
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public int totalItemCount;
|
public int totalItemCount;
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
|
@ -27,41 +29,78 @@ public class GameManager : Script
|
||||||
private IEnumerable<Item> listOfItems;
|
private IEnumerable<Item> listOfItems;
|
||||||
private IEnumerable<ScoringZone> listOfZone;
|
private IEnumerable<ScoringZone> listOfZone;
|
||||||
|
|
||||||
|
public GameObject scoreText;
|
||||||
|
public GameObject timeText;
|
||||||
|
|
||||||
|
private bool once = true;
|
||||||
|
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
|
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
|
||||||
|
Audio.PlayBGMOnce2D("event:/Ambience/roomtone_kitchen");
|
||||||
totalItemCount = 0;
|
totalItemCount = 0;
|
||||||
Score = 0;
|
Score = 0;
|
||||||
currGameState = GameState.MAINMENU;
|
currGameState = GameState.START;
|
||||||
|
|
||||||
if (itemPool)
|
|
||||||
{
|
|
||||||
listOfItems = itemPool.GetScriptsInChildren<Item>();
|
|
||||||
if (listOfItems != null)
|
|
||||||
foreach (Item i in listOfItems)
|
|
||||||
totalItemCount += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zonePool)
|
|
||||||
{
|
|
||||||
listOfZone = zonePool.GetScriptsInChildren<ScoringZone>();
|
|
||||||
if (listOfZone != null)
|
|
||||||
foreach (ScoringZone sz in listOfZone)
|
|
||||||
sz.gameManger = Owner.GetScript<GameManager>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
if (timer > 0 && currGameState == GameState.START)
|
Cheats();
|
||||||
|
|
||||||
|
if (once)
|
||||||
|
{
|
||||||
|
if (itemPool)
|
||||||
|
{
|
||||||
|
listOfItems = itemPool.GetScriptsInChildren<Item>();
|
||||||
|
if (listOfItems != null)
|
||||||
|
foreach (Item i in listOfItems)
|
||||||
|
totalItemCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zonePool)
|
||||||
|
{
|
||||||
|
listOfZone = zonePool.GetScriptsInChildren<ScoringZone>();
|
||||||
|
if (listOfZone != null)
|
||||||
|
foreach (ScoringZone sz in listOfZone)
|
||||||
|
sz.gameManger = Owner.GetScript<GameManager>();
|
||||||
|
}
|
||||||
|
once = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currGameState == GameState.START)
|
||||||
{
|
{
|
||||||
timer -= Time.DeltaTimeF;
|
timer -= Time.DeltaTimeF;
|
||||||
if (totalItemCount <= 0)
|
if(scoreText)
|
||||||
|
scoreText.GetComponent<TextRenderable>().Text = $"Score: {Score}";
|
||||||
|
if(timeText)
|
||||||
|
timeText.GetComponent<TextRenderable>().Text = $"Time Left: {timer.ToString("0.00")}";
|
||||||
|
|
||||||
|
if ((timer > 0 && totalItemCount <= 0) || Input.GetKeyDown(Input.KeyCode.F1))
|
||||||
{
|
{
|
||||||
currGameState = GameState.WIN;
|
currGameState = GameState.WIN;
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
SceneManager.ChangeScene(winScene);
|
||||||
|
Audio.PlaySFXOnce2D("event:/Music/stingers/game_win");
|
||||||
|
}
|
||||||
|
else if(timer < 0 || Input.GetKeyDown(Input.KeyCode.F2))
|
||||||
|
{
|
||||||
|
currGameState = GameState.LOSE;
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
SceneManager.ChangeScene(loseScene);
|
||||||
|
Audio.PlaySFXOnce2D("event:/Music/stingers/game_lose");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
currGameState = GameState.LOSE;
|
|
||||||
|
private void Cheats()
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.Escape))
|
||||||
|
{
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
SceneManager.ChangeScene(97158628);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class ScoringZone : Script
|
||||||
{
|
{
|
||||||
if (gameManger && info.GameObject.GetScript<Item>())
|
if (gameManger && info.GameObject.GetScript<Item>())
|
||||||
{
|
{
|
||||||
Audio.PlayBGMOnce2D("event:/Music/stingers/item_scored");
|
Audio.PlaySFXOnce2D("event:/Music/stingers/item_scored");
|
||||||
gameManger.Score += info.GameObject.GetScript<Item>().Score;
|
gameManger.Score += info.GameObject.GetScript<Item>().Score;
|
||||||
gameManger.totalItemCount -= 1;
|
gameManger.totalItemCount -= 1;
|
||||||
info.GameObject.SetActive(false);
|
info.GameObject.SetActive(false);
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
using System;
|
|
||||||
using SHADE;
|
|
||||||
|
|
||||||
public class SC_MainMenu : Script
|
|
||||||
{
|
|
||||||
protected override void awake()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
protected override void update()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
using System;
|
||||||
|
using SHADE;
|
||||||
|
|
||||||
|
public class EndScene : Script
|
||||||
|
{
|
||||||
|
public uint mainGameScene = 86098106;
|
||||||
|
public uint mainMainScene = 97158628;
|
||||||
|
|
||||||
|
protected override void awake()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
protected override void update()
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.R))
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
|
||||||
|
}
|
||||||
|
if (Input.GetKeyUp(Input.KeyCode.R))
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/UI/success");
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
SceneManager.ChangeScene(mainGameScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.M))
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
|
||||||
|
}
|
||||||
|
if (Input.GetKeyUp(Input.KeyCode.M))
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/UI/success");
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
SceneManager.ChangeScene(mainMainScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKey(Input.KeyCode.Escape))
|
||||||
|
{
|
||||||
|
Application.Quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: SC_EndScene
|
||||||
|
ID: 165333970
|
||||||
|
Type: 9
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using SHADE;
|
||||||
|
|
||||||
|
public class MainMenu : Script
|
||||||
|
{
|
||||||
|
protected override void awake()
|
||||||
|
{
|
||||||
|
Audio.PlayBGMOnce2D("event:/Music/main_menu");
|
||||||
|
}
|
||||||
|
protected override void update()
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.Space))
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyUp(Input.KeyCode.Space))
|
||||||
|
{
|
||||||
|
Audio.PlaySFXOnce2D("event:/UI/success");
|
||||||
|
SceneManager.ChangeScene(86098106);
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.Escape))
|
||||||
|
{
|
||||||
|
Audio.StopAllSounds();
|
||||||
|
Application.Quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_KHR_vulkan_glsl : enable
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 aVertexPos;
|
||||||
|
layout(location = 1) in mat4 worldTransform;
|
||||||
|
layout(location = 5) in vec4 color;
|
||||||
|
|
||||||
|
// Output
|
||||||
|
layout(location = 0) out struct
|
||||||
|
{
|
||||||
|
vec4 Color;
|
||||||
|
} Out;
|
||||||
|
|
||||||
|
layout(set = 2, binding = 0) uniform CameraData
|
||||||
|
{
|
||||||
|
vec4 position;
|
||||||
|
mat4 vpMat;
|
||||||
|
mat4 viewMat;
|
||||||
|
mat4 perspectiveMat;
|
||||||
|
mat4 orthoMat;
|
||||||
|
} cameraData;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos.xyz, 1.0f);
|
||||||
|
Out.Color = color;
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: DebugDrawMesh_VS
|
||||||
|
ID: 42127043
|
||||||
|
Type: 2
|
|
@ -1,14 +1,13 @@
|
||||||
#version 450
|
#version 450
|
||||||
#extension GL_KHR_vulkan_glsl : enable
|
#extension GL_KHR_vulkan_glsl : enable
|
||||||
|
|
||||||
layout(location = 0) in vec4 aVertexPos;
|
layout(location = 0) in vec3 aVertexPos;
|
||||||
layout(location = 1) in vec4 aVertColor;
|
layout(location = 1) in vec4 aVertColor;
|
||||||
|
|
||||||
|
// Output
|
||||||
layout(location = 0) out struct
|
layout(location = 0) out struct
|
||||||
{
|
{
|
||||||
vec4 vertColor; // location 0
|
vec4 vertColor; // location 0
|
||||||
|
|
||||||
} Out;
|
} Out;
|
||||||
|
|
||||||
layout(set = 2, binding = 0) uniform CameraData
|
layout(set = 2, binding = 0) uniform CameraData
|
||||||
|
@ -22,6 +21,6 @@ layout(set = 2, binding = 0) uniform CameraData
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = cameraData.vpMat * vec4 (aVertexPos.xyz, 1.0f);
|
gl_Position = cameraData.vpMat * vec4 (aVertexPos, 1.0f);
|
||||||
Out.vertColor = aVertColor;
|
Out.vertColor = aVertColor;
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue