开始用FairyGUI和KBEngine重写uMMORPG

来源:互联网 发布:csgom4a1皮肤知乎 编辑:程序博客网 时间:2024/06/05 06:19

uMMORPG这个插件很棒!MMORPG里基本的东西都有了,登录、选角色、战斗、技能、背包、换装等等,除了场景跳转,因为UNET还不支持。这么说来UNET还是一个处在实验中的东西。uMMORPG的代码很清晰,如果用Photon实现的话,先不说Photon要收费,代码上肯定没有用UNET实现这么清晰了,官网上说只有3500行,我自己重写了下,感觉代码量也不大。uMMORPG的资源拿来做实验也不错,如题,我打算用这两个东西重写下,FairyGUI、KBEngine是目前为止我发现的最棒的GUI、Server解决方案。

在这里记录些重写过程中重要的东西。


发现kbe的实体的定义文件都是def结尾的,要在sublime里def跟xml关联起来。Browse Packages,找到xml,里面有个tmLanguage,加上<string>def</string>就可以了。


Player.cs中有这么一段是处理鼠标点击的,这里要注意一点就是NPC或者怪物,除了要有NavMeshAgent,还要有Rigidbody,不然点击的时候,会导致点击到他们的骨骼上。

[Client]    void SelectionHandling() {        // click raycasting only if not over a UI element        // note: this only works if the UI's CanvasGroup blocks Raycasts        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) {            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);            RaycastHit hit;            if (Physics.Raycast(ray, out hit)) {print ("hit.transform : " + hit.transform);                // valid target?                var entity = hit.transform.GetComponent<Entity>();                if (entity) {                    // set indicator                    SetIndicatorViaParent(hit.transform);                    // clicked last target again? and is not self?                    if (entity != this && entity == target) {



0 0