Update changes to scripts and AudioSystem #224

Merged
glencelow merged 15 commits from PlayerController into main 2022-11-18 19:01:24 +08:00
6 changed files with 182 additions and 33 deletions
Showing only changes of commit e4f23dc6c3 - Show all commits

View File

@ -13,6 +13,7 @@
Near: 0.00999999978
Far: 10000
Perspective: true
IsActive: true
Light Component:
Position: {x: 0, y: 0, z: 0}
Type: Directional
@ -20,6 +21,7 @@
Color: {x: 0.951541841, y: 0.921719015, z: 0.553319454, w: 1}
Layer: 4294967295
Strength: 0
IsActive: true
Scripts: ~
- EID: 1
Name: Default
@ -30,9 +32,11 @@
Translate: {x: -1.440328, y: -4.41369677, z: -5}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 49.4798889, y: 0.5, z: 17.5}
IsActive: true
Renderable Component:
Mesh: 149697411
Material: 126974645
IsActive: true
RigidBody Component:
Type: Static
Mass: 1
@ -46,6 +50,7 @@
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
@ -55,6 +60,7 @@
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
- EID: 2
Name: Player
@ -62,12 +68,14 @@
NumberOfChildren: 3
Components:
Transform Component:
Translate: {x: -0.867276311, y: -3.67369723, z: -9.76580334}
Translate: {x: -17.1017113, y: -3.67369723, z: -6.04142666}
Rotate: {x: -0, y: 0, z: 0}
Scale: {x: 2, y: 2, z: 2}
IsActive: true
Renderable Component:
Mesh: 149697411
Material: 126974645
IsActive: true
RigidBody Component:
Type: Dynamic
Mass: 1
@ -81,6 +89,7 @@
Freeze Rotation X: true
Freeze Rotation Y: true
Freeze Rotation Z: true
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
@ -90,12 +99,13 @@
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0.5, z: 0}
IsActive: true
Scripts:
- Type: PlayerController
currentState: 0
maxMoveVel: 2
maxMoveVel: 4
moveForce: 50
sprintMultiplier: 2
sprintMultiplier: 1.5
rotationFactorPerFrame: 1
maxJumpHeight: 4
maxJumpTime: 0.75
@ -104,17 +114,18 @@
mediumMultiper: 0.5
heavyMultiper: 0.25
- Type: PickAndThrow
holdPosition: [0, 1, 0]
throwForce: [100, 200, 100]
holdPosition: [0, 1.20000005, 0]
throwForce: [200, 300, 200]
- EID: 3
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 1, z: 0}
Translate: {x: 0, y: 1.20000005, z: 0}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Scripts: ~
- EID: 4
Name: Default
@ -123,18 +134,20 @@
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0}
Rotate: {x: -0.549778998, y: 1.59691703, z: 0}
Rotate: {x: -0.78538686, y: 1.26529622, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Camera Component:
Position: {x: -0.867276311, y: -3.67369723, z: -9.76580334}
Pitch: -31.5000153
Yaw: 91.4966049
Position: {x: -17.1017113, y: -3.67369723, z: -6.04142666}
Pitch: -44.9993515
Yaw: 72.4961319
Roll: 0
Width: 1920
Height: 1080
Near: 0.00999999978
Far: 10000
Perspective: true
IsActive: true
Scripts:
- Type: SHADE_Scripting.ThirdPersonCamera
armLength: 2
@ -150,9 +163,11 @@
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: 144838771
Material: 123745521
IsActive: true
Scripts: ~
- EID: 6
Name: AI
@ -163,9 +178,11 @@
Translate: {x: -8, y: -4.42369843, z: 2.5}
Rotate: {x: -0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:
Mesh: 149697411
Material: 126974645
IsActive: true
RigidBody Component:
Type: Dynamic
Mass: 1
@ -179,6 +196,7 @@
Freeze Rotation X: true
Freeze Rotation Y: true
Freeze Rotation Z: true
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
@ -188,6 +206,7 @@
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0.5, z: 0}
IsActive: true
Scripts: ~
- EID: 7
Name: Default
@ -198,9 +217,11 @@
Translate: {x: 0, y: -16.8647861, z: -14.039052}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 28.1434975, y: 28.1434975, z: 28.1434975}
IsActive: true
Renderable Component:
Mesh: 149697411
Material: 126974645
IsActive: true
Scripts: ~
- EID: 8
Name: Default
@ -214,8 +235,54 @@
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 0.25
IsActive: true
Scripts: ~
- EID: 5
- EID: 11
Name: GameManager
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
RigidBody Component:
Type: Static
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Interpolate: 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: true
Type: Box
Half Extents: {x: 3.5999999, y: 8, z: 7.19999981}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: -24.3999996, y: -3.0999999, z: -5.0999999}
IsActive: true
Scripts:
- Type: GameManager
itemPool: 12
totalItemCount: 0
Score: 1
- EID: 12
Name: ItemPool
IsActive: true
NumberOfChildren: 2
Components: ~
Scripts: ~
- EID: 10
Name: item
IsActive: true
NumberOfChildren: 0
@ -224,9 +291,11 @@
Translate: {x: 3.19870043, y: -3.67369723, z: -5}
Rotate: {x: -0, y: 0, z: 0}
Scale: {x: 2, y: 2, z: 2}
IsActive: true
Renderable Component:
Mesh: 144838771
Material: 123745521
IsActive: true
RigidBody Component:
Type: Dynamic
Mass: 1
@ -240,6 +309,7 @@
Freeze Rotation X: true
Freeze Rotation Y: true
Freeze Rotation Z: true
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
@ -256,6 +326,56 @@
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0.5, z: 0}
IsActive: true
Scripts:
- Type: Item
Score: 1
currCategory: 0
- EID: 5
Name: item
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -3.09096575, y: -2.43732405, z: -6.98679876}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 2, y: 2, z: 2}
IsActive: true
Renderable Component:
Mesh: 144838771
Material: 123745521
IsActive: true
RigidBody Component:
Type: Dynamic
Mass: 1
Drag: 0
Angular Drag: 0
Use Gravity: true
Interpolate: false
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: true
Freeze Rotation Y: true
Freeze Rotation Z: true
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.5, z: 0}
- Is Trigger: true
Type: Box
Half Extents: {x: 2, y: 2, z: 2}
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0.5, z: 0}
IsActive: true
Scripts:
- Type: Item
Score: 1

