Bug fixes, Scene changes and new features #376

Merged
glencelow merged 15 commits from PlayerController into main 2023-02-28 23:10:33 +08:00
9 changed files with 2497 additions and 2128 deletions
Showing only changes of commit efcca56c99 - Show all commits

View File

@ -1,3 +1,3 @@
Name: Level1Scene
Name: Level1
ID: 96668835
Type: 5

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
Name: MainGame
Name: Level2
ID: 86098106
Type: 5

View File

@ -51,7 +51,10 @@ public class Breakable : Script
{
isBreak = true;
if (GameObject.GetScript<Item>())
{
GameManager.Instance.totalItemCount -= 1;
GameManager.Instance.itemShatter = true;
}
}
}
protected override void onTriggerEnter(CollisionInfo info)
@ -71,6 +74,7 @@ public class Breakable : Script
gO.Parent = GameObject.Null;
}
GameManager.Instance.itemShatter = false;
isBreak = false;
AudioHandler.audioClipHandlers["SFXBreak"].Play();
GameObject.SetActive(false);

View File

@ -28,13 +28,20 @@ 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;
[Tooltip("Height of ray")]
public float rayHeight = 0.1f;
[Tooltip("FOV when you aim")]
public float aimingFOV = 50;
[Tooltip("Default FOV")]
public float defaultFOV = 45;
protected override void awake()
@ -51,6 +58,16 @@ 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 = silhouettePlayer.GetComponent<Renderable>();
AudioHandler.audioClipHandlers["SFXThrow"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_throw");
timer = delayTimer;
@ -62,6 +79,18 @@ public class PickAndThrow : Script
return;
}
if (silhouettePlayerRend && silhouetteBagRend)
{
//wait for daniel
//0.00075f;
/* Vector3 dis = Camera.GetMainCamera().Position - GameObject.GetComponent<Transform>().LocalPosition;
float disSqr = dis.GetSqrMagnitude();
Debug.Log($"DIS :{disSqr}");
float ratio = System.Math.Clamp(1 - (disSqr / (1 + disSqr)), 0, 1.0f);
silhouettePlayerRend.Material.SetProperty<float>("data.offset", ratio * 0.00075f);
silhouetteBagRend.Material.SetProperty<float>("data.offset", ratio * 0.00075f);*/
}
if (timer <= delayTimer)
timer += Time.DeltaTimeF;

View File

@ -41,6 +41,28 @@ public class GameManager : Script
public bool GamePause { get; set; }
public bool itemShatter { get; set; }
protected override void awake()
{
if (Instance != null && Instance != this)
RemoveScript<GameManager>();
else
Instance = this;
totalItemCount = 0;
Score = 0;
currGameState = GameState.START;
itemScored = false;
currMultiplierCombo = 1;
currMultiplierDuration = 0;
fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration);
itemShatter = false;
AudioHandler.audioClipHandlers["BGMWin"] = Audio.CreateAudioClip("event:/Music/stingers/game_win");
AudioHandler.audioClipHandlers["BGMLose"] = Audio.CreateAudioClip("event:/Music/stingers/game_lose");
}
protected override void start()
{
@ -57,31 +79,6 @@ public class GameManager : Script
AudioHandler.audioClipHandlers["SFXHumming"].Play();
}
protected override void awake()
{
if (Instance != null && Instance != this)
RemoveScript<GameManager>();
else
Instance = this;
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
//Audio.PlayBGMOnce2D("event:/Music/player_undetected");
//Audio.PlayBGMOnce2D("event:/Ambience/roomtone_kitchen");
totalItemCount = 0;
Score = 0;
currGameState = GameState.START;
itemScored = false;
currMultiplierCombo = 1;
currMultiplierDuration = 0;
fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration);
AudioHandler.audioClipHandlers["BGMWin"] = Audio.CreateAudioClip("event:/Music/stingers/game_win");
AudioHandler.audioClipHandlers["BGMLose"] = Audio.CreateAudioClip("event:/Music/stingers/game_lose");
}
protected override void update()
{
if (GamePause)
@ -116,24 +113,20 @@ public class GameManager : Script
multiplierText.GetComponent<Transform>().LocalScale = Vector3.Zero;
}
if ((timer > 0 && totalItemCount <= 0) || Input.GetKeyDown(Input.KeyCode.F1))
if ((timer > 0 && totalItemCount <= 0 && !itemShatter) || Input.GetKeyDown(Input.KeyCode.F1))
{
currGameState = GameState.WIN;
//Audio.StopAllSounds(); //Calling this outright breaks audio clip handlers
AudioHandler.stopAllSounds(false);
AudioHandler.audioClipHandlers["BGMWin"].Play();
SceneManager.ChangeScene(winScene);
//Audio.PlaySFXOnce2D("event:/Music/stingers/game_win");
}
else if(timer < 0 || Input.GetKeyDown(Input.KeyCode.F2))
{
currGameState = GameState.LOSE;
//Audio.StopAllSounds();
AudioHandler.stopAllSounds(false);
AudioHandler.audioClipHandlers["BGMLose"].Play();
SceneManager.ChangeScene(loseScene);
//Audio.PlaySFXOnce2D("event:/Music/stingers/game_lose");
}
}

View File

@ -6,6 +6,7 @@
struct MatPropData
{
vec4 color;
float offset;
};
struct GenericData
@ -56,7 +57,7 @@ layout(input_attachment_index = 0, set = 3, binding = 0) uniform subpassInput de
void main()
{
// Sample depth buffer using UV and save it
float currentDepth = subpassLoad (depthBuffer).r;
float currentDepth = subpassLoad (depthBuffer).r + MatProp.data[In2.materialIndex].offset;
// Use depth buffer to check against current fragment's depth. If fragment is behind depth buffer, render fragment.
if (currentDepth > gl_FragCoord.z)