Merge branch 'main' into SP3-2-Physics

This commit is contained in:
Diren D Bharwani 2023-03-20 13:44:11 +08:00
commit 8e7bfa465d
127 changed files with 7879 additions and 1176 deletions

View File

@ -1,4 +1,4 @@
Start in Fullscreen: false
Starting Scene ID: 91478134
Starting Scene ID: 97158628
Window Size: {x: 1920, y: 1080}
Window Title: SHADE Engine

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: Cinematics
ID: 197932678
Type: 11

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,11 +1,11 @@
0 StaticObject 1110000000000000
0 StaticObject 1100000000000000
1 Player 1100000000000000
2 Food 1000000000000000
3 Breakable 1100000000000000
4 ScoringWallCollider 0110000000000000
5 Homeowner 1100000000000000
6 Camera 0010000000000000
7 8 0000000000000000
7 StaticWithCameraCollision 1110000000000000
8 9 0000000000000000
9 10 0000000000000000
10 11 0000000000000000

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 0
Casting Shadows: false
IsActive: true
Scripts: ~
- EID: 1
@ -73,10 +74,10 @@
sceneID: 97158628
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 6
@ -108,10 +109,10 @@
Enabled: true
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 3
@ -152,7 +153,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 450
Name: TransitionCanvas

View File

@ -100,10 +100,10 @@
sceneID: 91947920
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 6
@ -135,10 +135,10 @@
Enabled: true
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 7
@ -168,10 +168,10 @@
Scripts:
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- Type: SHADE_Scripting.UI.ChangeCanvasButton
@ -204,10 +204,10 @@
Scripts:
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- Type: SHADE_Scripting.UI.ChangeCanvasButton
@ -240,10 +240,10 @@
Scripts:
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- Type: SHADE_Scripting.UI.ChangeCanvasButton
@ -276,10 +276,10 @@
Scripts:
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- Type: SHADE_Scripting.UI.ChangeCanvasButton
@ -297,6 +297,7 @@
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 0
Casting Shadows: false
IsActive: true
Scripts: ~
- EID: 3
@ -337,7 +338,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 13
Name: How To Play Canvas
@ -428,10 +429,10 @@
multiImageList: 15
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 17
@ -465,10 +466,10 @@
multiImageList: 15
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 18
@ -501,10 +502,10 @@
canvasToActivate: 0
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 19
@ -575,10 +576,10 @@
canvasToActivate: 0
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 22
@ -1262,10 +1263,10 @@
canvasToActivate: 0
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 49
@ -1371,10 +1372,10 @@
canvasToActivate: 0
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 53

View File

@ -10,6 +10,7 @@
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 0
Casting Shadows: false
IsActive: true
Scripts: ~
- EID: 1
@ -73,10 +74,10 @@
sceneID: 97158628
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 6
@ -108,10 +109,10 @@
Enabled: true
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: Empty
onHoverEnterSound: event:/UI/botton_hover
onHoverExitSound: Empty
onClickSound: event:/UI/mouse_down_element
onReleaseSound: Empty
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 3
@ -152,7 +153,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 450
Name: TransitionCanvas

View File

@ -38,6 +38,7 @@
idleClip: 227450439
runClip: 229125027
pickUpClip: 219605278
controlAniSys: true
- EID: 1
Name: Default
IsActive: true
@ -80,3 +81,4 @@
idleClip: 0
runClip: 0
pickUpClip: 0
controlAniSys: false

View File

@ -13,6 +13,8 @@ namespace SHADE.Test
private AnimationClipAsset runClip;
[SerializeField]
private AnimationClipAsset pickUpClip;
[SerializeField]
private bool controlAniSys = false;
#endregion
#region Components
@ -23,6 +25,10 @@ namespace SHADE.Test
protected override void awake()
{
Animator = GetComponent<Animator>();
Animator.OnClipStartedPlaying.RegisterAction((_) => Debug.Log("Start Playing"));
Animator.OnClipPaused.RegisterAction((_) => Debug.Log("Pause"));
Animator.OnClipFinished.RegisterAction((_) => Debug.Log("Finished"));
}
protected override void update()
@ -34,19 +40,39 @@ namespace SHADE.Test
// Play animations
if (Input.GetKeyUp(Input.KeyCode.Equals))
{
playFunc(fullClip);
if (fullClip)
playFunc(fullClip);
}
else if (Input.GetKeyUp(Input.KeyCode.Alpha1))
{
playFunc(idleClip);
if (idleClip)
playFunc(idleClip);
}
else if (Input.GetKeyUp(Input.KeyCode.Alpha2))
{
playFunc(runClip);
if (runClip)
playFunc(runClip);
}
else if (Input.GetKeyUp(Input.KeyCode.Alpha3))
{
playFunc(pickUpClip);
if (pickUpClip)
playFunc(pickUpClip);
}
// Play and pause
if (controlAniSys && Input.GetKeyUp(Input.KeyCode.Space))
{
AnimationSystem.TimeScale = AnimationSystem.TimeScale > 0.0f ? 0.0f
: AnimationSystem.DefaultTimeScale;
}
if (Input.GetKeyUp(Input.KeyCode.P))
{
if (Animator.IsPlaying)
Animator.Pause();
else
Animator.Play();
}
}
#endregion

View File

@ -110,8 +110,8 @@ public partial class Homeowner1 : BehaviourTree
//These should be somewhere else
//Debug.Log("TESTING");
AudioHandler.audioClipHandlers["BGMUnalert"] = Audio.CreateAudioClip("event:/Music/player_undetected");
AudioHandler.audioClipHandlers["BGMAlert"] = Audio.CreateAudioClip("event:/Music/player_detected");
//AudioHandler.audioClipHandlers["BGMUnalert"] = Audio.CreateAudioClip("event:/Music/player_undetected");
//AudioHandler.audioClipHandlers["BGMAlert"] = Audio.CreateAudioClip("event:/Music/player_detected");
AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive");
AudioHandler.audioClipHandlers["SFXFootstep"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps");
@ -121,7 +121,7 @@ public partial class Homeowner1 : BehaviourTree
AudioHandler.audioClipHandlers["SFXDetectSting"] = Audio.CreateAudioClip("event:/Music/stingers/player_detected");
AudioHandler.audioClipHandlers["SFXHumming"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_humming");
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXHumming"], GameObject.EntityId);
AudioHandler.audioClipHandlers["SFXHumming"].SetVolume(0.15f);
//AudioHandler.audioClipHandlers["SFXHumming"].SetVolume(0.15f);
AudioHandler.audioClipHandlers["SFXHumming"].Play();
if (aiInstance != null && aiInstance != this)

View File

@ -156,7 +156,7 @@ public partial class LeafSearch : BehaviourTreeNode
//Draw a ray, succeed if ray is unobstructed
Vector3 eyePosition = transform.GlobalPosition + eyeOffset;
BoxCollider playerCollider = player.GetValueOrDefault().GetComponent<Collider>().GetCollisionShape<BoxCollider>(0);
Collider playerCollider = player.GetValueOrDefault().GetComponent<Collider>();
if (playerCollider == null)
{
//Debug.Log("Failure: Player has no collider");
@ -167,7 +167,7 @@ public partial class LeafSearch : BehaviourTreeNode
}
//Ray destination to target the centre of the player's collider instead of transform position
//Since transform position is often the raccoon's base and the ray needs to hit somewhere higher to be more reliable
Vector3 rayDestination = plrT.GlobalPosition + plrT.GlobalScale * playerCollider.PositionOffset;
Vector3 rayDestination = plrT.GlobalPosition + plrT.GlobalScale * playerCollider.GetCollisionShape(0).PositionOffset;
Ray sightRay = new Ray(eyePosition, rayDestination - eyePosition);
RaycastHit sightRayHit = Physics.Raycast(sightRay, false, (ushort)65535)[0];
//As of November 2022, RaycastHit contains only the FIRST object hit by

View File

@ -86,12 +86,17 @@ public class Item : Script
if (returnBack && !dontReturn)
{
if (rb)
{
rb.LinearVelocity = Vector3.Zero;
rb.AngularVelocity = Vector3.Zero;
rb.ClearForces();
rb.ClearTorque();
}
if(transform)
transform.LocalPosition = firstPostion;
if (rb)
rb.LinearVelocity = Vector3.Zero;
returnBack = false;
}

View File

@ -3,13 +3,38 @@ using System;
public class PlayerIdleState : BaseState
{
public PlayerIdleState(StateMachine stateMachine) : base(stateMachine)
private bool holdItem;
public PlayerIdleState(StateMachine stateMachine, bool hi) : base(stateMachine)
{
stateName = "Idle State";
holdItem = hi;
}
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
if (PlayerAnimations.Instance)
{
if (!holdItem)
{
if (PlayerAnimations.Instance.playerIdleClip)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
}
}
else
{
if (PlayerAnimations.Instance.playerCarryIdleClip)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
}
}
}
}
public override void update()
{

View File

@ -9,7 +9,7 @@ public class PlayerJumpState : BaseState
}
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
//Debug.Log("jump");
}
public override void update()
{

View File

@ -1,4 +1,5 @@
using SHADE;
using SHADE_Scripting.Audio;
using System;
public class PlayerRunState : BaseState
@ -13,6 +14,13 @@ public class PlayerRunState : BaseState
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
if (PlayerAnimations.Instance && PlayerAnimations.Instance.playerRunClip)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerRunClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerRunClip);
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerRunClip);
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerRunClip);
}
}
public override void update()
{
@ -21,7 +29,7 @@ public class PlayerRunState : BaseState
if (timer > delay)
{
Audio.PlaySFXOnce2D("event:/Raccoon/raccoon_footsteps");
AudioHandler.audioClipHandlers["footsteps"].Play();
timer = 0;
}
}

View File

@ -1,18 +1,44 @@
using SHADE;
using SHADE_Scripting.Audio;
using System;
public class PlayerWalkState : BaseState
{
private float timer;
private float delay = 0.5f;
public PlayerWalkState(StateMachine stateMachine) : base(stateMachine)
private bool holdItem;
public PlayerWalkState(StateMachine stateMachine, bool hi) : base(stateMachine)
{
stateName = "Walk State";
holdItem = hi;
}
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
timer = delay;
if (PlayerAnimations.Instance)
{
if (!holdItem)
{
if (PlayerAnimations.Instance.playerWalkClip)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
}
}
else
{
if (PlayerAnimations.Instance.playerCarryWalkClip)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
}
}
}
}
public override void update()
{
@ -21,7 +47,7 @@ public class PlayerWalkState : BaseState
if (timer > delay)
{
Audio.PlaySFXOnce2D("event:/Raccoon/raccoon_footsteps");
AudioHandler.audioClipHandlers["footsteps"].Play();
timer = 0;
}
}

View File

