Added spatial audio #374

Merged
srishamharan merged 4 commits from SP3-129-AudioSystem into main 2023-02-28 13:17:19 +08:00
14 changed files with 258 additions and 79 deletions
Showing only changes of commit 3141902e3d - Show all commits

View File

@ -0,0 +1,4 @@
Start Maximized: true
Working Scene ID: 97158628
Window Size: {x: 1920, y: 1013}
Style: 0

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: Dangrek-Regular
ID: 174412429
Type: 10

Binary file not shown.

View File

@ -4,5 +4,5 @@
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 57302694
data.alpha: 0
data.alpha: 1
data.beta: {x: 1, y: 1, z: 1}

View File

@ -9591,27 +9591,14 @@
gamePauseText: 11
canvas: 10
- EID: 199
Name: =====Text====
Name: Gameplay UI Canvas
IsActive: true
NumberOfChildren: 4
Components: ~
Scripts: ~
- EID: 237
Name: Score
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -800, y: 400, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 60, y: 60, z: 60}
IsActive: true
Text Renderer Component:
Text: My name is Brandon.
Font: 176667660
IsActive: true
UI Component:
Canvas ID: 199
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 206
@ -9630,24 +9617,8 @@
IsActive: true
UI Component:
Canvas ID: 199
IsActive: true
Scripts: ~
- EID: 139
Name: Multiplier
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -800, y: 300, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 60, y: 60, z: 60}
IsActive: true
Text Renderer Component:
Text: TEST
Font: 176667660
IsActive: true
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 11
@ -9664,6 +9635,91 @@
Text: Game Pause
Font: 176667660
IsActive: false
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 139
Name: Multiplier Text
IsActive: true
NumberOfChildren: 1
Components:
Transform Component:
Translate: {x: -800, y: 300, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 60, y: 60.0000038, z: 60}
IsActive: true
Text Renderer Component:
Text: TEST
Font: 176667660
IsActive: true
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 463
Name: Multiplier BG
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.833334029, y: 0.416666061, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 5, y: 1.66666651, z: 0.0166666675}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 237
Name: Score Text
IsActive: true
NumberOfChildren: 1
Components:
Transform Component:
Translate: {x: -770.099915, y: 419.999969, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 60.0000038, y: 60.0000038, z: 60}
IsActive: true
Text Renderer Component:
Text: My name is Brandon.
Font: 176667660
IsActive: true
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 462
Name: Score BG
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0.334998131, y: 0.500000477, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 6.66666603, y: 1.66666651, z: 0.0166666675}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 198
Name: ====Raccoon====
@ -9765,7 +9821,6 @@
Yaw: 360
Roll: 1.28065994e-06
Width: 1055
Height: 604
Near: 0.00999999978
Far: 10000
Perspective: true
@ -10664,6 +10719,7 @@
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 8
@ -10687,6 +10743,8 @@
IsActive: true
UI Component:
Canvas ID: 10
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 0
@ -10710,6 +10768,8 @@
IsActive: true
UI Component:
Canvas ID: 10
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 461
@ -10733,5 +10793,7 @@
IsActive: true
UI Component:
Canvas ID: 10
Hovered: false
Clicked: false
IsActive: true
Scripts: ~

View File

