Novice guide design (1)

Novice guide design


foreword

For all game designs, novice guidance is already a necessary module to lead players to quickly understand the gameplay in advance, but because the guidance involves too many functional modules, its code is highly coupled with other modules, how to design a set of efficient, and The independent novice guide is a skill that the client program must master.

This article uses U3D as the development platform to design a guiding framework, aiming to help more front-ends and open up an idea.


1. The saved format of the novice guide

General configuration information is usually saved in Excel, but some nested formats cannot be stored, or it is not convenient to store and read, so we use json for storage.

2. Novice guide storage structure

1. The main structure of the novice guide

The code is as follows (example):

public class MainGuideData
{
    
    
    // 引导的名称
    public string GuideName; 
    // 引导的id;
    public int GuideId;
    // 是否强制引导
    public int ForceGuide;
	// 前置引导id;
	public int PreId;
	// 后置引导id;
	public int PostId;
	// 引导优先级
	public int Priority;
	// 中断后重新触发的子进度索引;
	public int RestartSubIndex;
	// 保存进度的子进度索引;
	public int SaveSubIndex;
	// 存出的子引导任务;
	public List<SubGuideData> SubGuideList;
}

Each guide is usually composed of a series of sub-guides, and there may be a certain pre-post relationship between each guide, for example, only when the player is guided to collect equipment. Only then will there be guidance for players to strengthen or upgrade their equipment.

  • ForceGuide represents whether it is a forced guide, the entire screen will be blocked by the guide mask, and only the ones that need to be clicked or dragged will be highlighted, and the player can only operate in the highlighted position.
  • The purpose of PreId and PostId is to string all guides into multiple trees, each tree represents a series of independent guides, and the leaf nodes in each tree represent the sequence of guides.
  • Priority priority is when there are multiple guides to trigger at the same time, but for players, they can only be triggered one by one according to the priority, and this field is needed at this time.
  • RestartSubIndex, the boot step that is retriggered after interruption. For some non-mandatory guides, the player may choose another button or entry in the middle and leave the current interface due to the guide. execute in one step.
  • SaveSubIndex When the sub-guidance is executed to this step, although there may be boot tasks later, it needs to be saved to indicate that the boot has been completed. If the boot is interrupted at this time, or the player kills the process and logs in again, the boot flag has been completed. , and will not execute the boot again.
  • SubGuideList The subguide list, which represents all the specific subguides of this guide, and its subguides include specific performances, such as dialogues, highlighted buttons, and so on.

2. Subboot structure

The sub-guidance is a specific guidance, and the guidance generally includes trigger timing, trigger conditions, and post-trigger performance. Trigger timing For example, when the player upgrades, the player opens the specified interface, the player obtains items, etc. There are many types of these, and the corresponding parameters are also different. It is very difficult to define a general structure. We can use Dictionary to store configuration information, and use different keys and values ​​as parameters for corresponding trigger conditions. There are also various conditions, such as whether the player has reached the number
and whether the player has There are many specific conditions for having specified equipment, whether the specified interface is currently open, etc. We can also use Dictionary for storage configuration as with trigger timing.
After triggering, it also uses Dictionary for storage configuration. Therefore, we define a public GuideItemData structure

public class GuideItemData
{
    
    
	// 具体的Action, Conditon,或者Trigger的类型;
    public string Type;
    // 具体的参数信息;
    public Dictionary<string, string> Params;
}

