Updated Player and MainGame scene, fix bugs #281
|
@ -8236,15 +8236,7 @@
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Type: Box
|
Type: Box
|
||||||
Half Extents: {x: 0.200000003, y: 0.200000003, z: 0.200000003}
|
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.400000006, y: 0.400000006, z: 0.400000006}
|
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
Bounciness: 0
|
Bounciness: 0
|
||||||
Density: 1
|
Density: 1
|
||||||
|
@ -8288,15 +8280,7 @@
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Type: Box
|
Type: Box
|
||||||
Half Extents: {x: 0.5, y: 0.150000006, z: 0.5}
|
Half Extents: {x: 0.25, y: 0.075000003, z: 0.25}
|
||||||
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.699999988, y: 0.300000012, z: 0.75}
|
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
Bounciness: 0
|
Bounciness: 0
|
||||||
Density: 1
|
Density: 1
|
||||||
|
@ -8340,15 +8324,7 @@
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Type: Box
|
Type: Box
|
||||||
Half Extents: {x: 0.300000012, y: 0.300000012, z: 0.300000012}
|
Half Extents: {x: 0.150000006, y: 0.150000006, 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}
|
|
||||||
- Is Trigger: true
|
|
||||||
Type: Box
|
|
||||||
Half Extents: {x: 0.5, y: 0.5, z: 0.5}
|
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
Bounciness: 0
|
Bounciness: 0
|
||||||
Density: 1
|
Density: 1
|
||||||
|
@ -8558,10 +8534,12 @@
|
||||||
heavyMultiper: 0.25
|
heavyMultiper: 0.25
|
||||||
- Type: PickAndThrow
|
- Type: PickAndThrow
|
||||||
Enabled: true
|
Enabled: true
|
||||||
throwForce: [50, 50, 50]
|
throwForce: [8, 10, 8]
|
||||||
|
item: 51000
|
||||||
delayTimer: 1
|
delayTimer: 1
|
||||||
aimingLength: 0.5
|
aimingLength: 0.5
|
||||||
rayDistance: 1
|
inRange: false
|
||||||
|
rayDistance: 0.5
|
||||||
- EID: 3
|
- EID: 3
|
||||||
Name: HoldingPoint
|
Name: HoldingPoint
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -8634,62 +8612,3 @@
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 196
|
|
||||||
Name: ====AI=====
|
|
||||||
IsActive: true
|
|
||||||
NumberOfChildren: 0
|
|
||||||
Components:
|
|
||||||
Transform Component:
|
|
||||||
Translate: {x: 2.70000005, y: 0.100000001, z: -2}
|
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
|
||||||
IsActive: true
|
|
||||||
Renderable Component:
|
|
||||||
Mesh: 140697366
|
|
||||||
Material: 129495479
|
|
||||||
IsActive: true
|
|
||||||
RigidBody Component:
|
|
||||||
Type: Dynamic
|
|
||||||
Drag: 0.00999999978
|
|
||||||
Angular Drag: 0.00999999978
|
|
||||||
Use Gravity: true
|
|
||||||
Interpolate: false
|
|
||||||
Sleeping Enabled: true
|
|
||||||
Freeze Position X: false
|
|
||||||
Freeze Position Y: false
|
|
||||||
Freeze Position Z: false
|
|
||||||
Freeze Rotation X: true
|
|
||||||
Freeze Rotation Y: false
|
|
||||||
Freeze Rotation Z: true
|
|
||||||
IsActive: true
|
|
||||||
Collider Component:
|
|
||||||
Colliders:
|
|
||||||
- Is Trigger: false
|
|
||||||
Type: Box
|
|
||||||
Half Extents: {x: 1, y: 1.79999995, z: 0.400000006}
|
|
||||||
Friction: 0.400000006
|
|
||||||
Bounciness: 0
|
|
||||||
Density: 1
|
|
||||||
Position Offset: {x: 0, y: 0.899999976, z: 0}
|
|
||||||
Rotation Offset: {x: 0, y: 0, z: 0}
|
|
||||||
IsActive: true
|
|
||||||
Scripts:
|
|
||||||
- Type: Homeowner1
|
|
||||||
Enabled: true
|
|
||||||
player: 2
|
|
||||||
waypoints:
|
|
||||||
- [2.70000005, 0, -2]
|
|
||||||
- [-0.300000012, 0, -2.70000005]
|
|
||||||
- [-2, 0, -3.79999995]
|
|
||||||
- [-4, 0, -2.0999999]
|
|
||||||
- [-2.9000001, 0, 2.4000001]
|
|
||||||
- [-1, 0, 4]
|
|
||||||
- [2.70000005, 0, 4]
|
|
||||||
patrolSpeed: 1
|
|
||||||
chaseSpeed: 2
|
|
||||||
turningSpeed: 5
|
|
||||||
sightDistance: 8
|
|
||||||
eyeOffset: [0, 0, 0]
|
|
||||||
distanceToCapture: 0.5
|
|
||||||
captureTime: 0.5
|
|
||||||
footstepSFXIntervalMultiplier: 0.5
|
|
|
@ -7,7 +7,7 @@ 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 GameObject item { get; set; }
|
public GameObject item;
|
||||||
public float delayTimer = 1.0f;
|
public float delayTimer = 1.0f;
|
||||||
public float aimingLength = 1.5f;
|
public float aimingLength = 1.5f;
|
||||||
|
|
||||||
|
@ -17,18 +17,16 @@ public class PickAndThrow : Script
|
||||||
private Transform itemTransform;
|
private Transform itemTransform;
|
||||||
private RigidBody itemRidibody;
|
private RigidBody itemRidibody;
|
||||||
private Transform raccoonHoldLocation;
|
private Transform raccoonHoldLocation;
|
||||||
private Transform playerTran;
|
|
||||||
private Item itemScript;
|
private Item itemScript;
|
||||||
private ThirdPersonCamera tpc;
|
private ThirdPersonCamera tpc;
|
||||||
private float lastXDir;
|
private float lastXDir;
|
||||||
private float lastZDir;
|
private float lastZDir;
|
||||||
private bool inRange = false;
|
public bool inRange = false;
|
||||||
|
|
||||||
private Collider collider;
|
private Collider collider;
|
||||||
private BoxCollider cs;
|
|
||||||
|
|
||||||
[Tooltip("Lenght of ray")]
|
[Tooltip("Lenght of ray")]
|
||||||
public float rayDistance = 3;
|
public float rayDistance = 1;
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
|
@ -49,7 +47,6 @@ public class PickAndThrow : Script
|
||||||
Debug.LogError("COLLIDER EMPTY");
|
Debug.LogError("COLLIDER EMPTY");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs = collider.GetCollisionShape<BoxCollider>(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timer = delayTimer;
|
timer = delayTimer;
|
||||||
|
@ -60,13 +57,14 @@ public class PickAndThrow : Script
|
||||||
timer += Time.DeltaTimeF;
|
timer += Time.DeltaTimeF;
|
||||||
|
|
||||||
CalculateDir();
|
CalculateDir();
|
||||||
|
CastRay();
|
||||||
|
|
||||||
if (pc && itemRidibody && itemTransform)
|
if (pc && itemRidibody && itemTransform)
|
||||||
{
|
{
|
||||||
if (pc.holdItem)
|
if (pc.holdItem)
|
||||||
{
|
{
|
||||||
itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition;
|
itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition;
|
||||||
itemTransform.LocalRotation = playerTran.LocalRotation;
|
itemTransform.LocalRotation = pc.tranform.LocalRotation;
|
||||||
|
|
||||||
if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
|
if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
|
||||||
{
|
{
|
||||||
|
@ -86,6 +84,7 @@ public class PickAndThrow : Script
|
||||||
if (itemScript)
|
if (itemScript)
|
||||||
{
|
{
|
||||||
Vector3 vec = new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir);
|
Vector3 vec = new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir);
|
||||||
|
//to be change
|
||||||
if (itemScript.currCategory == ItemCategory.LIGHT)
|
if (itemScript.currCategory == ItemCategory.LIGHT)
|
||||||
itemRidibody.AddForce(vec * 0.3f);
|
itemRidibody.AddForce(vec * 0.3f);
|
||||||
if (itemScript.currCategory == ItemCategory.MEDIUM)
|
if (itemScript.currCategory == ItemCategory.MEDIUM)
|
||||||
|
@ -130,7 +129,6 @@ public class PickAndThrow : Script
|
||||||
|
|
||||||
protected override void fixedUpdate()
|
protected override void fixedUpdate()
|
||||||
{
|
{
|
||||||
CastRay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetItemObject()
|
private void ResetItemObject()
|
||||||
|
@ -144,7 +142,7 @@ public class PickAndThrow : Script
|
||||||
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 && !itemRidibody )
|
||||||
{
|
{
|
||||||
itemRidibody = item.GetComponent<RigidBody>();
|
itemRidibody = item.GetComponent<RigidBody>();
|
||||||
if (itemRidibody == null)
|
if (itemRidibody == null)
|
||||||
|
@ -187,43 +185,34 @@ public class PickAndThrow : Script
|
||||||
|
|
||||||
private void CastRay()
|
private void CastRay()
|
||||||
{
|
{
|
||||||
if (pc != null && cs != null)
|
if (pc != null)
|
||||||
{
|
{
|
||||||
Vector3 dirNor = pc.tranform.Forward;
|
Vector3 dirNor = pc.tranform.Forward;
|
||||||
//change when cs.HalfExtents.z works
|
Vector3 playerRayPos = pc.tranform.GlobalPosition;
|
||||||
//cs.HalfExtents.z
|
playerRayPos.y += 0.05f;
|
||||||
Vector3 playerRayPos = pc.tranform.GlobalPosition + (dirNor * (0.3f + 0.1f));
|
|
||||||
playerRayPos.y += 0.1f;
|
|
||||||
dirNor.Normalise();
|
dirNor.Normalise();
|
||||||
RaycastHit ray1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance);
|
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 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.5f);
|
RaycastHit ray3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f);
|
||||||
|
inRange = CheckForItem(ray1) || CheckForItem(ray2) || CheckForItem(ray3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CheckForItem(RaycastHit ray)
|
||||||
|
{
|
||||||
|
if (ray.Hit)
|
||||||
|
{
|
||||||
|
if (ray.Other.Value.GetScript<Item>() && !pc.holdItem)
|
||||||
|
{
|
||||||
|
item = ray.Other.Value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
protected override void onCollisionEnter(CollisionInfo info)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
protected override void onTriggerEnter(CollisionInfo info)
|
|
||||||
{
|
|
||||||
if (info.GameObject.GetScript<Item>() && !pc.holdItem)
|
|
||||||
{
|
|
||||||
item = info.GameObject;
|
|
||||||
inRange = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected override void onTriggerStay(CollisionInfo info)
|
|
||||||
{
|
|
||||||
//Debug.Log("STAY");
|
|
||||||
}
|
|
||||||
protected override void onTriggerExit(CollisionInfo info)
|
|
||||||
{
|
|
||||||
//Debug.Log("EXIT");
|
|
||||||
if (info.GameObject.GetScript<Item>() != null && !pc.holdItem)
|
|
||||||
{
|
|
||||||
inRange = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -42,17 +42,12 @@ public class GameManager : Script
|
||||||
Score = 0;
|
Score = 0;
|
||||||
currGameState = GameState.START;
|
currGameState = GameState.START;
|
||||||
|
|
||||||
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()
|
||||||
{
|
{
|
||||||
|
Cheats();
|
||||||
|
|
||||||
if (once)
|
if (once)
|
||||||
{
|
{
|
||||||
if (itemPool)
|
if (itemPool)
|
||||||
|
@ -62,6 +57,14 @@ public class GameManager : Script
|
||||||
foreach (Item i in listOfItems)
|
foreach (Item i in listOfItems)
|
||||||
totalItemCount += 1;
|
totalItemCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (zonePool)
|
||||||
|
{
|
||||||
|
listOfZone = zonePool.GetScriptsInChildren<ScoringZone>();
|
||||||
|
if (listOfZone != null)
|
||||||
|
foreach (ScoringZone sz in listOfZone)
|
||||||
|
sz.gameManger = Owner.GetScript<GameManager>();
|
||||||
|
}
|
||||||
once = false;
|
once = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,4 +89,20 @@ public class GameManager : Script
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Cheats()
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.F1))
|
||||||
|
{
|
||||||
|
SceneManager.ChangeScene(loseScene);
|
||||||
|
}
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.F2))
|
||||||
|
{
|
||||||
|
SceneManager.ChangeScene(winScene);
|
||||||
|
}
|
||||||
|
if (Input.GetKeyDown(Input.KeyCode.Escape))
|
||||||
|
{
|
||||||
|
SceneManager.ChangeScene(97158628);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,14 @@ public class MainMenu : Script
|
||||||
}
|
}
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
if (Input.GetKey(Input.KeyCode.Space))
|
if (Input.GetKeyDown(Input.KeyCode.Space))
|
||||||
{
|
{
|
||||||
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
|
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
|
||||||
SceneManager.ChangeScene(86098106);
|
SceneManager.ChangeScene(86098106);
|
||||||
Audio.StopAllSounds();
|
Audio.StopAllSounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetKey(Input.KeyCode.Escape))
|
if (Input.GetKeyDown(Input.KeyCode.Escape))
|
||||||
{
|
{
|
||||||
Audio.StopAllSounds();
|
Audio.StopAllSounds();
|
||||||
Application.Quit();
|
Application.Quit();
|
||||||
|
|
|
@ -144,7 +144,6 @@ namespace SHADE
|
||||||
// HACK: Clamp DT here to prevent a ridiculous amount of updates. This limits updates from large dt to 2.
|
// HACK: Clamp DT here to prevent a ridiculous amount of updates. This limits updates from large dt to 2.
|
||||||
// HACK: This should be done by the FRC and not here for predictable behaviour.
|
// HACK: This should be done by the FRC and not here for predictable behaviour.
|
||||||
|
|
||||||
dt = std::clamp(dt, 0.0, 1.0 / 30.0);
|
|
||||||
accumulatedTime += dt;
|
accumulatedTime += dt;
|
||||||
|
|
||||||
//testFunction();
|
//testFunction();
|
||||||
|
|
Loading…
Reference in New Issue