====== Online Gift Packs ====== (12-minutes reading) ===== Guide ===== **By reading the full text, you will master the online gift package based on the UI editor, which specifically covers the following points:** - UI real-time text refresh realized by looping triggers. - Some skills in UI interface creation and trigger creation. - Judgment of conditions when rewards are issued. - Rewards issued after conditions are met. Note: The content of the online gift package function can only be realized by using the UI editing function in the game. UI editing related tutorials:\\ * **[[UI Editor|]]** \\ * **[[UI Store|]]** \\ ===== Effect Display ===== {{https://wiki.miniworldgame.com/lib/exe/fetch.php?media=:developer_center:developer_editor:online_gift_packs:online_gift_packs1.gif?600&nolink|}} ===== UI Making ===== **First of all, we need to make the basic UI interface to complete the subsequent content.**\\ **Create the UI component content as shown in the picture below:**\\ Make the main interface part of the online reward interface. Note that the "Online Duration" text box is an independent component created separately to facilitate subsequent trigger settings. And the "Receiving" needs to be a button component.\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs2.png?600&nolink|}} ===== Trigger setting ===== ==== Online Timing ==== Create a private timer variable "Online Time" to record the player's online time.\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs3.png?600&nolink|}} Then create a new trigger "Online Time", set the event to "When any player enters the game", and start the "Online Time" timer of the player who triggered the event.\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs4.png?600&nolink|}} After setting up the trigger to record the player's online time, we also need to know how long he is currently online when the player opens the interface. \\ So continue to create two new triggers "Duration Refresh 1" and "Duration Refresh 2", and set the event of "Duration Refresh 1" to "Every second the game runs", and set the action to "Run 'Duration Refresh 2' for all players" device".\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs5.png?600&nolink|}} Then add a new action for the "Duration Refresh 2" trigger, and set the text content of the independent text element "Online Duration" mentioned in the previous steps to string concatenation.\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs6.png?600&nolink|}} It is not intuitive enough if the time duration is only displayed in seconds, so we also need to convert seconds to minutes.\\ In the String Concatenation, we add two more string concatenations with the purpose of changing the two text contents to "min" and "s". The specific settings steps are as follows:\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs7.png?600&nolink|}} Then set the first "Value to String" space as shown in the figure below, divide the player's online time by 60 and round down to convert it to the player's online minutes.\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs8.png?600&nolink|}} It is also necessary to divide the online time of the player by 60 and then take the remainder as the content of the second "convert the value into a string", which is the “Seconds” part of the online time.\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs9.png?600&nolink|}} After setting the triggers of the above steps, the effect of online duration timers can be realized.\\ {{https://wiki.miniworldgame.com/lib/exe/fetch.php?media=:developer_center:developer_editor:online_gift_packs:online_gift_packs10.gif?600&nolink|}} ==== Reward collection ==== Make related functions for players to receive rewards after meeting the conditions. First, create two triggers of "receive success" and "receive failure" to realize the two situations that may occur when the player presses the button.\\ **Receive success**: The first tier of rewards currently designed is for the player to be online for 5 minutes, which is 300 seconds. So set the "receive success" trigger as follows:\\ Event: "Any button on the current interface is released".\\ Conditions: The button is the "Receive" button; the player's private timer "Online Time" is greater than or equal to 300.\\ Action: Make the player obtain the item type indicated by the UI icon, and then hide the claim button.\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs11.png?600&nolink|}} **Receive failure**: The condition is that the player's online time is less than 300, and the action "show the window text to the player".\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs12.png?600&nolink|}} After the above setting, the function of issuing rewards according to the player's online time is completed.\\ {{https://wiki.miniworldgame.com/lib/exe/fetch.php?media=:developer_center:developer_editor:online_gift_packs:online_gift_packs13.gif?600&nolink|}} If you want to set rewards for different stages, you only need to copy the original UI elements and arrange them, and then modify the prop images.\\ {{https://wiki.miniworldgame.com/lib/exe/fetch.php?media=:developer_center:developer_editor:online_gift_packs:online_gift_packs14.gif?600&nolink|}}\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs15.png?600&nolink|}}\\ Next, copy the entire "reward claim" trigger group and rename it "reward claim 2", and then modify the corresponding conditions and reward content issued.\\ {{:developer_center:developer_editor:online_gift_packs:online_gift_packs16.png?600&nolink|}} If you need more levels of rewards when designing the interface, you only need to copy and modify the corresponding triggers and corresponding components.