@ -34,11 +34,6 @@ public class PickAndThrow : Script
[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()
{
pc = GetScript<PlayerController>();
@ -85,7 +80,7 @@ public class PickAndThrow : Script
pc.camArm.ArmLength = aimingLength;
prevTargetOffSet = pc.camArm.TargetOffset;
pc.camArm.TargetOffset = cameraArmOffSet;
pc.cam.FOV = aimingFOV;
pc.cam.FOV = Settings.cameraFOV + 5;
}
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
@ -95,7 +90,7 @@ public class PickAndThrow : Script
itemCollider.GetCollisionShape(0).IsTrigger = false;
pc.isAiming = false;
pc.camArm.TargetOffset = prevTargetOffSet;
pc.cam.FOV = defaultFOV;
pc.cam.FOV = Settings.cameraFOV;
if (tpc)
pc.camArm.ArmLength = tpc.armLength;
pc.holdItem = false;
@ -116,7 +111,7 @@ public class PickAndThrow : Script
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming)
{
pc.isAiming = false;
pc.cam.FOV = defaultFOV;
pc.cam.FOV = Settings.cameraFOV;
pc.camArm.TargetOffset = prevTargetOffSet;
if (tpc)
pc.camArm.ArmLength = tpc.armLength;

View File

@ -0,0 +1,83 @@
using SHADE;
using System;
using System.Collections.Generic;
public class PlayerAnimations : Script
{
#region Raccoon
[SerializeField]
public AnimationClipAsset playerIdleClip; // done
[SerializeField]
public AnimationClipAsset playerWalkClip; // done
[SerializeField]
public AnimationClipAsset playerRunClip; // done
[SerializeField]
public AnimationClipAsset playerPickUpClip;
[SerializeField]
public AnimationClipAsset playerCarryIdleClip; // done
[SerializeField]
public AnimationClipAsset playerCarryWalkClip; // done
[SerializeField]
public AnimationClipAsset playerThrowClip;
[SerializeField]
public AnimationClipAsset playerJumpStartClip;
[SerializeField]
public AnimationClipAsset playerJumpLoopClip;
[SerializeField]
public AnimationClipAsset playerJumpEndClip;
#endregion
#region Animator
public Animator playerAnimator { get; private set; }
public Animator BagAnimator { get; private set; }
public Animator silhoPlayerAnimator { get; private set; }
public Animator silhoBagAnimator { get; private set; }
#endregion
#region silhouette
public GameObject silhouettePlayer;
public GameObject silhouetteBag;
#endregion
public static PlayerAnimations Instance { get; private set; }
protected override void awake()
{
if (Instance != null && Instance != this)
RemoveScript<PlayerAnimations>();
else
Instance = this;
playerAnimator = GetComponent<Animator>();
if (!playerAnimator)
Debug.LogError("Player Animator is MISSING!");
BagAnimator = GetComponentInChildren<Animator>();
if (!BagAnimator)
Debug.LogError("Bag Animator is MISSING!");
if(silhouettePlayer)
silhoPlayerAnimator = silhouettePlayer.GetComponent<Animator>();
else
Debug.LogError("Silho Player is MISSING!");
if (!silhoPlayerAnimator)
Debug.LogError("Silho Player Animator is MISSING!");
if(silhouetteBag)
silhoBagAnimator = silhouetteBag.GetComponent<Animator>();
else
Debug.LogError("Silho bag is MISSING!");
if (!silhoBagAnimator)
Debug.LogError("Silho Player Animator is MISSING!");
}
protected override void onDestroy()
{
if (Instance == this)
Instance = null;
}
}

View File

@ -0,0 +1,3 @@
Name: SC_PlayerAnimations
ID: 159045981
Type: 9

View File

@ -1,6 +1,7 @@
using SHADE;
using System;
using System.Collections.Generic;
using SHADE_Scripting.Audio;
using static Item;
public class PlayerController : Script
@ -32,7 +33,7 @@ public class PlayerController : Script
private float delayTimer = 0.0f;
[Tooltip("The current state fo the raccoon")]
public RaccoonStates currentState = RaccoonStates.IDLE;
public RaccoonStates currentState;
//Movement variables============================================================
[Tooltip("Max vel for walking")]
@ -98,17 +99,17 @@ public class PlayerController : Script
//rigidbody check
rb = GetComponent<RigidBody>();
if (!rb)
Debug.LogError("RigidBody is NULL!");
Debug.LogError("RigidBody is MISSING!");
//Transform check
tranform = GetComponent<Transform>();
if(!tranform)
Debug.LogError("tranform is NULL!");
Debug.LogError("tranform is MISSING!");
stateMachine = AddScript<StateMachine>();
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine));
dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine));
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine, holdItem));
dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine, holdItem));
dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine));
dictionary.Add(typeof(PlayerJumpState), new PlayerJumpState(stateMachine));
dictionary.Add(typeof(PlayerFallState), new PlayerFallState(stateMachine));
@ -131,6 +132,14 @@ public class PlayerController : Script
silhouetteBagRend = silhouetteBag.GetComponent<Renderable>();
silhouetteBagRend.Material.SetProperty<float>("data.offset", 0.1f);
}
AudioHandler.audioClipHandlers["footsteps"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_footsteps");
}
protected override void start()
{
currentState = RaccoonStates.IDLE;
stateMachine.SetState(typeof(PlayerIdleState));
}
protected override void lateUpdate()
@ -167,8 +176,8 @@ public class PlayerController : Script
if (!cam)
{
cam = GetComponentInChildren<Camera>();
if(pat)
cam.FOV = pat.defaultFOV;
if (pat)
cam.FOV = Settings.cameraFOV;
}
if(!camArm)
camArm = GetComponentInChildren<CameraArm>();
@ -315,6 +324,8 @@ public class PlayerController : Script
if ( (Input.GetKeyDown(Input.KeyCode.Space) || landedOnJumpPad ) && isGrounded && rb != null)
{
currentState = RaccoonStates.JUMP;
if (stateMachine && !stateMachine.IsState(typeof(PlayerJumpState)))
stateMachine.SetState(typeof(PlayerJumpState));
Vector3 v = rb.LinearVelocity;
v.y = initialJumpVel * 0.5f;
if (holdItem && pat != null && pat.item.GetScript<Item>() != null)
@ -337,8 +348,12 @@ public class PlayerController : Script
}
}
if(!isGrounded && rb != null && (rb.LinearVelocity.y < 0.0f || Input.GetKeyUp(Input.KeyCode.Space)))
if (!isGrounded && rb != null && (rb.LinearVelocity.y < 0.0f || Input.GetKeyUp(Input.KeyCode.Space)))
{
currentState = RaccoonStates.FALLING;
if (stateMachine && !stateMachine.IsState(typeof(PlayerFallState)))
stateMachine.SetState(typeof(PlayerFallState));
}
}
@ -369,7 +384,11 @@ public class PlayerController : Script
{
isGrounded = true;
if (currentState == RaccoonStates.FALLING)
{
currentState = RaccoonStates.LANDED;
if (stateMachine && !stateMachine.IsState(typeof(PlayerLandState)))
stateMachine.SetState(typeof(PlayerLandState));
}
}
else
isGrounded = false;
@ -417,7 +436,7 @@ public class PlayerController : Script
if (isAiming)
{
isAiming = false;
cam.FOV = pat.defaultFOV;
cam.FOV = Settings.cameraFOV;
camArm.TargetOffset = pat.prevTargetOffSet;
camArm.ArmLength = pat.tpc.armLength;
}

View File

@ -37,6 +37,7 @@ namespace SHADE_Scripting
protected override void start()
{
GetComponent<CameraArm>().ArmLength = armLength;
GetComponent<Camera>().FOV = Settings.cameraFOV;
}
protected override void update()

View File

@ -101,6 +101,8 @@ public class GameManager : Script
protected override void update()
{
if (GamePause || !stealFoodPopUpDone)
{
return;
@ -195,6 +197,13 @@ public class GameManager : Script
if (SceneFadeInOut.Instance != null)
SceneFadeInOut.Instance.CallFadeIn();
}
if (Input.GetKeyUp(Input.KeyCode.G))
{
ItemScored();
Score += 500;
}
}
@ -219,6 +228,13 @@ public class GameManager : Script
fx.ShowMultiplier(currMultiplierCombo, maxMultiplierDuration);
}
SingleScaleBounce sb = scoreText.GetScript<SingleScaleBounce>();
if(sb)
{
sb.ScaleBounceOnce();
}
}
}

View File

@ -2,15 +2,64 @@
using SHADE_Scripting.Audio;
using System;
public class JumpPad : Script
{
private Transform tran;
private Vector3 defaultScale;
public float scaleYMaxSize = 2.0f;
private float scaleXZMaxSize;
public float scaleDuration = 0.25f;
private bool landed = false;
private bool scaleUpDone = false;
[NonSerialized]
private TweenThread scaleYUp;
[NonSerialized]
private TweenThread scaleXZUp;
[NonSerialized]
private TweenThreadVec3 scaleDown;
protected override void awake()
{
AudioHandler.audioClipHandlers["SFXJumpPad"] = Audio.CreateAudioClip("event:/Props/jumppad_boing");
tran = GameObject.GetComponent<Transform>();
if (!tran)
Debug.LogError("NO TRANSFORM");
defaultScale = tran.LocalScale;
scaleXZMaxSize = scaleYMaxSize * 0.3f;
}
protected override void start()
{
scaleYUp = TweenManager.CreateTweenThread(scaleDuration, tran.LocalScale.y, scaleYMaxSize, EASING_METHOD.EASE_IN_SINE);
scaleXZUp = TweenManager.CreateTweenThread(scaleDuration, tran.LocalScale.y, scaleXZMaxSize, EASING_METHOD.EASE_IN_SINE);
}
protected override void update()
{
if (landed && tran)
{
tran.LocalScale = new Vector3(scaleXZUp.GetValue(), scaleYUp.GetValue(), scaleXZUp.GetValue());
if (scaleYUp.IsCompleted() && scaleXZUp.IsCompleted())
{
landed = false;
scaleUpDone = true;
scaleDown = TweenManager.CreateTweenThreadVec3(scaleDuration, tran.LocalScale, defaultScale, EASING_METHOD.EASE_IN_SINE);
}
}
if (scaleUpDone && !landed)
{
tran.LocalScale = scaleDown.GetValue();
if (scaleDown.IsCompleted())
{
scaleUpDone = false;
}
}
}
protected override void onCollisionEnter(CollisionInfo info)
@ -20,7 +69,11 @@ public class JumpPad : Script
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXJumpPad"], GameObject.EntityId);
AudioHandler.audioClipHandlers["SFXJumpPad"].Play();
info.GameObject.GetScript<PlayerController>().landedOnJumpPad = true;
landed = true;
scaleYUp.Reset();
scaleXZUp.Reset();
}
}
}

View File

