New features added #383

Merged
glencelow merged 8 commits from PlayerController into main 2023-03-02 18:31:38 +08:00
8 changed files with 102 additions and 73 deletions
Showing only changes of commit ab92d56cf0 - Show all commits

View File

@ -4530,7 +4530,7 @@
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
@ -4581,7 +4581,7 @@
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
@ -4632,7 +4632,7 @@
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
@ -5090,7 +5090,7 @@
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: true
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: true
Freeze Rotation Y: true
@ -5124,6 +5124,8 @@
lightMultiper: 0.75
mediumMultiper: 0.5
heavyMultiper: 0.25
silhouettePlayer: 462
silhouetteBag: 465
- Type: PickAndThrow
Enabled: true
throwForce: [8, 10, 8]
@ -5131,8 +5133,6 @@
delayTimer: 1
aimingLength: 0.899999976
throwItem: false
silhouettePlayer: 462
silhouetteBag: 465
rayDistance: 0.5
rayHeight: 0.100000001
aimingFOV: 50

View File

@ -2321,7 +2321,7 @@
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: true
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: true
Freeze Rotation Y: true
@ -2355,6 +2355,8 @@
lightMultiper: 0.899999976
mediumMultiper: 0.699999988
heavyMultiper: 0.5
silhouettePlayer: 462
silhouetteBag: 465
- Type: PickAndThrow
Enabled: true
throwForce: [10, 8, 10]
@ -2362,8 +2364,6 @@
delayTimer: 1
aimingLength: 1
throwItem: false
silhouettePlayer: 462
silhouetteBag: 465
rayDistance: 0.75
rayHeight: 0.100000001
aimingFOV: 50
@ -4782,7 +4782,7 @@
- Type: JumpPad
Enabled: true
- EID: 10
Name: Canvas
Name: PauseCanvas
IsActive: true
NumberOfChildren: 3
Components:
@ -13298,3 +13298,50 @@
Material: 131956078
IsActive: true
Scripts: ~
- EID: 174
Name: TweenManager
IsActive: true
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
Enabled: true
- EID: 172
Name: StealFoodCanvas
IsActive: true
NumberOfChildren: 1
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 173
Name: StealFoodLogo
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 0, y: 0, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 127459277
IsActive: true
UI Component:
Canvas ID: 172
Hovered: false
Clicked: false
IsActive: true
Scripts:
- Type: SHADE_Scripting.UI.StealFoodPopUp
Enabled: true
popInDuration: 0.5
popOutDuration: 0.5
stayDuration: 1
rotationAmt: 1800
scaleAmtX: 538
scaleAmtY: 377

View File

