Updated ScoreText UI. Updated Button SFX #421

Merged
maverickdgg merged 8 commits from SP3-20-UI-System into main 2023-03-10 19:52:38 +08:00
33 changed files with 5907 additions and 439 deletions
Showing only changes of commit 56cda49ea7 - Show all commits

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -3071,13 +3071,14 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 0.400000006, y: 0.5, z: 0.300000012}
Collision Tag: 1
Type: Capsule
Radius: 0.300000012
Height: 0.300000012
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0.25, z: 0}
Position Offset: {x: 0, y: 0.300000012, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts:
@ -3107,8 +3108,6 @@
throwItem: false
rayDistance: 0.75
rayHeight: 0.100000001
aimingFOV: 50
defaultFOV: 45
- EID: 3
Name: HoldingPoint
IsActive: true
@ -14094,9 +14093,7 @@
IsActive: true
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
Enabled: true
Scripts: ~
- EID: 549
Name: StealFoodCanvas
IsActive: true
@ -14178,7 +14175,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 554
Name: CameraPoints

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
@ -152,7 +153,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 450
Name: TransitionCanvas

View File

@ -338,7 +338,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 13
Name: How To Play Canvas

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
@ -152,7 +153,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 450
Name: TransitionCanvas

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,28 @@ 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)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
}
else
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
}
}
}
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,11 @@ public class PlayerRunState : BaseState
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
if (PlayerAnimations.Instance)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerRunClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerRunClip);
}
}
public override void update()
{
@ -21,7 +27,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,38 @@
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);
if(PlayerAnimations.Instance.playerWalkClip)
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
}
else
{
if(PlayerAnimations.Instance.playerCarryWalkClip)
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
if(PlayerAnimations.Instance.playerCarryWalkClip)
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
}
}
}
public override void update()
{
@ -21,7 +41,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,81 @@
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>();
@ -417,7 +426,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

@ -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

@ -7,89 +7,93 @@ 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;
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 (sfx != null)
{
sfx.ScaledValue = Settings.sfxVolume;
}
if (bgm != null)
{
bgm.ScaledValue = Settings.bgmVolume;
}
if (fov != null)
{
fov.ScaledValue = Settings.cameraFOV;
if (mv != null)
{
mv.ScaledValue = Settings.masterVolume;
}
if (sens != null)
{
sens.ScaledValue = Settings.cameraSensitivity;
}
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 * 0.01f;
SHADE.Audio.SetVCAVolume("vca:/MASTER", Settings.masterVolume);
}
if (sfx != null)
{
Settings.sfxVolume = sfx.ScaledValue * 0.01f;
SHADE.Audio.SetVCAVolume("vca:/SFX", Settings.sfxVolume);
SHADE.Audio.SetVCAVolume("vca:/UI", Settings.sfxVolume);
}
if (bgm != null)
{
Settings.bgmVolume = bgm.ScaledValue * 0.01f;
SHADE.Audio.SetVCAVolume("vca:/MUSIC", Settings.bgmVolume);
}
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;
}
});
}
@ -106,6 +107,7 @@ public class PauseMenu : Script
if (canvas)
canvas.SetActive(true);
Application.FixDeltaTime = 0;
AnimationSystem.TimeScale = 0;
}
}

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

@ -31,6 +31,6 @@ namespace SHADE
struct SH_API SHAnimClipContainerAsset final : SHAssetData
{
AssetID animRawDataAssetId;
std::vector<SHAnimClipAsset> clips{};
std::vector<SHAnimClipAsset*> clips{};
};
}

View File

@ -66,19 +66,19 @@ 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),
reinterpret_cast<char const*>(&clip->firstIndex),
sizeof(uint32_t) * 2
);
}
@ -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),
reinterpret_cast<char*>(&clip->firstIndex),
sizeof(uint32_t) * 2
);
clip.animRawDataAssetId = data->animRawDataAssetId;
clip->animRawDataAssetId = data->animRawDataAssetId;
}
result = data;

View File

@ -314,10 +314,10 @@ namespace SHADE
.parent = parent
};
auto& newClip {animContainer->clips.emplace_back()};
newClip.name = name;
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

@ -280,7 +280,7 @@ namespace SHADE
if (arm->lookAtCameraOrigin)
CameraLookAt(camera, camera.position + arm->GetTargetOffset());
CameraLookAt(camera, camera.position + tOffset);
}

View File

@ -194,10 +194,10 @@ namespace SHADE
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());
SHAssetManager::SaveAsset(containerAsset->id);
}
}

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>();