Sample of Stamina(GS2 UIKit for Unity)

sample implementation of GS2-Stamina functionality using GS2 UIKit for Unity

Implement the Stamina function.

Repository

https://github.com/gs2io/gs2-uikit-for-unity-sample/tree/main/Stamina

GS2-Deploy template

https://github.com/gs2io/gs2-uikit-for-unity-sample/blob/main/Stamina/initialize_stamina_template.yaml

Project Description

img.png

Open the project and you will see the above.

img_1.png

When executed, the remaining amount of stamina and the UI for stamina operations will be displayed as shown here.

img_2.png

First, click the “Consume(5)” button.

img_3.png

Having consumed stamina, the remaining amount is displayed as “45/50” and a countdown is shown until it is recovered.

Next, click the “Recover(10)” button.

img_4.png

The remaining amount of stamina will be “55/50”. The countdown will not be displayed again because the maximum value has been exceeded.

Project Description

img_5.png

Note the hierarchy of the scene.

Canvas/StaminaWindow

img_6.png

Gs2StaminaOwnStaminaContext

Specifies the stamina of GS2-Stamina handled by the node under this GameObject.

img_8.png img_7.png

In this case, we specify a stamina named Stamina in the namespace stamina-0001 of GS2-Stamina.

Canvas/StaminaWindow/Stamina.

Gs2StaminaStaminaEnabler

After loading the Stamina, activate StaminaValue.

Canvas/StaminaWindow/Stamina/StaminaValue/Slider

img_9.png

Gs2StaminaStaminaProgress.

Gets the percentage of the current stamina value relative to the maximum value, from 0.0 to 1.0. The value is rounded to 1.0 when the maximum value is exceeded.

The result obtained is passed to OnUpdate(Single) and reflected in the Slider value.

Canvas/StaminaWindow/Stamina/StaminaValue/Slider/Label

img_10.png

Gs2StaminaStaminaValueEnabler.

Enables a GameObject based on whether the maximum value of stamina has been reached.

Canvas/StaminaWindow/Stamina/StaminaValue/Slider/Label/NextRecoverAt

img_11.png

Gs2StaminaStaminaNextRecoverAtFetcher.

Gets the date and time when stamina will be restored next time. The result is called back to OnUpdate(int64) and the value is reflected in Gs2CoreTimeSpanLabel.

Gs2CoreTimeSpanLabel.

Formats the remaining time until the next recovery of stamina into the format specified by Format. The formatted text is called back to OnUpdate(String), from which the value is reflected in the Text component.

Process/Gs2AutoLogin

A prefab is set up to perform the login process.

sample of Account, please refer to the explanation there.