developer_center:developer_editor:how_to_use_the_io_battle_gameplay_-_play_variables_in_one_game

Introduction
In the previous chapters of variables, we learned about the definition and function of variables and the difference between private variables and global variables, and reinforced the learning through practical exercises.
→ Variable (to understand variables by explaining the concept, function, naming rules, variable types)
→ How to use the Private Variable (case)
→ How to use the Global Variable (case)

Guide
In this lesson, we will design and implement an IO battle game to further strengthen the skills of practicing variables. Specific knowledge is as follows
1. IO Battle Concept and simple gameplay design
2. Strengthen the understanding of global variables and private variables
3. Variables application in trigger logic

All the knowledge about variables in this section has been learned in the previous chapters. If there is something unclear during the reading process, it is recommended to go back to the previous lessons and review it.

Without further ado, follow the teacher's pace!
IO Battle Concept
First of all, let's briefly understand what an IO battle game is.
IO battle games usually have the characteristics of multiplayer real-time battle, instant play, simple growth system, small map, etc., which can be considered as a small casual battle game.

Next, let's determine the specific gameplay we want to do, and divide which attributes need to be set as private variables or global variables.

Gameplay
! In order to focus on the learning of variables, we try to keep the gameplay as simple as possible.

Players are divided into two teams, each with only one player. Players can obtain blood volume, attack power and size upgrades by picking up fireflies on the map.
Victory conditions: Players earn points by picking up fireflies and defeating each other. When the game time ends, the team with the most points wins.

Variable Settings
Private variables: the player's HP, Attack Damage, and Body Size. (these variables will increase as the number of fireflies acquired by the player increases)
Global variables: Team Scores.

Global Variable Settings
Set two global variables, name them “Red Team Score” and “Blue Team Score”, with an initial value of “0”.

Private Variable Settings
Set three private variables: Attack (default value 0), HP (default value 100), Size (Default value 0.3)

Game Scene
Regarding the game scene, developers only need to set up the scene according to their imagination. Considering the principle of resource fairness in IO battle game design, you can try to make a symmetrical design.

If we put the original fireflies directly on the map, they will fly around, so we need to use plug-ins to improve the properties of fireflies.
Open the plug-in → find the creature plugin → add creature → create new → edit original creatures → find the firefly → cancel the movement → save → load into the game → then find the firefly in the backpack and place them on the map.

Basic Setting
- In Basic Settings→ Team Settings→ Set two teams, the red team and the blue team. The maximum number of each team is 1 person. (you can also set the maximum team number according to your scene size)
- In Basic Settings → Game Goal → Set the game time limit to 6 minutes, and the winning condition is score.
- Initial item - a sword.

Game Logic
Global Variable Application
First we set the global variable - the trigger logic for the player's score. The scoring logic is that a player gets 2 points for a star, and 6 points for defeating a player once.

Step 1: Create a trigger to check if the player touches the firefly creature. If yes, the player gets 2 points, and the firefly is destroyed.

Trigger Event :
- Triggered when any player collides
Trigger Condition:
- The target creature at the event is firefly
- The player in the trigger event is in the red team

Trigger Action:
- The value of “red team score” = “red team score” + 2
- Red team score = the variable “red team score”
- Destroy the creature

Next, we make a copy of the trigger “Red Team Score” and change the corresponding parameters for Blue Team scoring.

(Additional thinking) Please try to use the same logic to set two triggers to judge the red and blue team to get score when they defeat the opponent.

Private Variable Application
Set a trigger to initialize the private variable value of the player who is just entering the game.

Assume that every time a player gets a firefly, its private variable HP +10, attack +20, and model +0.2. Then, we set a trigger in the following way to realize the growth of the player's private attributes. Let's set maximum health growth first.

After that, we set the player's Attack and HP according to the same idea. (quick modification by copy action)

Finally, we bind the trigger “personal grows” and the “team score” trigger together. The reason for that is when the team score is triggered, the player's attributes will grow, and “team score” is the trigger event for “personal grows”.

Congratulations, you have completed all the content. Let's take a look at the complete battle version!

This is the charm of variables, which can easily and flexibly manipulate various attributes of the game, making the development of games more flexible and diverse! Because of that, we must cherish variables, and use more variables in the future development process!

developer_center/developer_editor/how_to_use_the_io_battle_gameplay_-_play_variables_in_one_game.txt · Last modified: 2023/05/24 03:19 by admin