@ -40,11 +40,6 @@ namespace SHADE_Scripting.UI
if (listOfCamera.Count == 0)
Debug.LogError("EMPTY PREVIEW POINTS");
moveToEndPoint1 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[0].GetComponent<Transform>().LocalPosition, endPoint1, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint2 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[1].GetComponent<Transform>().LocalPosition, endPoint2, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint3 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[2].GetComponent<Transform>().LocalPosition, endPoint3, EASING_METHOD.EASE_IN_SINE);
}
protected override void start()
@ -52,6 +47,11 @@ namespace SHADE_Scripting.UI
if (gameplayCanvas)
gameplayCanvas.SetActive(false);
listOfCamera[0].SetMainCamera();
moveToEndPoint1 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[0].GetComponent<Transform>().LocalPosition, endPoint1, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint2 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[1].GetComponent<Transform>().LocalPosition, endPoint2, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint3 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[2].GetComponent<Transform>().LocalPosition, endPoint3, EASING_METHOD.EASE_IN_SINE);
}
protected override void update()
@ -135,7 +135,7 @@ namespace SHADE_Scripting.UI
{
if (reset3)
{
moveToEndPoint3 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[2].GetComponent<Transform>().LocalPosition, endPoint3, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint3.Reset();
reset3 = false;
}
listOfCamera[2].GetComponent<Transform>().LocalPosition = moveToEndPoint3.GetValue();

View File

@ -4,18 +4,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting
static public class Settings
{
static public class Settings
{
static public float cameraSensitivity = 100.0f;
static public float cameraSensitivity = 100.0f;
static public float cameraFOV = 90.0f;
static public float cameraFOV = 45.0f;
static public float masterVolume = 100.0f;
static public float sfxVolume = 100.0f;
static public float bgmVolume = 100.0f;
}
static public float masterVolume = 100.0f;
static public float sfxVolume = 100.0f;
static public float bgmVolume = 100.0f;
}

View File

@ -4,9 +4,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public enum EASING_METHOD
{
EASE_IN_SINE,
@ -16,84 +13,88 @@ namespace SHADE_Scripting.UI
EASE_INOUT_BOUNCE
}
public static class EasingHelper
public static class EasingHelper
{
public static float EaseHelp(float value, EASING_METHOD method)
{
switch (method)
{
public static float EaseHelp(float value, EASING_METHOD method)
case EASING_METHOD.EASE_IN_SINE:
{
switch (method)
{
case EASING_METHOD.EASE_IN_SINE:
{
return EaseInSine(value);
}break;
case EASING_METHOD.EASE_OUT_SINE:
{
return EaseOutSine(value);
}break;
case EASING_METHOD.EASE_OUT_BOUNCE:
{
return EaseOutBounce(value);
}break;
case EASING_METHOD.EASE_IN_BOUNCE:
{
return EaseInBounce(value);
}
break;
case EASING_METHOD.EASE_INOUT_BOUNCE:
{
return EaseInOutBounce(value);
}
break;
default:
return 0.0f;
}
return EaseInSine(value);
}
private static float EaseInSine(float value)
break;
case EASING_METHOD.EASE_OUT_SINE:
{
return (float)(1.0f - Math.Cos((value * Math.PI / 2.0f) ));
return EaseOutSine(value);
}
private static float EaseOutSine(float value)
break;
case EASING_METHOD.EASE_OUT_BOUNCE:
{
return (float)(Math.Sin(value * Math.PI / 2.0f) );
return EaseOutBounce(value);
}
private static float EaseOutBounce(float value)
break;
case EASING_METHOD.EASE_IN_BOUNCE:
{
const float n1 = 7.5625f;
const float d1 = 2.75f;
if (value < 1.0f / d1)
{
return n1 * value * value;
} else if (value < 2.0f / d1)
{
return n1 * (value -= 2.25f / d1) * value + 0.9375f;
}
else
{
return n1 * (value -= 2.625f / d1) * value + 0.984375f;
}
return EaseInBounce(value);
}
private static float EaseInBounce(float value)
break;
case EASING_METHOD.EASE_INOUT_BOUNCE:
{
return 1 - EaseOutBounce(1 - value);
return EaseInOutBounce(value);
}
break;
default:
return 0.0f;
}
}
private static float EaseInSine(float value)
{
return (float)(1.0f - Math.Cos((value * Math.PI / 2.0f)));
}
private static float EaseOutSine(float value)
{
return (float)(Math.Sin(value * Math.PI / 2.0f));
}
private static float EaseInOutBounce(float value)
{
return (value < 0.5f)
?(1.0f - EaseOutBounce(1.0f - 2.0f * value)) / 2.0f
: (1.0f + EaseOutBounce(2.0f * value - 1.0f)) / 2.0f;
}
private static float EaseOutBounce(float value)
{
const float n1 = 7.5625f;
const float d1 = 2.75f;
if (value < 1.0f / d1)
{
return n1 * value * value;
}
else if (value < 2.0f / d1)
{
return n1 * (value -= 2.25f / d1) * value + 0.9375f;
}
else
{
return n1 * (value -= 2.625f / d1) * value + 0.984375f;
}
}
private static float EaseInBounce(float value)
{
return 1 - EaseOutBounce(1 - value);
}
private static float EaseInOutBounce(float value)
{
return (value < 0.5f)
? (1.0f - EaseOutBounce(1.0f - 2.0f * value)) / 2.0f
: (1.0f + EaseOutBounce(2.0f * value - 1.0f)) / 2.0f;
}
}

View File

@ -9,10 +9,10 @@ namespace SHADE_Scripting.UI
{
public class ButtonFX:Script
{
public string onHoverEnterSound = "Empty";
public string onHoverEnterSound = "event:/UI/botton_hover";
public string onHoverExitSound = "Empty";
public string onClickSound = "event:/UI/mouse_down_element";
public string onReleaseSound = "Empty";
public string onClickSound = "event:/UI/button_success";
public string onReleaseSound = "event:/UI/button_fail";
[NonSerialized]
private AudioClipHandler onHoverEnterACHandler;

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using SHADE;
using SHADE_Scripting.Audio;
public class CutsceneEnd : Script
{
@ -58,6 +58,17 @@ public class CutsceneEnd : Script
{
initCutscene4();
initCutscene5();
AudioHandler.audioClipHandlers["cutsceneBGM"] = Audio.CreateAudioClip("event:/Cinematics/BGM");
AudioHandler.audioClipHandlers["cutscenePanelSlide"] = Audio.CreateAudioClip("event:/Cinematics/panel_slide");
//Cutscene 4 Audio
AudioHandler.audioClipHandlers["cutscene4Run"] = Audio.CreateAudioClip("event:/Cinematics/4/1_run");
//Cutscene 5 Audio
AudioHandler.audioClipHandlers["cutscene5Yay"] = Audio.CreateAudioClip("event:/Cinematics/5/2_yay");
AudioHandler.audioClipHandlers["cutsceneBGM"].Play();
}
protected override void update()
@ -70,6 +81,11 @@ public class CutsceneEnd : Script
skip = true;
oldDuration = duration;
duration = skipDuration;
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Stop(true);
AudioHandler.audioClipHandlers["cutscene4Run"].Stop(true);
AudioHandler.audioClipHandlers["cutscene5Yay"].Stop(true);
}
if (Input.GetKeyUp(Input.KeyCode.Space) && cutscene4Done && canvas4.IsActiveSelf)
@ -90,6 +106,11 @@ public class CutsceneEnd : Script
{
if (canvas4.IsActiveSelf)
{
if(time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene4Run"].Play();
}
if (showPic4a)
{
if (time < duration)
@ -116,6 +137,10 @@ public class CutsceneEnd : Script
if (showPic4b)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
}
if (time < duration)
{
pic4bTran.LocalPosition = Vector3.Lerp(pic4bTran.LocalPosition, listOfCutscene4Points[1].LocalPosition, time / duration);
@ -140,6 +165,10 @@ public class CutsceneEnd : Script
if (showPic4c)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
}
if (time < duration)
{
pic4cTran.LocalPosition = Vector3.Lerp(pic4cTran.LocalPosition, listOfCutscene4Points[2].LocalPosition, time / duration);
@ -171,6 +200,10 @@ public class CutsceneEnd : Script
{
if (showPic5a)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
}
if (time < duration)
{
pic5aTran.LocalPosition = Vector3.Lerp(pic5aTran.LocalPosition, listOfCutscene5Points[0].LocalPosition, time / duration);
@ -195,6 +228,11 @@ public class CutsceneEnd : Script
if (showPic5b)
{
if (time == 0)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene5Yay"].Play();
}
if (time < duration)
{
pic5bTran.LocalPosition = Vector3.Lerp(pic5bTran.LocalPosition, listOfCutscene5Points[1].LocalPosition, time / duration);

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using SHADE;
using SHADE_Scripting.Audio;
public class CutsceneIntro : Script
{
@ -87,6 +87,24 @@ public class CutsceneIntro : Script
initCutscene1();
initCutscene2();
initCutscene3();
//Cutscene BGM
AudioHandler.audioClipHandlers["cutsceneBGM"] = Audio.CreateAudioClip("event:/Cinematics/BGM");
AudioHandler.audioClipHandlers["cutscenePanelSlide"] = Audio.CreateAudioClip("event:/Cinematics/panel_slide");
//Cutscene 2 Audio
AudioHandler.audioClipHandlers["cutscene2Stomach"] = Audio.CreateAudioClip("event:/Cinematics/2/1_stomach");
AudioHandler.audioClipHandlers["cutscene2Alert"] = Audio.CreateAudioClip("event:/Cinematics/2/2_alert");
AudioHandler.audioClipHandlers["cutscene2Sparkle"] = Audio.CreateAudioClip("event:/Cinematics/2/3_sparkle");
//Cutscene 3 Audio
AudioHandler.audioClipHandlers["cutscene3Jump"] = Audio.CreateAudioClip("event:/Cinematics/3/1_jump");
AudioHandler.audioClipHandlers["cutscene3Sparkle"] = Audio.CreateAudioClip("event:/Cinematics/3/2_sparkle");
AudioHandler.audioClipHandlers["cutscene3Carry"] = Audio.CreateAudioClip("event:/Cinematics/3/3_carry");
AudioHandler.audioClipHandlers["cutscene3Throw"] = Audio.CreateAudioClip("event:/Cinematics/3/4_throw");
AudioHandler.audioClipHandlers["cutscene3Yay"] = Audio.CreateAudioClip("event:/Cinematics/3/5_yay");
AudioHandler.audioClipHandlers["cutsceneBGM"].Play();
}
protected override void update()
@ -98,6 +116,16 @@ public class CutsceneIntro : Script
if (Input.GetKeyUp(Input.KeyCode.Space) && !skip && (!cutscene1Done || !cutscene2Done || !cutscene3Done))
{
skip = true;
AudioHandler.audioClipHandlers["cutscene2Stomach"].Stop(true);
AudioHandler.audioClipHandlers["cutscene2Alert"].Stop(true);
AudioHandler.audioClipHandlers["cutscene2Sparkle"].Stop(true);
AudioHandler.audioClipHandlers["cutscene3Jump"].Stop(true);
AudioHandler.audioClipHandlers["cutscene3Sparkle"].Stop(true);
AudioHandler.audioClipHandlers["cutscene3Carry"].Stop(true);
AudioHandler.audioClipHandlers["cutscene3Throw"].Stop(true);
AudioHandler.audioClipHandlers["cutscene3Yay"].Stop(true);
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Stop(true);
oldDuration = duration;
duration = skipDuration;
}
@ -128,6 +156,10 @@ public class CutsceneIntro : Script
{
if (canvas1.IsActiveSelf)
{
if(time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
}
if (showPic1a)
{
if (time < duration)
@ -154,6 +186,10 @@ public class CutsceneIntro : Script
if (showPic1b)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
}
if (time < duration)
{
pic1bTran.LocalPosition = Vector3.Lerp(pic1bTran.LocalPosition, listOfCutscene1Points[1].LocalPosition, time / duration);
@ -178,6 +214,10 @@ public class CutsceneIntro : Script
if (showPic1c)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
}
if (time < duration)
{
pic1cTran.LocalPosition = Vector3.Lerp(pic1cTran.LocalPosition, listOfCutscene1Points[2].LocalPosition, time / duration);
@ -209,6 +249,11 @@ public class CutsceneIntro : Script
{
if (showPic2a)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene2Stomach"].Play();
}
if (time < duration)
{
pic2aTran.LocalPosition = Vector3.Lerp(pic2aTran.LocalPosition, listOfCutscene2Points[0].LocalPosition, time / duration);
@ -233,6 +278,11 @@ public class CutsceneIntro : Script
if (showPic2b)
{
if(time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene2Alert"].Play();
}
if (time < duration)
{
pic2bTran.LocalPosition = Vector3.Lerp(pic2bTran.LocalPosition, listOfCutscene2Points[1].LocalPosition, time / duration);
@ -257,6 +307,11 @@ public class CutsceneIntro : Script
if (showPic2c)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene2Sparkle"].Play();
}
if (time < duration)
{
pic2cTran.LocalPosition = Vector3.Lerp(pic2cTran.LocalPosition, listOfCutscene2Points[2].LocalPosition, time / duration);
@ -288,6 +343,11 @@ public class CutsceneIntro : Script
{
if (showPic3a)
{
if(time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene3Jump"].Play();
}
if (time < duration)
{
pic3aTran.LocalPosition = Vector3.Lerp(pic3aTran.LocalPosition, listOfCutscene3Points[0].LocalPosition, time / duration);
@ -312,6 +372,11 @@ public class CutsceneIntro : Script
if (showPic3b)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene3Sparkle"].Play();
}
if (time < duration)
{
pic3bTran.LocalPosition = Vector3.Lerp(pic3bTran.LocalPosition, listOfCutscene3Points[1].LocalPosition, time / duration);
@ -336,6 +401,11 @@ public class CutsceneIntro : Script
if (showPic3c)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene3Carry"].Play();
}
if (time < duration)
{
pic3cTran.LocalPosition = Vector3.Lerp(pic3cTran.LocalPosition, listOfCutscene3Points[2].LocalPosition, time / duration);
@ -360,6 +430,11 @@ public class CutsceneIntro : Script
if (showPic3d)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene3Throw"].Play();
}
if (time < duration)
{
pic3dTran.LocalPosition = Vector3.Lerp(pic3dTran.LocalPosition, listOfCutscene3Points[3].LocalPosition, time / duration);
@ -384,6 +459,11 @@ public class CutsceneIntro : Script
if (showPic3e)
{
if (time == 0 && !skip)
{
AudioHandler.audioClipHandlers["cutscenePanelSlide"].Play();
AudioHandler.audioClipHandlers["cutscene3Yay"].Play();
}
if (time < duration)
{
pic3eTran.LocalPosition = Vector3.Lerp(pic3eTran.LocalPosition, listOfCutscene3Points[4].LocalPosition, time / duration);

View File

@ -10,8 +10,8 @@ public class EndScene : Script
protected override void awake()
{
AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");
//AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element");
//AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");
}
protected override void start()
@ -27,28 +27,28 @@ public class EndScene : Script
if (Input.GetKeyDown(Input.KeyCode.R))
{
//Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXMouseDownElement"].Play();
//AudioHandler.audioClipHandlers["SFXMouseDownElement"].Play();
}
if (Input.GetKeyUp(Input.KeyCode.R))
{
//Audio.PlaySFXOnce2D("event:/UI/success");
//Audio.StopAllSounds();
AudioHandler.StopAllSounds(false);
AudioHandler.audioClipHandlers["SFXUISuccess"].Play();
//AudioHandler.audioClipHandlers["SFXUISuccess"].Play();
SceneManager.ChangeScene(mainGameScene);
}
if (Input.GetKeyDown(Input.KeyCode.M))
{
//Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXMouseDownElement"].Play();
//AudioHandler.audioClipHandlers["SFXMouseDownElement"].Play();
}
if (Input.GetKeyUp(Input.KeyCode.M))
{
//Audio.PlaySFXOnce2D("event:/UI/success");
//Audio.StopAllSounds();
AudioHandler.StopAllSounds(false);
AudioHandler.audioClipHandlers["SFXUISuccess"].Play();
//AudioHandler.audioClipHandlers["SFXUISuccess"].Play();
SceneManager.ChangeScene(mainMainScene);
}

View File

@ -13,8 +13,8 @@ public class MainMenu : Script
protected override void awake()
{
AudioHandler.audioClipHandlers["BGMMainMenu"] = Audio.CreateAudioClip("event:/Music/main_menu");
AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");
//AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element");
//AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");
//Audio.PlayBGMOnce2D("event:/Music/main_menu");
AudioHandler.audioClipHandlers["BGMMainMenu"].Play();

View File

@ -7,89 +7,92 @@ using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public class Options:Script
public class Options : Script
{
public GameObject masterVolSlider;
public GameObject sfxVolSlider;
public GameObject bgmVolSlider;
public GameObject fovSlider;
public GameObject sensitivitySlider;
protected override void awake()
{
public GameObject masterVolSlider;
public GameObject sfxVolSlider;
public GameObject bgmVolSlider;
public GameObject fovSlider;
public GameObject sensitivitySlider;
Slider mv = masterVolSlider.GetComponent<Slider>();
Slider sfx = sfxVolSlider.GetComponent<Slider>();
Slider bgm = bgmVolSlider.GetComponent<Slider>();
Slider fov = fovSlider.GetComponent<Slider>();
Slider sens = sensitivitySlider.GetComponent<Slider>();
if (mv != null)
{
mv.ScaledValue = Settings.masterVolume;
}
if (sfx != null)
{
sfx.ScaledValue = Settings.sfxVolume;
protected override void awake()
{
Slider mv = masterVolSlider.GetComponent<Slider>();
Slider sfx = sfxVolSlider.GetComponent<Slider>();
Slider bgm = bgmVolSlider.GetComponent<Slider>();
Slider fov = fovSlider.GetComponent<Slider>();
Slider sens = sensitivitySlider.GetComponent<Slider>();
}
if (bgm != null)
{
bgm.ScaledValue = Settings.bgmVolume;
}
if (fov != null)
{
fov.ScaledValue = Settings.cameraFOV;
}
if (sens != null)
{
sens.ScaledValue = Settings.cameraSensitivity;
if (mv != null)
{
mv.ScaledValue = Settings.masterVolume;
}
if (sfx != null)
{
sfx.ScaledValue = Settings.sfxVolume;
}
if (bgm != null)
{
bgm.ScaledValue = Settings.bgmVolume;
}
if (fov != null)
{
fov.ScaledValue = Settings.cameraFOV;
}
if (sens != null)
{
sens.ScaledValue = Settings.cameraSensitivity;
}
}
protected override void update()
{
Slider mv = masterVolSlider.GetComponent<Slider>();
Slider sfx = sfxVolSlider.GetComponent<Slider>();
Slider bgm = bgmVolSlider.GetComponent<Slider>();
Slider fov = fovSlider.GetComponent<Slider>();
Slider sens = sensitivitySlider.GetComponent<Slider>();
if(mv != null)
{
Settings.masterVolume = mv.ScaledValue;
}
if (sfx != null)
{
Settings.sfxVolume = sfx.ScaledValue;
}
if (bgm != null)
{
Settings.bgmVolume = bgm.ScaledValue;
}
if (fov != null)
{
Settings.cameraFOV = fov.ScaledValue;
}
if (sens != null)
{
Settings.cameraSensitivity = sens.ScaledValue;
}
}
}
}
protected override void update()
{
Slider mv = masterVolSlider.GetComponent<Slider>();
Slider sfx = sfxVolSlider.GetComponent<Slider>();
Slider bgm = bgmVolSlider.GetComponent<Slider>();
Slider fov = fovSlider.GetComponent<Slider>();
Slider sens = sensitivitySlider.GetComponent<Slider>();
if (mv != null)
{
Settings.masterVolume = mv.ScaledValue;
SHADE.Audio.SetVCAVolume("vca:/MASTER", Settings.masterVolume * 0.01f);
}
if (sfx != null)
{
Settings.sfxVolume = sfx.ScaledValue;
SHADE.Audio.SetVCAVolume("vca:/SFX", Settings.sfxVolume * 0.01f);
SHADE.Audio.SetVCAVolume("vca:/UI", Settings.sfxVolume * 0.01f);
}
if (bgm != null)
{
Settings.bgmVolume = bgm.ScaledValue;
SHADE.Audio.SetVCAVolume("vca:/MUSIC", Settings.bgmVolume * 0.01f);
}
if (fov != null)
{
Settings.cameraFOV = fov.ScaledValue;
}
if (sens != null)
{
Settings.cameraSensitivity = sens.ScaledValue;
}
}
}
}

View File

@ -50,6 +50,7 @@ public class PauseMenu : Script
if (canvas)
canvas.SetActive(false);
Application.FixDeltaTime = Time.DefaultFixDeltaTime;
AnimationSystem.TimeScale = AnimationSystem.DefaultTimeScale;
}
});
}
@ -69,6 +70,8 @@ public class PauseMenu : Script
GameManager.Instance.GamePause = false;
GameManager.Instance.stealFoodPopUpDone = false;
GameManager.Instance.PreviewLevelDone = false;
Application.FixDeltaTime = Time.DefaultFixDeltaTime;
AnimationSystem.TimeScale = AnimationSystem.DefaultTimeScale;
});
}
else
@ -82,6 +85,8 @@ public class PauseMenu : Script
quit.OnRelease.RegisterAction(() =>
{
Audio.StopAllSounds();
Application.FixDeltaTime = Time.DefaultFixDeltaTime;
AnimationSystem.TimeScale = AnimationSystem.DefaultTimeScale;
//go to main menu
SceneManager.ChangeScene(97158628);
});
@ -106,6 +111,7 @@ public class PauseMenu : Script
if (canvas)
canvas.SetActive(true);
Application.FixDeltaTime = 0;
AnimationSystem.TimeScale = 0;
}
}

View File

@ -0,0 +1,42 @@
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public class ScoreTextDigitPositioning:Script
{
[NonSerialized]
Vector3 defaultPosition;
public float offsetPerDigit = 0.0f;
protected override void awake()
{
Transform trans = GetComponent<Transform>();
if(trans)
{
defaultPosition = trans.LocalPosition;
}
}
protected override void update()
{
TextRenderable text = GetComponent<TextRenderable>();
Transform trans = GetComponent<Transform>();
if (trans && text)
{
String str = text.Text;
Vector3 offset = new Vector3((str.Length - 1) * offsetPerDigit, 0.0f, 0.0f);
trans.LocalPosition = defaultPosition - offset;
}
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_ScoreTextDigitPositioning
ID: 166859312
Type: 9

View File

@ -0,0 +1,73 @@
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public class SingleScaleBounce: Script
{
[NonSerialized]
TweenThread thread;
[NonSerialized]
Vector3 defaultScale;
public float durationUp = 0.15f;
public float durationDown = 0.3f;
public float scaleSize = 1.2f;
[NonSerialized]
private bool scaleUp = false;
protected override void awake()
{
Transform trans = GetComponent<Transform>();
if(trans != null)
{
defaultScale = trans.LocalScale;
}
}
protected override void start()
{
thread = TweenManager.CreateTweenThread(0.0f,1.0f,1.0f,EASING_METHOD.EASE_IN_SINE);
}
protected override void update()
{
if(scaleUp)
{
if(thread.IsCompleted())
{
scaleUp = false;
thread.duration = durationDown;
thread.ResetInvert();
}
}
Transform trans = GetComponent<Transform>();
if(trans != null)
{
trans.LocalScale = defaultScale * thread.GetValue();
}
}
public void ScaleBounceOnce()
{
scaleUp = true;
thread.duration = durationUp;
thread.Reset(1.0f, scaleSize);
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_SingleScaleBounce
ID: 151165363
Type: 9

View File

@ -53,13 +53,16 @@ namespace SHADE_Scripting.UI
{
if (!GameManager.Instance.PreviewLevelDone)
{
rot.Reset();
scaleX.Reset();
scaleY.Reset();
if (rot != null && scaleX != null && scaleY != null)
{
rot.Reset();
scaleX.Reset();
scaleY.Reset();
}
return;
}
if (!popInDone)
if (!popInDone && rot != null && scaleX != null && scaleY != null)
{
tran.LocalEulerAngles = new Vector3(0.0f, 0.0f, SHADE.Math.DegreesToRadians(rot.GetValue()));
tran.LocalScale = new Vector3(scaleX.GetValue(), scaleY.GetValue(), 1);
@ -71,7 +74,7 @@ namespace SHADE_Scripting.UI
stayDone = true;
}
if (rot.IsCompleted() && scaleX.IsCompleted() && scaleY.IsCompleted())
if (rot != null && scaleX != null && scaleY != null && rot.IsCompleted() && scaleX.IsCompleted() && scaleY.IsCompleted())
popInDone = true;
if (stayDone)
@ -82,8 +85,11 @@ namespace SHADE_Scripting.UI
scaleOutY = TweenManager.CreateTweenThread(popOutDuration, scaleAmtY, 0, EASING_METHOD.EASE_IN_SINE);
createThreadOnce = false;
}
tran.LocalScale = new Vector3(scaleOutX.GetValue(), scaleOutY.GetValue(), 1);
if (scaleOutX.IsCompleted() && scaleOutY.IsCompleted())
if(scaleOutX != null && scaleOutY != null)
tran.LocalScale = new Vector3(scaleOutX.GetValue(), scaleOutY.GetValue(), 1);
if (scaleOutX != null && scaleOutY != null && scaleOutX.IsCompleted() && scaleOutY.IsCompleted())
{
GameObject.SetActive(false);
GameManager.Instance.stealFoodPopUpDone = true;

View File

@ -4,190 +4,182 @@ using System;
using System.Collections.Generic;
using System.Threading;
namespace SHADE_Scripting.UI
public class TweenThread
{
private float timer = 0.0f;
public float duration = 1.0f;
public EASING_METHOD method;
private float value = 0.0f;
public float startValue = 0.0f;
public float endValue = 1.0f;
public TweenThread(float duration, float startValue, float endValue, EASING_METHOD method)
{
this.duration = duration;
this.method = method;
this.startValue = startValue;
this.endValue = endValue;
}
public void Update(float deltaTime)
{
if (timer >= duration)
return;
timer += deltaTime;
if (timer >= duration)
timer = duration;
value = EasingHelper.EaseHelp(timer / duration, method) * (endValue - startValue) + startValue;
}
public bool IsCompleted()
{
return timer >= duration;
}
public void Reset()
{
timer = 0.0f;
value = startValue;
}
public void Reset(float startValue, float endValue)
{
Reset();
this.startValue = startValue;
this.endValue = endValue;
}
public void ResetInvert()
{
Reset();
float temp = startValue;
startValue = endValue;
endValue = temp;
}
public float GetValue()
{
return value;
}
}
public class TweenThreadVec3
{
private float timer = 0.0f;
public float duration = 1.0f;
public EASING_METHOD method;
private Vector3 value = Vector3.Zero;
public Vector3 startValue = Vector3.Zero;
public Vector3 endValue = Vector3.Zero;
public TweenThreadVec3(float duration, Vector3 startValue, Vector3 endValue, EASING_METHOD method)
{
this.duration = duration;
this.method = method;
this.startValue = startValue;
this.endValue = endValue;
}
public void Update(float deltaTime)
{
if (timer >= duration)
return;
timer += deltaTime;
if (timer >= duration)
timer = duration;
value = (endValue - startValue) * EasingHelper.EaseHelp(timer / duration, method) + startValue;
}
public bool IsCompleted()
{
return timer >= duration;
}
public void Reset()
{
timer = 0.0f;
value = startValue;
}
public void Reset(Vector3 startValue, Vector3 endValue)
{
Reset();
this.startValue = startValue;
this.endValue = endValue;
}
public void ResetInvert()
{
Reset();
Vector3 temp = startValue;
startValue = endValue;
endValue = temp;
}
public Vector3 GetValue()
{
return value;
}
}
public class TweenManager : Script
{
public static TweenManager Instance { get; private set; }
[NonSerialized]
private List<TweenThread> threadList;
[NonSerialized]
private List<TweenThreadVec3> threadVec3List;
protected override void awake()
{
if (Instance != null && Instance != this)
RemoveScript<TweenManager>();
else
Instance = this;
threadList = new List<TweenThread>();
threadVec3List = new List<TweenThreadVec3>();
}
protected override void onDestroy()
{
if (Instance == this)
Instance = null;
}
protected override void update()
{
foreach (TweenThread thread in threadList)
{
thread.Update(Time.DeltaTimeF);
}
foreach (TweenThreadVec3 thread in threadVec3List)
{
thread.Update(Time.DeltaTimeF);
}
}
public static TweenThread CreateTweenThread(float duration, float startValue, float endValue, EASING_METHOD method)
{
if (Instance == null)
return null;
TweenThread thread = new TweenThread(duration, startValue, endValue, method);
Instance.threadList.Add(thread);
thread.Reset();
return thread;
}
public static TweenThreadVec3 CreateTweenThreadVec3(float duration, Vector3 startValue, Vector3 endValue, EASING_METHOD method)
{
if (Instance == null)
return null;
TweenThreadVec3 thread = new TweenThreadVec3(duration, startValue, endValue, method);
Instance.threadVec3List.Add(thread);
thread.Reset();
return thread;
}
public class TweenThread
{
private float timer = 0.0f;
public float duration = 1.0f;
public EASING_METHOD method;
private float value = 0.0f;
public float startValue = 0.0f;
public float endValue = 1.0f;
public TweenThread(float duration, float startValue, float endValue, EASING_METHOD method)
{
this.duration = duration;
this.method = method;
this.startValue = startValue;
this.endValue = endValue;
}
public void Update(float deltaTime)
{
if (timer >= duration)
return;
timer += deltaTime;
if (timer >= duration)
timer = duration;
value = EasingHelper.EaseHelp(timer/duration, method) * (endValue - startValue) + startValue ;
}
public bool IsCompleted()
{
return timer >= duration;
}
public void Reset()
{
timer = 0.0f;
value = startValue;
}
public void Reset(float startValue, float endValue)
{
Reset();
this.startValue = startValue;
this.endValue = endValue;
}
public void ResetInvert()
{
Reset();
float temp = startValue;
startValue = endValue;
endValue = temp;
}
public float GetValue()
{
return value;
}
}
public class TweenThreadVec3
{
private float timer = 0.0f;
public float duration = 1.0f;
public EASING_METHOD method;
private Vector3 value = Vector3.Zero;
public Vector3 startValue = Vector3.Zero;
public Vector3 endValue = Vector3.Zero;
public TweenThreadVec3(float duration, Vector3 startValue, Vector3 endValue, EASING_METHOD method)
{
this.duration = duration;
this.method = method;
this.startValue = startValue;
this.endValue = endValue;
}
public void Update(float deltaTime)
{
if (timer >= duration)
return;
timer += deltaTime;
if (timer >= duration)
timer = duration;
value = (endValue - startValue) * EasingHelper.EaseHelp(timer / duration, method) + startValue;
}
public bool IsCompleted()
{
return timer >= duration;
}
public void Reset()
{
timer = 0.0f;
value = startValue;
}
public void Reset(Vector3 startValue, Vector3 endValue)
{
Reset();
this.startValue = startValue;
this.endValue = endValue;
}
public void ResetInvert()
{
Reset();
Vector3 temp = startValue;
startValue = endValue;
endValue = temp;
}
public Vector3 GetValue()
{
return value;
}
}
public class TweenManager : Script
{
public static TweenManager Instance { get; private set; }
[NonSerialized]
private List<TweenThread> threadList;
[NonSerialized]
private List<TweenThreadVec3> threadVec3List;
protected override void awake()
{
if (Instance != null && Instance != this)
RemoveScript<TweenManager>();
else
Instance = this;
threadList = new List<TweenThread>();
threadVec3List = new List<TweenThreadVec3>();
}
protected override void onDestroy()
{
if (Instance == this)
Instance = null;
}
protected override void update()
{
foreach (TweenThread thread in threadList)
{
thread.Update(Time.DeltaTimeF);
}
foreach (TweenThreadVec3 thread in threadVec3List)
{
thread.Update(Time.DeltaTimeF);
}
}
public static TweenThread CreateTweenThread(float duration, float startValue, float endValue, EASING_METHOD method)
{
if (Instance == null)
return null;
TweenThread thread = new TweenThread(duration, startValue, endValue, method);
Instance.threadList.Add(thread);
thread.Reset();
return thread;
}
public static TweenThreadVec3 CreateTweenThreadVec3(float duration, Vector3 startValue, Vector3 endValue, EASING_METHOD method)
{
if (Instance == null)
return null;
TweenThreadVec3 thread = new TweenThreadVec3(duration, startValue, endValue, method);
Instance.threadVec3List.Add(thread);
thread.Reset();
return thread;
}
}
}

View File

@ -15,17 +15,14 @@ public abstract class BaseState
}
public virtual void OnEnter()
{
}
{}
public abstract void update();
public abstract void fixedUpdate();
public virtual void OnExit()
{
}
{}
public string GetStateName()
{
@ -37,11 +34,6 @@ public abstract class BaseState
return animationName;
}
public virtual float GetAnimPercent()
{
return 1.0f;
}
public virtual void onCollisionEnter(CollisionInfo info)
{
}

View File

@ -0,0 +1,37 @@
#version 450
#extension GL_KHR_vulkan_glsl : enable
//#include "ShaderDescriptorDefinitions.glsl"
layout(location = 0) in vec3 aVertexPos;
layout(location = 4) in mat4 worldTransform;
layout(location = 9) in uvec4 aBoneIndices;
layout(location = 10) in vec4 aBoneWeights;
layout(location = 11) in uint firstBoneIndex;
layout(set = 1, binding = 0) uniform CameraData
{
vec4 position;
mat4 vpMat;
mat4 viewMat;
mat4 projMat;
} cameraData;
layout (std430, set = 2, binding = 1) buffer AnimBoneMatrices
{
mat4 data[];
} BoneMatrices;
void main()
{
// // Compute bone matrix
mat4 boneMatrix = BoneMatrices.data[firstBoneIndex + aBoneIndices[0]] * aBoneWeights[0];
boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[1]] * aBoneWeights[1];
boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[2]] * aBoneWeights[2];
boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[3]] * aBoneWeights[3];
// clip space for rendering
// gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
gl_Position = cameraData.vpMat * worldTransform * boneMatrix * vec4 (aVertexPos, 1.0f);
}

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: ShadowMapAnim_VS
ID: 39393999
Type: 2

View File

@ -7,9 +7,6 @@ layout(location = 2) in vec3 aNormal;
layout(location = 3) in vec3 aTangent;
layout(location = 4) in mat4 worldTransform;
layout(location = 8) in uvec2 integerData;
layout(location = 9) in uvec4 aBoneIndices;
layout(location = 10) in vec4 aBoneWeights;
layout(location = 11) in uint firstBoneIndex;
layout(location = 0) out struct
{

View File

@ -40,6 +40,12 @@ layout(set = 1, binding = 0) uniform CameraData
mat4 projMat;
} cameraData;
layout (std430, set = 2, binding = 1) buffer AnimBoneMatrices
{
mat4 data[];
} BoneMatrices;
void main()
{
Out2.materialIndex = gl_InstanceIndex;
@ -63,6 +69,13 @@ void main()
Out.normal.rgb = transposeInv * aNormal.rgb;
Out.normal.rgb = normalize (Out.normal.rgb);
// Compute bone matrix
mat4 boneMatrix = BoneMatrices.data[firstBoneIndex + aBoneIndices[0]] * aBoneWeights[0];
boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[1]] * aBoneWeights[1];
boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[2]] * aBoneWeights[2];
boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[3]] * aBoneWeights[3];
// clip space for rendering
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
gl_Position = cameraData.vpMat * worldTransform * boneMatrix * vec4 (aVertexPos, 1.0f);
// gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
}

View File

@ -0,0 +1,3 @@
Name: Button_Resume_Clicked
ID: 66776217
Type: 3

View File

@ -0,0 +1,3 @@
Name: Button_Resume_Default
ID: 63738242
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: Button_Resume_Hovered
ID: 58455648
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: Button_Retry_Clicked
ID: 60429179
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: Button_Retry_Default
ID: 64995894
Type: 3

View File

@ -1,3 +0,0 @@
Name: Button_Retry_Hover
ID: 58347825
Type: 3

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: Button_Retry_Hovered
ID: 58109178
Type: 3

View File

@ -1,3 +0,0 @@
Name: Button_Retry_Idle
ID: 64806384
Type: 3

View File

@ -1,3 +0,0 @@
Name: Button_Retry_Pressed
ID: 63234380
Type: 3

View File

@ -180,8 +180,8 @@ namespace Sandbox
// Link up SHDebugDraw
SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>());
auto clip = SHResourceManager::LoadOrGet<SHRawAnimation>(77816045);
auto rig = SHResourceManager::LoadOrGet<SHRig>(77816045);
//auto clip = SHResourceManager::LoadOrGet<SHRawAnimation>(77816045);
//auto rig = SHResourceManager::LoadOrGet<SHRig>(77816045);
}
void SBApplication::Update(void)

View File

@ -24,15 +24,13 @@ project "SHADE_CSharp"
{
"SHADE_Engine"
}
warnings 'Extra'
postbuildcommands
{
"xcopy /r /y /q \"%{outputdir}\\net5.0\\SHADE_CSharp.xml\" \"%{outputdir}\"",
"xcopy /r /y /q \"%{outputdir}\\net5.0\\SHADE_CSharp.pdb\" \"%{outputdir}\""
"xcopy /r /y /q \"%{wks.location}/bin/$(Configuration)\\net5.0\\SHADE_CSharp.pdb\" \"%{wks.location}/bin/$(Configuration)\""
}
warnings 'Extra'
filter "configurations:Debug"
symbols "On"
defines {"_DEBUG"}

View File

@ -20,19 +20,19 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
/* Constructors */
/*-----------------------------------------------------------------------------------*/
SHAnimationClip::SHAnimationClip(Handle<SHRawAnimation> rawAnimHandle, int firstFrame, int lastFrame)
: rawAnim { rawAnimHandle }
, startFrameIndex { firstFrame }
, endFrameIndex { lastFrame }
, duration { 0.0f }
, startTimeStamp { 0.0f }
SHAnimationClip::SHAnimationClip(Handle<SHRawAnimation> rawAnimHandle, int firstFrame, int lastFrame, float playbackMultiplier)
: rawAnim { rawAnimHandle }
, startFrameIndex { firstFrame }
, endFrameIndex { lastFrame }
, duration { 0.0f }
, startTimeStamp { 0.0f }
, playbackSpeedMultiplier { playbackMultiplier }
{
if (!rawAnim)
return;
const float SECS_PER_TICK = 1.0f / static_cast<float>(rawAnim->GetTicksPerSecond());
const int ONE_PAST_LAST_FRAME = lastFrame + 1;
duration = static_cast<float>(ONE_PAST_LAST_FRAME - firstFrame) * SECS_PER_TICK;
duration = static_cast<float>(lastFrame - firstFrame) * SECS_PER_TICK;
startTimeStamp = static_cast<float>(firstFrame) * SECS_PER_TICK;
}
}

View File

@ -41,25 +41,39 @@ namespace SHADE
/// <param name="rawAnimHandle">Handle to the raw animation data.</param>
/// <param name="firstFrame">First frame to be played.</param>
/// <param name="lastFrame">Last frame to be played.</param>
SHAnimationClip(Handle<SHRawAnimation> rawAnimHandle, int firstFrame, int lastFrame);
/// <param name="playbackMultiplier">Multiplier for the playback speed.</param>
SHAnimationClip(Handle<SHRawAnimation> rawAnimHandle, int firstFrame, int lastFrame, float playbackMultiplier = 1.0f);
/*---------------------------------------------------------------------------------*/
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
inline Handle<SHRawAnimation> GetRawAnimation() const noexcept { return rawAnim; }
inline int GetStartFrameIndex() const noexcept { return startFrameIndex; }
inline int GetEndFrameIndex() const noexcept { return endFrameIndex; }
inline float GetTotalDuration() const noexcept { return duration; }
inline int GetEndFrameIndex() const noexcept { return endFrameIndex; }\
inline float GetStartTimeStamp() const noexcept { return startTimeStamp; }
inline float GetPlaybackSpeedMultiplier() const noexcept { return playbackSpeedMultiplier; }
/// <summary>
/// Retrieves the duration of the animation as if the playback speed multiplier is
/// in it's default value of 1.0f.
/// </summary>
/// <returns>Duration of the animation in seconds.</returns>
inline float GetTotalDuration() const noexcept { return duration; }
/// <summary>
/// Retrieves the duration of the animation with the playback speed multiplier
/// taken into account.
/// </summary>
/// <returns>True duration of the animation in seconds.</returns>
inline float GetTrueDuration() const noexcept { return duration / playbackSpeedMultiplier; }
private:
/*---------------------------------------------------------------------------------*/
/* Data Members */
/*---------------------------------------------------------------------------------*/
Handle<SHRawAnimation> rawAnim;
int startFrameIndex; // First Frame
int endFrameIndex; // Last Frame (inclusive)
float duration; // Total playback time
float startTimeStamp; // Starting time stamp of the raw anim
int startFrameIndex; // First Frame
int endFrameIndex; // Last Frame (inclusive)
float duration; // Total playback time
float startTimeStamp; // Starting time stamp of the raw anim
float playbackSpeedMultiplier; // Multiplier applied to the playback of an animation clip
};
}

View File

@ -15,6 +15,7 @@ of DigiPen Institute of Technology is prohibited.
#include "SHAnimationSystem.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "SHAnimationClip.h"
#include "Events/SHEventManager.hpp"
namespace SHADE
{
@ -55,23 +56,27 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
/* Lifecycle Functions */
/*-----------------------------------------------------------------------------------*/
void SHAnimationController::Update(InstanceData& instData, float dt)
void SHAnimationController::Update(EntityID eid, InstanceData& instData, float dt)
{
// Is there a valid node
if (!instData.CurrentNode)
return;
// Get the clip
Handle<SHAnimationClip> clip = instData.CurrentNode->Clip;
// Update the current playback
instData.ClipPlaybackTime += dt;
instData.ClipPlaybackTime += dt * clip->GetPlaybackSpeedMultiplier();
// Check if we finished playing
const float CLIP_CURR_PLAYED_TIME = instData.ClipPlaybackTime - instData.CurrentNode->Clip->GetStartTimeStamp();
if (CLIP_CURR_PLAYED_TIME > instData.CurrentNode->Clip->GetTotalDuration())
const float CLIP_CURR_PLAYED_TIME = instData.ClipPlaybackTime - clip->GetStartTimeStamp();
if (CLIP_CURR_PLAYED_TIME > clip->GetTotalDuration())
{
// Clamp
instData.ClipPlaybackTime = instData.CurrentNode->Clip->GetStartTimeStamp() + instData.CurrentNode->Clip->GetTotalDuration();
instData.ClipPlaybackTime = clip->GetStartTimeStamp() + clip->GetTotalDuration();
// Go to next state
Handle<SHAnimationClip> originalClip = clip;
bool stateChanged = false;
for (const auto& transition : instData.CurrentNode->Transitions)
{
@ -107,7 +112,29 @@ namespace SHADE
}
// Handle if there is no next state, we repeat
if (!stateChanged)
if (stateChanged)
{
// Raise events
SHEventManager::BroadcastEvent
(
SHAnimationSystem::FinishedEvent
{
eid,
originalClip
},
SH_ANIMATION_FINISHED_EVENT
);
SHEventManager::BroadcastEvent
(
SHAnimationSystem::PlayEvent
{
eid,
instData.CurrentNode ? instData.CurrentNode->Clip : Handle<SHAnimationClip>()
},
SH_ANIMATIONS_PLAY_EVENT
);
}
else
{
instData.ClipPlaybackTime = instData.CurrentNode->Clip->GetStartTimeStamp();
}

View File

@ -18,6 +18,7 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes
#include "SH_API.h"
#include "Resource/SHHandle.h"
#include "ECS_Base/SHECSMacros.h"
namespace SHADE
{
@ -162,7 +163,12 @@ namespace SHADE
/// <summary>
/// Runs a single update for the animation controller.
/// </summary>
void Update(InstanceData& instData, float dt);
/// <param name="eid">
/// EntityID of the entity that this animation controller is updating.
/// </param>
/// <param name="instData">Instance data that stores the current state.</param>
/// <param name="dt">Frame time.</param>
void Update(EntityID eid, InstanceData& instData, float dt);
/*---------------------------------------------------------------------------------*/
/* Usage Functions */

View File

@ -32,6 +32,7 @@ namespace SHADE
void SHAnimationSystem::UpdateRoutine::Execute(double dt) noexcept
{
auto& animators = SHComponentManager::GetDense<SHAnimatorComponent>();
dt *= reinterpret_cast<SHAnimationSystem*>(system)->TimeScale;
for (auto& animator : animators)
{
animator.Update(dt);

View File

@ -19,6 +19,11 @@ of DigiPen Institute of Technology is prohibited.
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* Forward Declaration */
/*-----------------------------------------------------------------------------------*/
class SHAnimationClip;
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------------*/
@ -29,7 +34,7 @@ namespace SHADE
{
public:
/*---------------------------------------------------------------------------------*/
/* Type Definitions */
/* Type Definitions - System Routines */
/*---------------------------------------------------------------------------------*/
/// <summary>
/// Responsible for updating the playback of all animator components and computing
@ -42,6 +47,57 @@ namespace SHADE
void Execute(double dt) noexcept override final;
};
/*---------------------------------------------------------------------------------*/
/* Type Definitions - Event Data */
/*---------------------------------------------------------------------------------*/
/// <summary>
/// Event data for the SH_ANIMATIONS_PLAY_EVENT event which is raised on the frame
/// that an animation has started playing.
/// </summary>
struct PlayEvent
{
EntityID Entity;
Handle<SHAnimationClip> PlayingClip;
float CurrentTimeStamp;
};
/// <summary>
/// Event data for the SH_ANIMATIONS_PAUSED_EVENT event which is raised on the frame
/// that an animation is paused.
/// </summary>
struct PausedEvent
{
EntityID Entity;
Handle<SHAnimationClip> PausedClip;
float PauseTimeStamp;
};
/// <summary>
/// Event data for the SH_ANIMATIONS_FINISHED_EVENT event which is raised on the
/// frame that an animation has finished playing. This will not be called for any
/// animation that loops.
/// </summary>
struct FinishedEvent
{
EntityID Entity;
Handle<SHAnimationClip> FinishedClip;
};
/*---------------------------------------------------------------------------------*/
/* Constants */
/*---------------------------------------------------------------------------------*/
/// <summary>
/// Default time scale used by the system.
/// </summary>
static constexpr double DEFAULT_TIME_SCALE = 1.0;
/*---------------------------------------------------------------------------------*/
/* Public Data Members */
/*---------------------------------------------------------------------------------*/
/// <summary>
/// Used by the system to multiply the given delta time to scale the animation
/// speed.
/// </summary>
double TimeScale = DEFAULT_TIME_SCALE;
/*---------------------------------------------------------------------------------*/
/* Constructors */
/*---------------------------------------------------------------------------------*/

View File

@ -25,6 +25,7 @@ of DigiPen Institute of Technology is prohibited.
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
#include "Tools/SHDebugDraw.h"
#include "Events/SHEventManager.hpp"
namespace SHADE
{
@ -35,6 +36,8 @@ namespace SHADE
{
isPlaying = true;
playOnce = false;
raisePlayEvent();
}
void SHAnimatorComponent::Play(Handle<SHAnimationClip> clip)
@ -91,11 +94,13 @@ namespace SHADE
isPlaying = true;
currPlaybackTime = 0.0f;
raisePlayEvent();
}
void SHAnimatorComponent::Pause()
{
isPlaying = false;
raisePauseEvent();
}
void SHAnimatorComponent::Stop()
@ -119,9 +124,13 @@ namespace SHADE
std::fill(boneMatrices.begin(), boneMatrices.end(), SHMatrix::Identity);
// Do not do anything if is not playing or there's nothing to animate
if (!isPlaying || !rig || !rig->GetRootNode())
if (!rig || !rig->GetRootNode())
return;
// We want to still display a paused pose, so we only prevent progression
if (!isPlaying)
dt = 0.0f;
// Update the animation controller if any, this will set the currClip
if (animController)
{
@ -211,6 +220,19 @@ namespace SHADE
return animController->SetTrigger(animInstanceData, paramName);
}
/*-----------------------------------------------------------------------------------*/
/* Getter Functions */
/*-----------------------------------------------------------------------------------*/
Handle<SHAnimationClip> SHAnimatorComponent::GetCurrentClip() const noexcept
{
if (animController)
{
return animInstanceData.CurrentNode ? animInstanceData.CurrentNode->Clip : Handle<SHAnimationClip>();
}
return currClip;
}
/*-----------------------------------------------------------------------------------*/
/* Helper Functions - Update */
/*-----------------------------------------------------------------------------------*/
@ -221,7 +243,7 @@ namespace SHADE
return;
// Update the animation controller
animController->Update(animInstanceData, dt);
animController->Update(GetEID(), animInstanceData, dt);
// Get current clip
currClip = animInstanceData.CurrentNode->Clip;
@ -232,7 +254,7 @@ namespace SHADE
}
void SHAnimatorComponent::updateManualClipState(float dt)
{
currPlaybackTime += dt;
currPlaybackTime += dt * currClip->GetPlaybackSpeedMultiplier();
const float CLIP_CURR_PLAYED_TIME = currPlaybackTime - currClip->GetStartTimeStamp();
if (CLIP_CURR_PLAYED_TIME > currClip->GetTotalDuration())
{
@ -241,6 +263,7 @@ namespace SHADE
playOnce = false;
isPlaying = false;
currPlaybackTime = currClip->GetStartTimeStamp() + currClip->GetTotalDuration();
raiseFinishEvent();
}
else
{
@ -251,7 +274,7 @@ namespace SHADE
void SHAnimatorComponent::updateCurrentAnimatorState(Handle<SHAnimationClip> clip, float playbackTime)
{
// Nothing to animate
if (!clip || !isPlaying || !rig || !rig->GetRootNode())
if (!clip || !rig || !rig->GetRootNode())
return;
// Check that we have animation data
@ -299,6 +322,50 @@ namespace SHADE
updatePoseWithClip(poseTime, rawAnimData, child, transformMatrix);
}
}
/*-----------------------------------------------------------------------------------*/
/* Helper Functions - Event */
/*-----------------------------------------------------------------------------------*/
void SHAnimatorComponent::raisePlayEvent()
{
SHEventManager::BroadcastEvent
(
SHAnimationSystem::PlayEvent
{
GetEID(),
GetCurrentClip(),
GetCurrentClipPlaybackTime()
},
SH_ANIMATIONS_PLAY_EVENT
);
}
void SHAnimatorComponent::raisePauseEvent()
{
SHEventManager::BroadcastEvent
(
SHAnimationSystem::PausedEvent
{
GetEID(),
GetCurrentClip(),
GetCurrentClipPlaybackTime()
},
SH_ANIMATIONS_PAUSED_EVENT
);
}
void SHAnimatorComponent::raiseFinishEvent()
{
SHEventManager::BroadcastEvent
(
SHAnimationSystem::FinishedEvent
{
GetEID(),
GetCurrentClip()
},
SH_ANIMATION_FINISHED_EVENT
);
}
}
/*-------------------------------------------------------------------------------------*/

View File

@ -24,6 +24,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Math/SHQuaternion.h"
#include "SHRawAnimation.h"
#include "SHAnimationController.h"
#include "SHAnimationSystem.h"
namespace SHADE
{
@ -166,6 +167,20 @@ namespace SHADE
/// </summary>
/// <returnsHandle to the currently set animtion controller.</returns>
Handle<SHAnimationController> GetAnimationController() const noexcept { return animController; }
/// <summary>
/// Retrieves the currently playing clip. If there is an Animation Controller, it
/// will be retrieved from it. Otherwise, the currently assigned Animation Clip is provided.
/// </summary>
/// <returns>Handle to the currently playing Animation Clip if any.</returns>
Handle<SHAnimationClip> GetCurrentClip() const noexcept;
/// <summary>
/// Retrieves the current timestamp of the currently playing clip. This is relative
/// to the start frame of the Animation Clip. This function will retrieve the correct
/// playback time depending on the current playback mode (Animation Controller or
/// Manual).
/// </summary>
/// <returns>Time in seconds of the current timestamp of the current clip.</returns>
float GetCurrentClipPlaybackTime() const noexcept { return animController ? animInstanceData.ClipPlaybackTime : currPlaybackTime; }
private:
/*---------------------------------------------------------------------------------*/
@ -201,6 +216,10 @@ namespace SHADE
void updatePoseWithClip(float poseTime, Handle<SHRawAnimation> rawAnimData, Handle<SHRigNode> node, const SHMatrix& parentMatrix);
template<typename T>
T getInterpolatedValue(const std::vector<SHAnimationKeyFrame<T>>& keyframes, float poseTime);
// Event Functions
void raisePlayEvent();
void raisePauseEvent();
void raiseFinishEvent();
/*---------------------------------------------------------------------------------*/
/* RTTR */

View File

@ -25,12 +25,13 @@ namespace SHADE
std::string name;
uint32_t firstIndex;
uint32_t lastIndex;
float playbackMultiplier = 1.0f;
AssetID animRawDataAssetId; // Not serialised, only populated during runtime from parent asset
};
struct SH_API SHAnimClipContainerAsset final : SHAssetData
{
AssetID animRawDataAssetId;
std::vector<SHAnimClipAsset> clips{};
std::vector<SHAnimClipAsset*> clips{};
};
}

View File

@ -66,20 +66,20 @@ namespace SHADE
for (auto const& clip : anim.clips)
{
uint32_t charCount {static_cast<uint32_t>(clip.name.size())};
uint32_t charCount {static_cast<uint32_t>(clip->name.size())};
file.write(
reinterpret_cast<char const*>(&charCount),
sizeof(uint32_t)
);
file.write(
clip.name.data(),
clip->name.data(),
charCount
);
file.write(
reinterpret_cast<char const*>(&clip.firstIndex),
sizeof(uint32_t) * 2
reinterpret_cast<char const*>(&clip->firstIndex),
sizeof(uint32_t) * 3
);
}
}
@ -99,28 +99,29 @@ namespace SHADE
reinterpret_cast<char*>(&size),
sizeof(uint32_t)
);
data->clips.resize(size);
for (auto i{0}; i < size; ++i)
for (auto& clip : data->clips)
{
auto& clip {data->clips.emplace_back()};
clip = new SHAnimClipAsset;
uint32_t charCount;
file.read(
reinterpret_cast<char*>(&charCount),
sizeof(uint32_t)
);
clip.name.resize(charCount);
clip->name.resize(charCount);
file.read(
clip.name.data(),
clip->name.data(),
charCount
);
file.read(
reinterpret_cast<char*>(&clip.firstIndex),
sizeof(uint32_t) * 2
reinterpret_cast<char*>(&clip->firstIndex),
sizeof(uint32_t) * 3
);
clip.animRawDataAssetId = data->animRawDataAssetId;
clip->animRawDataAssetId = data->animRawDataAssetId;
}
result = data;

View File

@ -313,11 +313,11 @@ namespace SHADE
.isSubAsset = true,
.parent = parent
};
auto& newClip {animContainer->clips.emplace_back()};
newClip.name = name;
auto& newClip {animContainer->clips.emplace_back(new SHAnimClipAsset())};
newClip->name = name;
assetCollection.emplace(id, asset);
assetCollection[parent].subAssets.push_back(&assetCollection[id]);
assetData.emplace(id, &newClip);
assetData.emplace(id, newClip);
return id;
}
@ -639,6 +639,25 @@ namespace SHADE
assetData.emplace(asset.id, data);
}
switch (asset.type)
{
case AssetType::ANIM_CONTAINER:
{
auto container = reinterpret_cast<SHAnimClipContainerAsset*>(data);
for (auto i{0}; i < asset.subAssets.size(); ++i)
{
assetData.emplace(
asset.subAssets[i]->id,
container->clips[i]
);
}
}
break;
default:
break;
}
return data;
}
@ -646,7 +665,6 @@ namespace SHADE
{
auto const& parent = assetCollection[asset.parent];
auto parentData = loaders[static_cast<size_t>(parent.type)]->Load(parent.path);
if (parentData == nullptr)
{
SHLOG_ERROR("[Asset Manager] Unable to load asset into memory: {}\n", parent.path.string());
@ -676,7 +694,7 @@ namespace SHADE
{
assetData.emplace(
parent.subAssets[i]->id,
&parentContainer->clips[i]
parentContainer->clips[i]
);
}
}
@ -859,7 +877,7 @@ namespace SHADE
for(auto& clip : data->clips)
{
SHAsset subAsset{
.name = clip.name,
.name = clip->name,
.id = GenerateAssetID(AssetType::ANIM_CLIP),
.type = AssetType::ANIM_CLIP,
.isSubAsset = true,
@ -869,7 +887,7 @@ namespace SHADE
assetCollection.emplace(subAsset.id, subAsset);
assetCollection[newAsset.id].subAssets.push_back(&assetCollection[subAsset.id]);
assetData.emplace(subAsset.id, &clip);
assetData.emplace(subAsset.id, clip);
}
SHAssetMetaHandler::WriteMetaData(assetCollection[newAsset.id]);

View File

@ -115,6 +115,7 @@ namespace SHADE
LoadBank((AUDIO_FOLDER_PATH + "Master.bank").data());
LoadBank((AUDIO_FOLDER_PATH + "Master.strings.bank").data());
LoadBank((AUDIO_FOLDER_PATH + "Music.bank").data());
LoadBank((AUDIO_FOLDER_PATH + "Cinematics.bank").data());
LoadBank((AUDIO_FOLDER_PATH + "SFX.bank").data());
LoadBank((AUDIO_FOLDER_PATH + "UI.bank").data());
@ -133,11 +134,12 @@ namespace SHADE
const ReceiverPtr ON_PAUSE_RECEIVER_PTR = std::dynamic_pointer_cast<SHEventReceiver>(ON_PAUSE_RECEIVER);
SHEventManager::SubscribeTo(SH_EDITOR_ON_PAUSE_EVENT, ON_PAUSE_RECEIVER_PTR);
#endif
const std::shared_ptr ON_SCENE_EXIT_RECEIVER{ std::make_shared<SHEventReceiverSpec<SHAudioSystem>>(this, &SHAudioSystem::onSceneExit) };
const ReceiverPtr ON_SCENE_EXIT_RECEIVER_PTR = std::dynamic_pointer_cast<SHEventReceiver>(ON_SCENE_EXIT_RECEIVER);
SHEventManager::SubscribeTo(SH_SCENE_EXIT_POST, ON_SCENE_EXIT_RECEIVER_PTR);
#endif
}
void SHADE::SHAudioSystem::Run(double dt)
@ -820,6 +822,16 @@ namespace SHADE
instance->setVolume(volume);
}
bool AudioClip::GetDestroyOnSceneExit()
{
return destroyOnSceneExit;
}
void AudioClip::SetDestroyOnSceneExit(bool value)
{
destroyOnSceneExit = value;
}
SHEventHandle SHAudioSystem::onStop(SHEventPtr onStopEvent)
{
StopAllSounds();
@ -839,7 +851,11 @@ namespace SHADE
auto [begin, end] = audioClipLibrary.GetDenseAccess();
for (auto& it = begin; it != end; ++it)
{
it->instance->release();
if(it->destroyOnSceneExit)
{
it->instance->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT);
it->instance->release();
}
}
return onSceneExitEvent->handle;

View File

@ -37,10 +37,13 @@ namespace SHADE
float GetParameterValue(const char* paramName);
float GetVolume();
void SetVolume(float volume);
bool GetDestroyOnSceneExit();
void SetDestroyOnSceneExit(bool value);
friend class SHAudioSystem;
private:
FMOD::Studio::EventInstance* instance = nullptr;
EntityID transformRef = MAX_EID;
bool destroyOnSceneExit = true;
};
class SH_API SHAudioSystem : public SHSystem

