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
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Y: true
Freeze Position Z: false
Freeze Rotation X: true
Freeze Rotation Y: true
@ -8240,6 +8240,7 @@
Scripts:
- Type: PlayerController
Enabled: true
respawnPoint: 239
currentState: 0
maxMoveVel: 3
moveForce: 50
@ -8255,14 +8256,14 @@
Enabled: true
throwForce: [300, 300, 300]
delayTimer: 1
aimingLength: 1.5
aimingLength: 0.5
- EID: 3
Name: HoldingPoint
IsActive: true
NumberOfChildren: 0
Components:
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}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -8369,7 +8370,11 @@
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
- EID: 242
Name: Mesh_Cheese
IsActive: true
@ -8417,7 +8422,11 @@
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
- EID: 241
Name: Mesh_Meat
IsActive: true
@ -8465,7 +8474,11 @@
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~
Scripts:
- Type: Item
Enabled: true
Score: 10
currCategory: 0
- EID: 15
Name: ====ScoreZonePool====
IsActive: true
@ -8547,4 +8560,15 @@
IsActive: true
Scripts:
- 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
}
public enum WalkingState
/* public enum WalkingState
{
CARRY,
AIMING,
THROW,
WALK,
TOTAL
}
}*/
public RigidBody rb { get; set; }
private Transform tranform;
@ -36,6 +36,9 @@ public class PlayerController : Script
public bool holdItem { get; set; }
public bool isAiming { get; set; }
public GameObject respawnPoint;
private float delayTimer = 0.0f;
[Tooltip("The current state fo the raccoon")]
public RaccoonStates currentState = RaccoonStates.IDLE;
@ -113,8 +116,27 @@ public class PlayerController : Script
}
protected override void lateUpdate()
{
//rb.FreezePositionY = false;
}
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)
{
@ -138,6 +160,7 @@ public class PlayerController : Script
protected override void fixedUpdate()
{
MoveKey();
Move();
Sprint();
@ -341,12 +364,12 @@ public class PlayerController : Script
private void GotCaught()
{
if (currentState == RaccoonStates.CAUGHT && tranform != null)
if (currentState == RaccoonStates.CAUGHT && tranform && respawnPoint)
{
currentState = RaccoonStates.IDLE;
if (stateMachine && !stateMachine.IsState(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 zonePool;
public uint winScene = 92009475;
public uint loseScene = 91685359;
[NonSerialized]
public GameState currGameState;
[NonSerialized]
@ -52,15 +55,19 @@ public class GameManager : Script
protected override void update()
{
if (timer > 0 && currGameState == GameState.START)
{
{
timer -= Time.DeltaTimeF;
if (totalItemCount <= 0)
{
{
currGameState = GameState.WIN;
SceneManager.ChangeScene(winScene);
}
}
else
{
currGameState = GameState.LOSE;
SceneManager.ChangeScene(loseScene);
}
}
}

View File

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