Gameplay UI on Level 2. #390

Merged
maverickdgg merged 3 commits from SP3-20-UI-System into main 2023-03-04 12:42:43 +08:00
7 changed files with 109 additions and 8 deletions
Showing only changes of commit 0984eee6bb - Show all commits

View File

@ -4833,14 +4833,14 @@
Enabled: true Enabled: true
- EID: 10 - EID: 10
Name: Pause Canvas Name: Pause Canvas
IsActive: true IsActive: false
NumberOfChildren: 4 NumberOfChildren: 4
Components: Components:
Canvas Component: Canvas Component:
Canvas Width: 1920 Canvas Width: 1920
Canvas Height: 1080 Canvas Height: 1080
Scale by canvas width: false Scale by canvas width: false
IsActive: true IsActive: false
Scripts: ~ Scripts: ~
- EID: 8 - EID: 8
Name: ResumeButton Name: ResumeButton
@ -13436,3 +13436,42 @@
Scripts: Scripts:
- Type: SHADE_Scripting.UI.TweenManager - Type: SHADE_Scripting.UI.TweenManager
Enabled: true Enabled: true
- EID: 524
Name: Canvas
IsActive: true
NumberOfChildren: 1
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 525
Name: StealFoodLogo
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 0, y: 0, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 127459277
IsActive: true
UI Component:
Canvas ID: 524
Hovered: false
Clicked: false
IsActive: true
Scripts:
- Type: SHADE_Scripting.UI.StealFoodPopUp
Enabled: true
popInDuration: 0.5
popOutDuration: 0.5
stayDuration: 1
rotationAmt: 1800
scaleAmtX: 538
scaleAmtY: 377

View File

@ -90,6 +90,11 @@ public class GameManager : Script
protected override void update() protected override void update()
{ {
if (Input.GetKeyDown(Input.KeyCode.G))
ItemScored();
if (GamePause) if (GamePause)
{ {
return; return;

View File

@ -52,12 +52,12 @@ namespace SHADE_Scripting.UI
private static float EaseInSine(float value) private static float EaseInSine(float value)
{ {
return (float)(1.0f - Math.Cos((value * Math.PI) / 2.0f)); return (float)(1.0f - Math.Cos((value * Math.PI / 2.0f) ));
} }
private static float EaseOutSine(float value) private static float EaseOutSine(float value)
{ {
return (float)(Math.Sin(value * Math.PI) / 2.0f); return (float)(Math.Sin(value * Math.PI / 2.0f) );
} }

View File

@ -11,6 +11,7 @@ namespace SHADE_Scripting.UI
{ {
[NonSerialized] [NonSerialized]
private TweenThread sizeThread; private TweenThread sizeThread;
private TweenThread sizeInvertThread;
private TweenThread alphaThread; private TweenThread alphaThread;
@ -20,6 +21,7 @@ namespace SHADE_Scripting.UI
private bool showMultiplier = false; private bool showMultiplier = false;
const float sizeUpDuration = 0.1f;
[NonSerialized] [NonSerialized]
private Vector3 defaultScale; private Vector3 defaultScale;
@ -27,6 +29,7 @@ namespace SHADE_Scripting.UI
protected override void start() protected override void start()
{ {
sizeThread = TweenManager.CreateTweenThread(0.0f, maxSize, minSize, EASING_METHOD.EASE_IN_SINE); sizeThread = TweenManager.CreateTweenThread(0.0f, maxSize, minSize, EASING_METHOD.EASE_IN_SINE);
sizeInvertThread = TweenManager.CreateTweenThread(sizeUpDuration, minSize, maxSize, EASING_METHOD.EASE_IN_SINE);
alphaThread = TweenManager.CreateTweenThread(0.0f, 1.0f, minAlpha, EASING_METHOD.EASE_OUT_SINE); alphaThread = TweenManager.CreateTweenThread(0.0f, 1.0f, minAlpha, EASING_METHOD.EASE_OUT_SINE);
Transform transform = GetComponent<Transform>(); Transform transform = GetComponent<Transform>();
if (transform != null) if (transform != null)
@ -43,8 +46,29 @@ namespace SHADE_Scripting.UI
protected override void update() protected override void update()
{ {
Transform transform = GetComponent<Transform>(); Transform transform = GetComponent<Transform>();
if (transform != null && showMultiplier == true) if (transform != null && showMultiplier == true)
{ {
if(!sizeInvertThread.IsCompleted())
{
transform.LocalScale = defaultScale * sizeInvertThread.GetValue();
Renderable rend = GetComponentInChildren<Renderable>();
if(rend)
{
rend.Material.SetProperty<float>("data.alpha", 1.0f);
}
TextRenderable text = GetComponent<TextRenderable>();
if (text)
{
Color clr = text.TextColor;
text.TextColor = new Color(clr.r, clr.g, clr.b, 1.0f);
}
return;
}
if(sizeThread.IsCompleted()) if(sizeThread.IsCompleted())
{ {
transform.LocalScale = Vector3.Zero; transform.LocalScale = Vector3.Zero;
@ -53,7 +77,18 @@ namespace SHADE_Scripting.UI
else else
{ {
transform.LocalScale = defaultScale * sizeThread.GetValue(); transform.LocalScale = defaultScale * sizeThread.GetValue();
GetComponentInChildren<Renderable>().Material.SetProperty<float>("data.alpha",alphaThread.GetValue());
Renderable rend = GetComponentInChildren<Renderable>();
if (rend)
{
rend.Material.SetProperty<float>("data.alpha", alphaThread.GetValue());
}
TextRenderable text = GetComponent<TextRenderable>();
if(text)
{
Color clr = text.TextColor;
text.TextColor = new Color(clr.r,clr.g,clr.b,alphaThread.GetValue() * 1.3f);
}
} }
} }
} }
@ -62,9 +97,10 @@ namespace SHADE_Scripting.UI
public void ShowMultiplier(int multiplier, float duration) public void ShowMultiplier(int multiplier, float duration)
{ {
GetComponent<TextRenderable>().Text = $"X {multiplier}"; GetComponent<TextRenderable>().Text = $"X {multiplier}";
sizeThread.duration = duration; sizeThread.duration = duration + sizeUpDuration;
alphaThread.duration = duration; alphaThread.duration = duration + sizeUpDuration;
sizeInvertThread.Reset();
sizeThread.Reset(); sizeThread.Reset();
alphaThread.Reset(); alphaThread.Reset();
showMultiplier = true; showMultiplier = true;

View File

@ -19,6 +19,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Assets/NativeAsset.hxx" #include "Assets/NativeAsset.hxx"
#include "Utility/Convert.hxx" #include "Utility/Convert.hxx"
namespace SHADE namespace SHADE
{ {
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
@ -55,4 +56,16 @@ namespace SHADE
GetNativeComponent()->SetFont(value.NativeObject); GetNativeComponent()->SetFont(value.NativeObject);
} }
} }
Color TextRenderable::TextColor::get()
{
return Convert::ToCLI(GetNativeComponent()->GetColour());
}
void TextRenderable::TextColor::set(Color value)
{
GetNativeComponent()->SetColour(Convert::ToNative(value));
}
} }

View File

@ -60,6 +60,13 @@ namespace SHADE
FontAsset get(); FontAsset get();
void set(FontAsset value); void set(FontAsset value);
} }
property Color TextColor
{
Color get();
void set(Color value);
}
}; };
} }

View File

@ -22,6 +22,7 @@ namespace SHADE
: Component(entity) : Component(entity)
{} {}
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Properties */ /* Properties */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/