@ -21,7 +21,7 @@
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 121834459
Material: 129138332
IsActive: true
UI Component:
Canvas ID: 0
@ -538,7 +538,7 @@
IsActive: true
Text Renderer Component:
Text: Options
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -558,7 +558,7 @@
IsActive: true
Text Renderer Component:
Text: Audio
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -594,7 +594,7 @@
IsActive: true
Text Renderer Component:
Text: Master
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -614,7 +614,7 @@
IsActive: true
Text Renderer Component:
Text: SFX
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -634,7 +634,7 @@
IsActive: true
Text Renderer Component:
Text: BGM
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -673,7 +673,7 @@
Material: 128676209
IsActive: true
Slider Component:
Slider Value: 0
Slider Value: 1
IsActive: true
UI Component:
Canvas ID: 19
@ -696,7 +696,7 @@
Material: 128676209
IsActive: true
Slider Component:
Slider Value: 0
Slider Value: 1
IsActive: true
UI Component:
Canvas ID: 19
@ -719,7 +719,7 @@
Material: 128676209
IsActive: true
Slider Component:
Slider Value: 0
Slider Value: 1
IsActive: true
UI Component:
Canvas ID: 19
@ -739,7 +739,7 @@
IsActive: true
Text Renderer Component:
Text: Camera
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -775,7 +775,7 @@
IsActive: true
Text Renderer Component:
Text: FOV
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -795,7 +795,7 @@
IsActive: true
Text Renderer Component:
Text: Sensitivity
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -834,7 +834,7 @@
Material: 128676209
IsActive: true
Slider Component:
Slider Value: 0
Slider Value: 1
IsActive: true
UI Component:
Canvas ID: 19
@ -857,7 +857,7 @@
Material: 128676209
IsActive: true
Slider Component:
Slider Value: 0
Slider Value: 1
IsActive: true
UI Component:
Canvas ID: 19
@ -893,7 +893,7 @@
IsActive: true
Text Renderer Component:
Text: 100
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -918,7 +918,7 @@
IsActive: true
Text Renderer Component:
Text: 100
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -943,7 +943,7 @@
IsActive: true
Text Renderer Component:
Text: 100
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -984,7 +984,7 @@
IsActive: true
Text Renderer Component:
Text: 100
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -1009,7 +1009,7 @@
IsActive: true
Text Renderer Component:
Text: 100
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 19
@ -1024,14 +1024,14 @@
maxValue: 100
- EID: 46
Name: Credits Canvas
IsActive: true
IsActive: false
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
IsActive: false
Scripts: ~
- EID: 47
Name: BackGround
@ -1093,7 +1093,7 @@
IsActive: true
Text Renderer Component:
Text: Credits
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 46
@ -1103,14 +1103,14 @@
Scripts: ~
- EID: 50
Name: Level Select Canvas
IsActive: true
IsActive: false
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
IsActive: false
Scripts: ~
- EID: 51
Name: BackGround
@ -1172,7 +1172,7 @@
IsActive: true
Text Renderer Component:
Text: Level Select
Font: 176667660
Font: 174412429
IsActive: true
UI Component:
Canvas ID: 50

View File

@ -100,7 +100,7 @@ public class GameManager : Script
if (itemScored)
{
multiplierText.GetComponent<TextRenderable>().Text = $"X {currMultiplierCombo}";
multiplierText.GetComponent<Transform>().LocalScale -= fontScalar * Time.DeltaTimeF;
//multiplierText.GetComponent<Transform>().LocalScale -= fontScalar * Time.DeltaTimeF;
currMultiplierDuration += Time.DeltaTimeF;
if (currMultiplierDuration >= maxMultiplierDuration)
@ -113,7 +113,7 @@ public class GameManager : Script
}
else
{
multiplierText.GetComponent<Transform>().LocalScale = Vector3.Zero;
//multiplierText.GetComponent<Transform>().LocalScale = Vector3.Zero;
}
if ((timer > 0 && totalItemCount <= 0) || Input.GetKeyDown(Input.KeyCode.F1))

View File