View File

@ -0,0 +1,43 @@
using SHADE;
using System;
using System.Collections.Generic;
public class GameManager : Script
{
enum GameState
{
}
public GameObject itemPool;
public int totalItemCount;
public int Score;
private IEnumerable<Item> listOfItems;
protected override void awake()
{
totalItemCount = 0;
Score = 0;
if (itemPool)
{
listOfItems = itemPool.GetScriptsInChildren<Item>();
foreach (Item i in listOfItems)
totalItemCount += 1;
}
}
protected override void update()
{
}
protected override void onTriggerEnter(CollisionInfo info)
{
if (info.GameObject.GetScript<Item>())
{
totalItemCount -= 1;
Score = info.GameObject.GetScript<Item>().Score;
info.GameObject.SetActive(false);
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_GameManager
ID: 161629605
Type: 9

View File

@ -8,7 +8,7 @@ public class Item : Script
MEDIUM,
HEAVY
}
public int Score = 1;
public int Score = 10;
public ItemCategory currCategory;

View File

@ -97,7 +97,6 @@ public class PickAndThrow : Script
}
protected override void onTriggerEnter(CollisionInfo info)
{
//Debug.Log("ENTER");
if (info.GameObject.GetScript<Item>() != null && !pc.holdItem)
{
item = info.GameObject;

View File

@ -97,9 +97,6 @@ public class PlayerController : Script
else
{
rb.IsGravityEnabled = false;
rb.FreezeRotationX = true;
rb.FreezeRotationY = true;
rb.FreezeRotationZ = true;
rb.Interpolating = false;
}
@ -143,24 +140,18 @@ public class PlayerController : Script
Sprint();
Jump();
Gravity();
//Debug.Log($"X: {rb.LinearVelocity.x}" + $" z: {rb.LinearVelocity.z}");
//Debug.Log($"X: {rb.LinearVelocity.x}" + $" Z: {rb.LinearVelocity.z}");
}
private void MoveKey()
{
xAxisMove = 0;
zAxisMove = 0;
axisMove = Vector2.Zero;
if (Input.GetKey(Input.KeyCode.W))
{
Vector3 camerAixs = cam.GetForward();
camerAixs.y = 0;
camerAixs.Normalise();
xAxisMove = camerAixs.x;
zAxisMove = camerAixs.z;
axisMove += new Vector2(camerAixs.x, camerAixs.z);
}
@ -169,8 +160,6 @@ public class PlayerController : Script
Vector3 camerAixs = cam.GetForward();
camerAixs.y = 0;
camerAixs.Normalise();
xAxisMove = -camerAixs.x;
zAxisMove = -camerAixs.z;
axisMove -= new Vector2(camerAixs.x, camerAixs.z);
}
@ -179,8 +168,6 @@ public class PlayerController : Script
Vector3 camerAixs = cam.GetRight();
camerAixs.y = 0;
camerAixs.Normalise();
xAxisMove = -camerAixs.x;
zAxisMove = -camerAixs.z;
axisMove -= new Vector2(camerAixs.x, camerAixs.z);
}
@ -189,13 +176,11 @@ public class PlayerController : Script
Vector3 camerAixs = cam.GetRight();
camerAixs.y = 0;
camerAixs.Normalise();
xAxisMove = camerAixs.x;
zAxisMove = camerAixs.z;
axisMove += new Vector2(camerAixs.x, camerAixs.z);
}
axisMove.Normalise();
isMoveKeyPress = xAxisMove != 0 || zAxisMove != 0;
isMoveKeyPress = axisMove.x != 0 || axisMove.y != 0;
if (isMoveKeyPress && isGrounded && !Input.GetKey(Input.KeyCode.LeftShift))
{
@ -218,7 +203,6 @@ public class PlayerController : Script
{
if (rb != null)
{
//rb.AddForce(new Vector3(axisMove.x, 0.0f,axisMove.y) * moveForce);
rb.LinearVelocity += new Vector3(axisMove.x * moveForce, 0.0f, axisMove.y * moveForce) * Time.DeltaTimeF;
if (isMoveKeyPress)
@ -305,9 +289,9 @@ public class PlayerController : Script
private void Rotation()
{
Vector3 poitionToLookAt;
poitionToLookAt.x = xAxisMove;
poitionToLookAt.x = axisMove.x;
poitionToLookAt.y = 0.0f;
poitionToLookAt.z = zAxisMove;
poitionToLookAt.z = axisMove.y;
if (tranform != null)
{