Experience(GS2 UIKit for Unity) sample

Sample implementation of GS2-Experience functionality using GS2 UIKit for Unity

Implement experience weight and level functionality.

Repository

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

GS2-Deploy template

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

Project Description

img.png

Open the project and you will see the above.

img_1.png

Run it and you will see the current level, level cap, and progress bar like this.

img_2.png

At the bottom of the screen, there is a button for operating experience.

Let’s add 100 experience with “Add Experience(100)”.

img_3.png

Experience has been added and the level has increased from 1 to 3.

Let’s add 100 to the experience value again with “Add Experience(100)”.

img_4.png

The level has increased to 5 and the level cap has been reached. To make it easier to understand this status, the level value has been changed from black to red.

Let’s press “Add Rank Cap” to raise the level cap.

img_5.png

The level cap has been raised from 5 to 6. As a result, the current level has not reached the level cap, so the level notation has also been changed back from red to black.

Project Description

img_6.png

Note the hierarchy of the scene.

Canvas/ExperienceWindow

img_7.png

Gs2ExperienceExperienceModelContext

Specifies the experience model to be handled by the node under this GameObject.

img_9.png img_8.png

In this case, we specify an experience model named Experience in the namespace experience-0001 in GS2-Experience.

Gs2ExperienceOwnStatusContext.

Specifies the status of itself handled by the node under this GameObject.

img_11.png img_10.png

This time, we specify an experience model named Experience and a property ID named player in the namespace experience-0001 in GS2-Experience.

Gs2ExperienceOwnStatusFetcher.

Gets the status specified in Gs2ExperienceOwnStatusContext.

Canvas/ExperienceWindow/Experience/…/RankValue

img_12.png

Gs2ExperienceStatusEnabler.

Enables/disables ValueContainer / Slider depending on status loading.

Canvas/ExperienceWindow/Experience/…/RankValue/ValueContainer

img_13.png

Gs2ExperienceStatusRankValueEnabler.

Enables or disables Value / ReachMaxValue depending on whether the status rank has reached or not reached the maximum value.

Canvas/ExperienceWindow/Experience/…/RankValue/ValueContainer/Value

img_14.png

Gs2ExperienceStatusLabel.

The current rank value and rank cap value are formatted in the format specified by Format. The formatted result is called back to OnUpdate(String) and is reflected in the Text component. The Text component here specifies black as the text color.

Canvas/ExperienceWindow/Experience/…/RankValue/ValueContainer/ReachMaxValue

img_14.png

Gs2ExperienceStatusLabel.

The current rank value and rank cap value are formatted in the format specified by Format. The formatted result is called back to OnUpdate(String) and is reflected in the Text component. The Text component here specifies red for the text color.

Canvas/ExperienceWindow/Experience/…/Slider

img_15.png

Gs2ExperienceStatusProgress.

Returns the progress from 0.0 to 1.0 in the current rank until the next rank up experience is reached in the OnUpdate(Single) callback. The value is reflected in Slider.value.

Canvas/ExperienceWindow/Input/AddExperience

Gs2ExchangeRateModelContext.

Sets the GS2-Exchange exchange rate that adds 10 to the experience value.

img_19.png img_18.png

Here we specify an exchange rate named AddExperience in the GS2-Exchange namespace named exchange-0006.

Canvas/ExperienceWindow/Input/AddExperience/Gs2ExchangeExchangeAction

img_16.png

You can add a prefab from this context menu.

img_17.png

By specifying the exchange quantity in Count and activating the prefab, the exchange rate specified in Gs2ExchangeRateModelContext will be executed.

OnExchangeComplete(String)

can be set to a callback when the exchange process is successfully completed, and disables itself.

Canvas/ExperienceWindow/Input/AddExperienceX10

Canvas/ExperienceWindow/Input/AddExperience Sets the GS2-Exchange exchange rate that adds 10 to the experience value as in.

Canvas/ExperienceWindow/Input/AddExperienceX10/Gs2ExchangeExchangeAction

Set the exchange quantity to 10.

Canvas/ExperienceWindow/Input/AddRankCap

Sets the GS2-Exchange exchange rate at which to add one rank cap.

Process/Gs2AutoLogin

A prefab is set up to perform the login process.

sample of Account, please refer to the explanation there.