View File

@ -206,6 +206,16 @@ namespace SHADE
camera->dirtyView = true;
}
camera->offset = offset;
SHVec3 tOffset = pivot.GetTargetOffset();
tOffset = SHVec3::RotateY(tOffset, SHMath::DegreesToRadians(pivot.GetYaw()));
if (pivot.lookAtCameraOrigin)
CameraLookAt(*camera, camera->position + tOffset);
@ -250,7 +260,7 @@ namespace SHADE
if (camera.isActive == false)
return;
if (SHComponentManager::HasComponent<SHTransformComponent>(camera.GetEID()) == true && &camera != &editorCamera)
if (SHComponentManager::HasComponent<SHTransformComponent>(camera.GetEID()) == true && SHComponentManager::HasComponent<SHCameraArmComponent>(camera.GetEID()) == false && &camera != &editorCamera)
{
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(camera.GetEID());
SHVec3 rotation = transform->GetWorldRotation();
@ -273,14 +283,14 @@ namespace SHADE
{
camera.offset = arm->GetOffset();
SHVec3 tOffset = arm->GetTargetOffset();
/*SHVec3 tOffset = arm->GetTargetOffset();
tOffset = SHVec3::RotateY(tOffset, SHMath::DegreesToRadians(arm->GetYaw()));
if (arm->lookAtCameraOrigin)
CameraLookAt(camera, camera.position + arm->GetTargetOffset());
CameraLookAt(camera, camera.position + arm->GetTargetOffset());*/
}

View File

@ -54,6 +54,7 @@ namespace SHADE
newAssetName.clear();
firstIndex = 0;
lastIndex = rawAnimation->GetTotalFrames();
playbackMultiplier = 1.0f;
}
// Assign callback
@ -72,6 +73,9 @@ namespace SHADE
SHEditorUI::PushID(1);
SHEditorUI::InputUnsignedInt("Last Frame Index", lastIndex);
SHEditorUI::PopID();
SHEditorUI::PushID(2);
SHEditorUI::InputFloat("Playback Multiplier", playbackMultiplier);
SHEditorUI::PopID();
// Invalid values
const bool INVALID_CONFIG = newAssetName.empty() || firstIndex > lastIndex;
@ -88,6 +92,7 @@ namespace SHADE
animClip->firstIndex = firstIndex;
animClip->lastIndex = lastIndex;
animClip->animRawDataAssetId = SHResourceManager::GetAssetID<SHRawAnimation>(rawAnimation).value_or(0);
animClip->playbackMultiplier = playbackMultiplier;
SHAssetManager::SaveAsset(containerAsset->id);
// Close
@ -158,13 +163,17 @@ namespace SHADE
if (SHEditorUI::CollapsingHeader("Existing Animation Clips"))
{
ImGui::Indent();
int i = 0;
for (auto animClip : childAnimClips)
{
ImGui::PushID(i++);
bool changed = false;
std::optional<std::string> animClipName = SHResourceManager::GetAssetName<SHAnimationClip>(animClip);
int firstIndex = animClip->GetStartFrameIndex();
int endIndex = animClip->GetEndFrameIndex();
float playbackMp = animClip->GetPlaybackSpeedMultiplier();
ImGui::Separator();
ImGui::Text(animClipName.has_value() ? animClipName.value().c_str() : "");
@ -180,23 +189,32 @@ namespace SHADE
[&]() { return endIndex; },
[&](int i) { endIndex = i; }
);
changed |= SHEditorWidgets::DragFloat
(
"Playback Multiplier",
[&]() { return playbackMp; },
[&](float f) { playbackMp = f; }
);
// If there's a change we need to commit changes
if (changed && firstIndex < endIndex)
{
// Update runtime asset
*animClip = SHAnimationClip(currRawAnim, firstIndex, endIndex);
*animClip = SHAnimationClip(currRawAnim, firstIndex, endIndex, playbackMp);
// Update serialized asset
auto assetId = SHResourceManager::GetAssetID(animClip);
if (assetId.has_value())
{
auto animAsset = SHAssetManager::GetData<SHAnimClipAsset>(assetId.value());
auto const animAsset = SHAssetManager::GetData<SHAnimClipAsset>(assetId.value());
animAsset->firstIndex = firstIndex;
animAsset->lastIndex = endIndex;
SHAssetManager::SaveAsset(assetId.value());
animAsset->playbackMultiplier = playbackMp;
SHAssetManager::SaveAsset(containerAsset->id);
}
}
ImGui::PopID();
}
// Extra separator if there is more than one

