Bug fixes and scene changes #267

Merged
glencelow merged 15 commits from PlayerController into main 2022-11-23 20:53:44 +08:00
4 changed files with 68 additions and 13 deletions
Showing only changes of commit 152007e810 - Show all commits

View File

@ -8220,7 +8220,7 @@
Interpolate: true Interpolate: true
Sleeping Enabled: true Sleeping Enabled: true
Freeze Position X: false Freeze Position X: false
Freeze Position Y: false Freeze Position Y: true
Freeze Position Z: false Freeze Position Z: false
Freeze Rotation X: true Freeze Rotation X: true
Freeze Rotation Y: true Freeze Rotation Y: true
@ -8240,6 +8240,7 @@
Scripts: Scripts:
- Type: PlayerController - Type: PlayerController
Enabled: true Enabled: true
respawnPoint: 239
currentState: 0 currentState: 0
maxMoveVel: 3 maxMoveVel: 3
moveForce: 50 moveForce: 50
@ -8255,14 +8256,14 @@
Enabled: true Enabled: true
throwForce: [300, 300, 300] throwForce: [300, 300, 300]
delayTimer: 1 delayTimer: 1
aimingLength: 1.5 aimingLength: 0.5
- EID: 3 - EID: 3
Name: HoldingPoint Name: HoldingPoint
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 1.20000005, z: 0.5} Translate: {x: 0, y: 0.699999988, z: 0.200000003}
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: 1, z: 1}
IsActive: true IsActive: true
@ -8369,7 +8370,11 @@
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}
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
- EID: 242 - EID: 242
Name: Mesh_Cheese Name: Mesh_Cheese
IsActive: true IsActive: true
@ -8417,7 +8422,11 @@
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}
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
- EID: 241 - EID: 241
Name: Mesh_Meat Name: Mesh_Meat
IsActive: true IsActive: true
@ -8465,7 +8474,11 @@
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}
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
- EID: 15 - EID: 15
Name: ====ScoreZonePool==== Name: ====ScoreZonePool====
IsActive: true IsActive: true
@ -8548,3 +8561,14 @@
Scripts: Scripts:
- Type: ScoringZone - Type: ScoringZone
Enabled: true Enabled: true
- EID: 239
Name: RespawnPoint
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2.5, y: 0.660660267, z: 7}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Scripts: ~

View File

@ -17,14 +17,14 @@ 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; private Transform tranform;
@ -36,6 +36,9 @@ public class PlayerController : Script
public bool holdItem { get; set; } public bool holdItem { get; set; }
public bool isAiming { get; set; } public bool isAiming { get; set; }
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;
@ -113,8 +116,27 @@ public class PlayerController : Script
} }
protected override void lateUpdate()
{
//rb.FreezePositionY = false;
}
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 //PickAndThrow check
if (!pat) if (!pat)
{ {
@ -138,6 +160,7 @@ public class PlayerController : Script
protected override void fixedUpdate() protected override void fixedUpdate()
{ {
MoveKey(); MoveKey();
Move(); Move();
Sprint(); Sprint();
@ -341,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;
} }
} }

View File

@ -14,6 +14,9 @@ public class GameManager : Script
public GameObject itemPool; public GameObject itemPool;
public GameObject zonePool; public GameObject zonePool;
public uint winScene = 92009475;
public uint loseScene = 91685359;
[NonSerialized] [NonSerialized]
public GameState currGameState; public GameState currGameState;
[NonSerialized] [NonSerialized]
@ -57,10 +60,14 @@ public class GameManager : Script
if (totalItemCount <= 0) if (totalItemCount <= 0)
{ {
currGameState = GameState.WIN; currGameState = GameState.WIN;
SceneManager.ChangeScene(winScene);
} }
} }
else else
{
currGameState = GameState.LOSE; currGameState = GameState.LOSE;
SceneManager.ChangeScene(loseScene);
}
} }
} }

View File

@ -5,6 +5,7 @@ public class MainMenu : Script
{ {
protected override void awake() protected override void awake()
{ {
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
} }
protected override void update() protected override void update()
{ {