With the GuideItemData structure, we can start to define the structure of SubGuideData

  • To guide a trigger timing, we need a Triggers field, which is a list, because there may be one or more trigger conditions.

  • When any one of the trigger conditions is triggered, we need to check whether the current trigger condition is met, and if it is met, the performance will be played, all of which require a Conditions.

  • Again, after the current trigger, the trigger condition is met, and the corresponding performance needs to be executed. We need an Actions to display the performance. Usually,
    these three fields can meet most of the guidance requirements.
    Finally, when there is a performance, when do we end the current performance, and then proceed to the next sub-guidance, an end trigger is needed to complete the triggering of the current sub-guidance. Let's call this list of triggers Dones.

  • Usually, this structure can meet the needs of mandatory guidance, but for non-mandatory guidance tasks, for example, I am currently talking in the main scene of the battle, and the player does not click on the dialogue at this time, but clicks on the battle scene. At this time, we should Interrupt the current boot, and let it boot from RestartSubIndex again, but how to judge that the boot should be interrupted at present, all need a condition that indicates that the current Action needs to be maintained. We named this StayConditions.

  • Usually, the player executes the donetrigger once to end the current action and proceed to the next sub-guidance. However, sometimes, it may be necessary to execute the donetrigger multiple times. After knowing that the conditions are met, the current action is ended and the next sub-guidance is completed. For example, the player is guided to continuously upgrade the equipment. At level 5, follow-up guidance is executed, so a DoneConditions is also needed.

  • Sometimes, an Action may change the real game to a certain state (such as the game is paused), and when Done is executed, it will be restored again (game resume). At this time, we also need a DoneActions. Finally, our sub-guided
    structure as follows

public class SubGuideData
{
    
    
	// 引导名称
	public string Name;
	// 引导触发器列表
	public List<GuideItemData> Triggers;
	// 引导触发条件
	public List<GuideItemData> Conditions;
	// 引导结束触发器;
	public List<GuideItemData> Dones;
	// 引导结束条件
	public List<GuideItemData> DoneConditions;
	// 引导Action保持需要的条件;
	public List<GuideItemData> StayConditions;	
	// 引导结束后的动作表现;
	public List<GuideItemData> DoneActions;
}

With these structures, we can use this structure to configure a json data, representing a guide,
you can see the following guide example

{
    
    
    "GuideList":
    [
        {
    
    
            "GuideId":101,
            "GuideName":"出来咋到",
            "PreId":-1,
            "PostId":102,
            "Priority":0,
            "ForceGuide":1,
            "SubGuide":
            [
                {
    
    
                    "Name":"初来咋到-说明文字1",
                    "Triggers":
                    [
                        {
    
    
                            "Type":"EnterScene",
                            "Params":
                            {
    
    
                                "SceneName":"MainScene"
                            }
                        }
                    ],
                    "Conditions":[
                        {
    
    
                            "Type":"PanelVisible",
                            "Params":
                            {
    
    
                                "UIName":"HallPanel"
                            }
                        },
                        {
    
    
                            "Type":"PlayerLevel",
                            "Params":
                            {
    
    
                                "Value":1
                            }
                        }
                    ],
                    "Actions":
                    [
                        {
    
    
                            "Type":"Dialog",
                            "Params":
                            {
    
    
                                "DialogType":"Left",
                                "Content":"欢迎{PlayerName}勇士来到{BornName}",
                                "ShowIntervalTime":0.05
                            }
                        }
                    ],
                    "Dones":
                    [
                        {
    
    
                            "Type":"ButtonClick",
                            "Params":
                            {
    
    
                                "UIName":"GuidePanel",
                                "ButtonName":"dialog"
                            }
                        }
                    ]
                },
                {
    
    
                    "Name":"初来咋到-点击装备",
                    "Triggers":
                    [
                        {
    
    
                            "Type":"Sequence"
                        }
                    ],
                    "Actions":
                    [
                        {
    
    
                            "Type":"ShowButtonAnim",
                            "Params":
                            {
    
    
                                "UIName":"HallPanel",
                                "ButtonName":"BtnEquipment"
                            }
                        }
                    ],
                    "Dones":
                    [
                        {
    
    
                            "Type":"ButtonClick",
                            "Params":
                            {
    
    
                                "UIName":"HallPanel",
                                "ButtonName":"BtnEquipment"
                            }
                        }
                    ]
                }
            ]
        }
    ] 
}

Summarize

When conducting bootstrap design, it is first necessary to design the corresponding data structure according to the requirements, and finally perform the corresponding coding.

Guess you like

Origin blog.csdn.net/zhush_2005/article/details/125143944