@ -11,6 +11,9 @@ namespace SHADE_Scripting.UI
{
EASE_IN_SINE,
EASE_OUT_SINE,
EASE_OUT_BOUNCE,
EASE_IN_BOUNCE,
EASE_INOUT_BOUNCE
}
public static class EasingHelper
@ -28,7 +31,20 @@ namespace SHADE_Scripting.UI
{
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;
}
@ -44,5 +60,37 @@ namespace SHADE_Scripting.UI
return (float)(1.0f - Math.Sin(value * Math.PI) / 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

@ -30,16 +30,30 @@ namespace SHADE_Scripting.UI
public float clickScale = 0.9f;
[NonSerialized]
private TweenThread thread;
[NonSerialized]
private bool tweening = false;
[NonSerialized]
private float currentScale = 1.0f;
protected override void awake()
{
onHoverEnterACHandler = SHADE.Audio.CreateAudioClip(onHoverEnterSound);
onHoverExitACHandler = SHADE.Audio.CreateAudioClip(onHoverExitSound);
onClickACHandler = SHADE.Audio.CreateAudioClip(onClickSound);
onReleaseACHandler = SHADE.Audio.CreateAudioClip(onReleaseSound);
}
protected override void start()
{
thread = TweenManager.CreateTweenThread(0.1f, 0.9f, 1.0f, EASING_METHOD.EASE_IN_SINE);
Transform transform = GetComponent<Transform>();
if (transform == null)
return;
@ -55,35 +69,53 @@ namespace SHADE_Scripting.UI
{
if (onClickSound != "")
onClickACHandler.Play();
transform.LocalScale = defaultScale * clickScale;
tweening = true;
if(thread != null)
thread.Reset(currentScale,clickScale);
});
ui.OnRelease.RegisterAction(() =>
{
if (onReleaseSound != "")
onReleaseACHandler.Play();
transform.LocalScale = defaultScale;
tweening = true;
if (thread != null)
thread.Reset(currentScale, 1.0f);
});
ui.OnHoverEnter.RegisterAction(() =>
{
if(onHoverEnterSound != "")
if (onHoverEnterSound != "")
onHoverEnterACHandler.Play();
transform.LocalScale = defaultScale * hoverScale;
tweening = true;
if (thread != null)
thread.Reset(currentScale, hoverScale);
});
ui.OnHoverExit.RegisterAction(() =>
{
if (onHoverExitSound != "")
onHoverExitACHandler.Play();
transform.LocalScale = defaultScale;
tweening = true;
if (thread != null)
thread.Reset(currentScale, 1.0f);
});
}
protected override void update()
{
Transform transform = GetComponent<Transform>();
if (transform == null)
return;
if (tweening == true && thread != null)
{
Debug.Log("Tweening value " + thread.GetValue());
transform.LocalScale = defaultScale * thread.GetValue();
currentScale = thread.GetValue();
if (thread.IsCompleted())
tweening = false;
}
}

View File

@ -14,7 +14,17 @@ namespace SHADE_Scripting.UI
public int minValue = 0;
public int maxValue = 0;
protected override void start()
{
Slider slider = sliderObj.GetComponent<Slider>();
TextRenderable text = GetComponent<TextRenderable>();
if (slider != null && text != null)
{
text.Text = ((int)(slider.GetValue() * (maxValue - minValue) + minValue)).ToString();
}
}
protected override void update()
{
Slider slider = sliderObj.GetComponent<Slider>();

View File

@ -70,7 +70,8 @@ namespace SHADE
beginCursorPos = ImGui::GetCursorScreenPos();
viewportMousePos = { mousePos.x - beginCursorPos.x, mousePos.y - beginCursorPos.y };
gfxSystem->GetMousePickSystem()->SetViewportMousePos(viewportMousePos);
ImGui::Image((ImTextureID)descriptorSet, { beginContentRegionAvailable.x, beginContentRegionAvailable.y });
SHVec2 viewportSize = CalculateWindowSize(beginContentRegionAvailable);
ImGui::Image((ImTextureID)descriptorSet, { viewportSize.x, viewportSize.y });
if (ImGui::IsWindowHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Right))
{

View File

@ -432,16 +432,25 @@ namespace SHADE
if (comp.GetValue() < 0.0f)
comp.value = 0.0f;
}
if (comp.GetValue() != tempValue)
try
{
//Set shader value.
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
if (renderable)
{
if (comp.GetValue() != material->GetProperty<float>("data.sliderThreshold"))
{
//Set shader value.
material->SetProperty("data.sliderThreshold", comp.GetValue());
material->SetProperty("data.sliderThreshold", comp.GetValue());
}
}
}
catch (...)
{
}

View File

@ -903,6 +903,12 @@ namespace SHADE
{
return pair->type;
}
/* Sort */
System::String^ sortKeyAccessor(System::Type^ type)
{
return type->Name;
}
}
void ScriptStore::refreshScriptTypeList()
@ -926,6 +932,10 @@ namespace SHADE
Func<Pair^, Type^>^ selector = gcnew Func<Pair^, Type^>(selectorFunc);
scriptTypeList = Enumerable::Select(whereResult, selector);
/* Sort: By Alphabetical Order */
Func<Type^, String^>^ sorter = gcnew Func<Type^, String^>(sortKeyAccessor);
scriptTypeList = Enumerable::OrderBy(scriptTypeList, sorter);
// Log
std::ostringstream oss;
oss << "[ScriptStore] Successfully retrieved references to " << Enumerable::Count(scriptTypeList)