@ -28,11 +28,6 @@ public class PickAndThrow : Script
public bool throwItem = false;
private Vector3 prevTargetOffSet;
public GameObject silhouettePlayer;
public Renderable silhouettePlayerRend;
public GameObject silhouetteBag;
public Renderable silhouetteBagRend;
[Tooltip("Lenght of ray")]
public float rayDistance = 1;
@ -58,41 +53,17 @@ public class PickAndThrow : Script
if(!tpc)
Debug.LogError("TPC EMPTY");
if(!silhouettePlayer)
Debug.LogError("silhouettePlayer EMPTY");
else
silhouettePlayerRend = silhouettePlayer.GetComponent<Renderable>();
if (!silhouetteBag)
Debug.LogError("silhouetteBag EMPTY");
else
silhouetteBagRend = silhouetteBag.GetComponent<Renderable>();
AudioHandler.audioClipHandlers["SFXThrow"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_throw");
timer = delayTimer;
}
protected override void update()
{
if (GameManager.Instance.GamePause)
if (GameManager.Instance.GamePause || GameManager.Instance.stealFoodPopUp)
{
return;
}
if (silhouettePlayerRend && silhouetteBagRend)
{
//wait for daniel
//0.00075f;
Vector3 dis = Camera.GetMainCamera().Position - GameObject.GetComponent<Transform>().LocalPosition;
float disSqr = dis.GetSqrMagnitude();
float ratio = System.Math.Clamp(1 - (disSqr / (1 + disSqr)), 0, 1.0f);
float temp = (1 - ratio) * 0.00075f;
if (temp <= 0.0006f)
temp = 0.1f;
silhouettePlayerRend.Material.SetProperty<float>("data.offset", temp);
silhouetteBagRend.Material.SetProperty<float>("data.offset", temp);
}
if (timer <= delayTimer)
timer += Time.DeltaTimeF;
@ -171,7 +142,7 @@ public class PickAndThrow : Script
protected override void fixedUpdate()
{
if (GameManager.Instance.GamePause)
if (GameManager.Instance.GamePause || GameManager.Instance.stealFoodPopUp)
{
return;
}

View File

@ -17,15 +17,6 @@ public class PlayerController : Script
TOTAL
}
/* public enum WalkingState
{
CARRY,
AIMING,
THROW,
WALK,
TOTAL
}*/
public RigidBody rb { get; set; }
public Transform tranform { get; set; }
public Camera cam { get; set; }
@ -85,6 +76,12 @@ public class PlayerController : Script
[Tooltip("How heavy item will affect player jump")]
public float heavyMultiper = 0.25f;
//silhouette=====================================================================
public GameObject silhouettePlayer;
public Renderable silhouettePlayerRend;
public GameObject silhouetteBag;
public Renderable silhouetteBagRend;
protected override void awake()
{
//default setup
@ -119,6 +116,21 @@ public class PlayerController : Script
dictionary.Add(typeof(PlayerCaughtState), new PlayerCaughtState(stateMachine));
stateMachine.InitStateMachine(dictionary);
if (!silhouettePlayer)
Debug.LogError("silhouettePlayer EMPTY");
else
{
silhouettePlayerRend = silhouettePlayer.GetComponent<Renderable>();
silhouettePlayerRend.Material.SetProperty<float>("data.offset", 0.1f);
}
if (!silhouetteBag)
Debug.LogError("silhouetteBag EMPTY");
else
{
silhouetteBagRend = silhouetteBag.GetComponent<Renderable>();
silhouetteBagRend.Material.SetProperty<float>("data.offset", 0.1f);
}
}
protected override void lateUpdate()
@ -127,26 +139,23 @@ public class PlayerController : Script
protected override void update()
{
if (GameManager.Instance.GamePause)
if (GameManager.Instance.GamePause || GameManager.Instance.stealFoodPopUp)
{
return;
}
if (delayTimer <= 1)
delayTimer += Time.DeltaTimeF;
if (silhouettePlayerRend && silhouetteBagRend)
{
Vector3 dis = Camera.GetMainCamera().Position - GameObject.GetComponent<Transform>().LocalPosition;
float disSqr = dis.GetSqrMagnitude();
float ratio = System.Math.Clamp(1 - (disSqr / (1 + disSqr)), 0, 1.0f);
float temp = (1 - ratio) * 0.00075f;
if (temp <= 0.0006f)
temp = 0.1f;
silhouettePlayerRend.Material.SetProperty<float>("data.offset", temp);
silhouetteBagRend.Material.SetProperty<float>("data.offset", temp);
}
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)
{
@ -160,9 +169,7 @@ public class PlayerController : Script
if(!camArm)
camArm = GetComponentInChildren<CameraArm>();
//tempFix
if (tranform)
tranform.LocalEulerAngles = new Vector3(0.0f, tranform.LocalEulerAngles.y, 0.0f);
GotCaught();
Rotation();
@ -178,7 +185,7 @@ public class PlayerController : Script
protected override void fixedUpdate()
{
if (GameManager.Instance.GamePause)
if (GameManager.Instance.GamePause || GameManager.Instance.stealFoodPopUp)
{
return;
}
@ -336,7 +343,7 @@ public class PlayerController : Script
if (isMoveKeyPress && tranform && !isAiming)
{
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), Vector3.Up);
tranform.LocalRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * (float)Time.FixedDeltaTime);
}
else if (camArm && tranform && isAiming)

View File

@ -41,7 +41,7 @@ namespace SHADE_Scripting
protected override void update()
{
if (GameManager.Instance.GamePause)
if (GameManager.Instance.GamePause || GameManager.Instance.stealFoodPopUp)
{
return;
}

View File

@ -40,6 +40,7 @@ public class GameManager : Script
public static GameManager Instance { get; private set; }
public bool GamePause { get; set; }
public bool stealFoodPopUp { get; set; }
public bool itemShatter { get; set; }
@ -58,6 +59,8 @@ public class GameManager : Script
currMultiplierDuration = 0;
fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration);
itemShatter = false;
GamePause = false;
stealFoodPopUp = true;
AudioHandler.audioClipHandlers["BGMWin"] = Audio.CreateAudioClip("event:/Music/stingers/game_win");
AudioHandler.audioClipHandlers["BGMLose"] = Audio.CreateAudioClip("event:/Music/stingers/game_lose");

View File

@ -86,7 +86,7 @@ public class PauseMenu : Script
protected override void update()
{
if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause)
if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause && !GameManager.Instance.stealFoodPopUp)
{
GameManager.Instance.GamePause = true;
AudioHandler.pauseAllSounds(true);

View File

@ -79,6 +79,7 @@ namespace SHADE_Scripting.UI
if (scaleOutX.IsCompleted() && scaleOutY.IsCompleted())
{
GameObject.SetActive(false);
GameManager.Instance.stealFoodPopUp = false;
}
}
}