About Unity programming system for production tasks UGUI

Copyright Notice:

  • Original article published on the blog Park "You dream maker culture," the blog space (URL: http://www.cnblogs.com/raymondking123/) and micro-channel public number "dream maker culture"
  • You are free to reprint, but must include the full copyright notice!

Show results:

The basic interface

1: a look at the two scripts for managing data

This TaskMgr script is the most basic definition of the two properties for the task, then the task will be to make a list and go down the list to add data (that is, the type of task typeid), but he only type of task, there is no specific task information, task specific information written in the script data inside another, then another effect of this script is loaded preform, setting his position, he was the first of several tasks, and what type, there is a word not to cut, that the role of the sentence is the task from the list inside out, by way of indexing

The MyTaskInfo data script that defines specific information about different tasks, define tasks a parent class and subclass inherits rewrite the virtual function method, and specific information about this character is the presence of dictionary inside, you can find him additional information by id (dictionary storage is stored key-value pairs)

This is a subclass inherits the parent class

2: Then talk about the function of each button on the screen is how to achieve

(1) the task list, this button when (onclick ()) Press the task list interface script calls hung

You could set setactive gameobject when onclick, the result of a beginning is not very familiar with, use the code to implement, through a bool variable control switch, but later changed a bit and found setactive not very sensitive sometimes point out.

(2)接受按钮 这个按钮是经过了两次判断的,第一次是判断你是不是已完成,如果是已完成,那这个按钮就会将这个任务的信息从已接任务转移到已完成任务(改变他的父节点),然后再将这个按钮设置成不能再点击;如果不是已完成(接受),那就往我的任务背包里边添加任务信息,此时在进行第二次判断,如果任务的等级大于你自身的等级,那么任务就接受不了,会在任务背包里显示接受不了任务,接受按钮也不会改变,如果自己的等级等于或者大于任务的等级,那么任务就是可以接受的,在自己的任务背包里会显示任务的具体内容,然后接受按钮也会变成已领取

(3)删除按钮 这个就比较简单,直接删除掉这个gameobject(接受,删除这两个按钮都是通过onclick来实现挂在预制体生成的任务上面的,所以删除的时候直接删掉这个gameobject就可以了)

(4)我的任务 这个按钮功能的实现和任务列表的实现是一样的

(5)已接任务和以完成任务我是设置的toggle进行切换

(6)提升一级 这个实现的脚本呢是挂在LVL这个text上的,就是将等级加一然后存下来(用于和人物等级进行比较)然后显示到屏幕上

3:最后说一下这个tasktip 这个我是在任务预制体上的那个脚本里用的两个接口 IPointerEnterHandler ,IPointerExitHandler当鼠标放到这个任务上的时候就会调用挂在tasktip上的show函数(把tasktip上的脚本写成了单例),这个show函数的作用第一个是将setactive设置为true;第二个是通过传进来的id找到这个任务的类型以及其他的基本信息,然后再将这个任务的具体信息写到tasktip上


Guess you like

Origin www.cnblogs.com/raymondking123/p/11306826.html