View File

@ -62,6 +62,7 @@ namespace SHADE
std::string newAssetName;
uint32_t firstIndex = 0;
uint32_t lastIndex = 0;
float playbackMultiplier = 1.0f;
Handle<SHRawAnimation> rawAnimation;
SHAsset* containerAsset{nullptr};
SHAnimClipContainerAsset* container{nullptr};

View File

@ -113,14 +113,15 @@ namespace SHADE
SHEditorWindowManager::CreateEditorWindow<SHAssetBrowser>();
SHEditorWindowManager::CreateEditorWindow<SHMaterialInspector>();
SHEditorWindowManager::CreateEditorWindow<SHColliderTagPanel>();
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
SHEditorWindowManager::CreateEditorWindow<SHInputBindingsPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
SHEditorWindowManager::CreateEditorWindow<SHAnimationControllerEditor>();
SHEditorWindowManager::CreateEditorWindow<SHRawAnimInspector>();
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
//Add popup windows
SHEditorWindowManager::CreatePopupWindow<SHSceneSavePrompt>();

View File

@ -31,4 +31,6 @@ constexpr SHEventIdentifier SH_BUTTON_HOVER_ENTER_EVENT { 22 };
constexpr SHEventIdentifier SH_BUTTON_HOVER_EXIT_EVENT { 23 };
constexpr SHEventIdentifier SH_ASSET_COMPILE_EVENT { 24 };
constexpr SHEventIdentifier SH_GRAPHICS_LIGHT_DELETE_EVENT { 25 };
constexpr SHEventIdentifier SH_ANIMATIONS_PAUSED_EVENT { 26 };
constexpr SHEventIdentifier SH_ANIMATIONS_PLAY_EVENT { 27 };
constexpr SHEventIdentifier SH_ANIMATION_FINISHED_EVENT { 28 };

View File

@ -726,16 +726,34 @@ namespace SHADE
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::BONE_MATRIX_FIRST_INDEX, transformDataBuffer[frameIndex], 0);
}
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
if (instanceDataDescSet[frameIndex])
if (IsAnimated())
{
cmdBuffer->BindDescriptorSet
(
instanceDataDescSet[frameIndex],
SH_PIPELINE_TYPE::GRAPHICS,
descMappings.at(SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH),
dynamicOffset
);
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING_ANIM);
if (instanceDataDescSet[frameIndex])
{
cmdBuffer->BindDescriptorSet
(
instanceDataDescSet[frameIndex],
SH_PIPELINE_TYPE::GRAPHICS,
descMappings.at(SHPredefinedDescriptorTypes::PER_INSTANCE_ANIM_BATCH),
dynamicOffset
);
}
}
else
{
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
if (instanceDataDescSet[frameIndex])
{
cmdBuffer->BindDescriptorSet
(
instanceDataDescSet[frameIndex],
SH_PIPELINE_TYPE::GRAPHICS,
descMappings.at(SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH),
dynamicOffset
);
}
}
cmdBuffer->DrawMultiIndirect(drawDataBuffer[frameIndex], static_cast<uint32_t>(drawData.size()));
cmdBuffer->EndLabeledSegment();

View File

@ -17,6 +17,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Graphics/Descriptors/SHVkDescriptorPool.h"
#include "Graphics/Commands/SHVkCommandBuffer.h"
namespace SHADE
{
@ -108,11 +109,19 @@ namespace SHADE
}
}
void SHSuperBatch::Draw(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex, bool bindBatchPipeline /*= true*/) noexcept
void SHSuperBatch::Draw(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex, bool bindBatchPipeline /*= true*/, Handle<SHVkPipeline> nonAnimPipeline/* = {}*/, Handle<SHVkPipeline> animPipeline/* = {}*/) noexcept
{
// Build all batches
for (auto& batch : batches)
{
if (!bindBatchPipeline)
{
if (batch.IsAnimated())
cmdBuffer->BindPipeline(animPipeline);
else
cmdBuffer->BindPipeline(nonAnimPipeline);
}
batch.Draw(cmdBuffer, frameIndex, bindBatchPipeline);
}
}

Some files were not shown because too many files have changed in this diff Show More