Exemplo n.º 1
0
        static public void AdjustNodeData(GameObject go, Vector3 pos, Vector4 offest, Vector2 size, UIAncherType ancher = UIAncherType.MiddleCenter)
        {
            var tran = GK.GetOrAddComponent <RectTransform>(go);

            if (null != tran)
            {
                tran.sizeDelta     = size;
                tran.pivot         = new Vector2(0.5f, 0.5f);
                tran.localPosition = Vector3.zero;

                if (UIAncherType.MiddleCenter == ancher)
                {
                    tran.anchorMax = new Vector2(0.5f, 0.5f);
                    tran.anchorMin = new Vector2(0.5f, 0.5f);

                    float x = pos.x - (UIController.width - size.x) * 0.5f;
                    float y = UIController.height * 0.5f - (UIController.height - pos.y - size.y * 0.5f);

                    tran.localPosition = new Vector3(x, y, 0);
                }
                else if (UIAncherType.FullScree == ancher)
                {
                    tran.anchorMax = new Vector2(1, 1);
                    tran.anchorMin = new Vector2(0, 0);
                    tran.offsetMin = new Vector2(offest.x, offest.y);
                    tran.offsetMax = new Vector2(offest.z, offest.w);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加连线
        /// </summary>
        /// <param name="linkId">连线GUID</param>
        /// <param name="nextNode">连接到的节点</param>
        public void AddLink(int linkId, GKToyNode nextNode, int height, string parmKey = "")
        {
            bool    vertical = false;
            Vector2 src      = new Vector2(outputRect.x + outputRect.width, outputRect.y + outputRect.height * 0.5f);
            Vector2 dest     = Vector2.zero;

            // 参数链接.
            if (!string.IsNullOrEmpty(parmKey) && nextNode.parmRect.ContainsKey(parmKey))
            {
                dest = new Vector2(nextNode.parmRect[parmKey].rect.x, nextNode.parmRect[parmKey].rect.y + nextNode.parmRect[parmKey].rect.height * 0.5f);
            }
            // 节点链接.
            else
            {
                dest = new Vector2(nextNode.inputRect.x, nextNode.inputRect.y + nextNode.inputRect.height * 0.5f);
            }
            if (10 <= (int)nextNode.nodeType)
            {
                otherLinks.Add(new Link(linkId, GK.ClacLinePoint(src, dest, out vertical, height), vertical, id, nextNode.id, parmKey));
            }
            else
            {
                links.Add(new Link(linkId, GK.ClacLinePoint(src, dest, out vertical, height), vertical, id, nextNode.id, parmKey));
            }

            LinkUpdate();
        }
Exemplo n.º 3
0
        static public T LoadPanel <T>(string p = "Panels/") where T : MonoBehaviour
        {
            var type = typeof(T);

            string path = p + type.Name;

            GameObject obj = null;

            if (!obj)
            {
                obj = GK.TryLoadGameObject(path);
            }

            if (!obj)
            {
                Debug.LogError("Error load UI panle " + type.Name);
                return(null);
            }

            var c = obj.GetComponent <T>();

            if (!c)
            {
                Debug.LogError("Error GetComponent from UI Panel " + type.Name);
                return(null);
            }

            GK.SetParent(c.gameObject, instance.panelGroup.gameObject, false);

            return(c);
        }
Exemplo n.º 4
0
 static public void ClosePanel <T>(T panel) where T : MonoBehaviour
 {
     if (panel != null)
     {
         GK.Destroy(panel.gameObject);
     }
 }
Exemplo n.º 5
0
        // 创建实例.
        public override GKToyBaseOverlord _CreateData(string path)
        {
            // 生成数据源.
            var       obj   = ScriptableObject.CreateInstance <GKToyExternalData>();
            GKToyData tData = new GKToyData();

            obj.data = tData.Clone() as GKToyData;
            GKEditor.CreateAsset(obj, path);
            var externalData = AssetDatabase.LoadMainAssetAtPath(path) as GKToyExternalData;

            if (null == externalData)
            {
                return(null);
            }

            string myName = Path.GetFileNameWithoutExtension(path);

            // 创建宿主.
            GameObject go          = new GameObject();
            var        tmpOverload = GK.GetOrAddComponent <GKToyBaseOverlord>(go);

            tmpOverload.internalData           = externalData;
            tmpOverload.name                   = myName;
            tmpOverload.internalData.data.name = myName;

            // 初始化首次数据.
            GKToyMakerChapterInfo.Create(this, position.min, ToyMakerBase._minWidth, ToyMakerBase._minHeight, _GetTaskLocalization("Chapter Infomation"), tmpOverload, go);
            return(tmpOverload);
        }
Exemplo n.º 6
0
        static void _ConvertBoxCollider2Dto3D(GameObject o)
        {
            o.layer = GK.LayerId("UI");

            var rb = o.GetComponent <Rigidbody>();

            if (rb)
            {
                GK.Destroy(rb);
            }

            var co = o.GetComponent <BoxCollider2D>();

            if (co)
            {
                Vector4 v4 = new Vector4(co.size.x, co.size.y, co.offset.x, co.offset.y);

                GK.Destroy(co);

                o.AddComponent <BoxCollider>();
                o.GetComponent <BoxCollider>().size   = new Vector3(v4.x, v4.y, 1);
                o.GetComponent <BoxCollider>().center = new Vector3(v4.z, v4.w, 1);
            }

            foreach (Transform t in o.transform)
            {
                _ConvertBoxCollider2Dto3D(t.gameObject);
            }
        }
Exemplo n.º 7
0
        // Create UI node.
        static public GameObject CreateNode(string name, GameObject parent, string layerName)
        {
            GameObject go = new GameObject(name);

            GK.SetParent(go, parent, false);
            go.layer = GK.LayerId(layerName);
            return(go);
        }
Exemplo n.º 8
0
 public void Save()
 {
     if (sceneObj)
     {
         GKEditor.CreateOrReplacePrefab(path, sceneObj);
         AssetDatabase.SaveAssets();
         GK.Destroy(sceneObj);
         sceneObj = null;
     }
 }
Exemplo n.º 9
0
        public GameObject GetOrAddGroup(string name)
        {
            var o = GK.FindChild(gameObject, name, true, false);

            if (!o)
            {
                o = new GameObject(name);
                GK.SetParent(o, gameObject, false);
                o.layer = GK.LayerId("UI");
            }
            return(o);
        }
Exemplo n.º 10
0
 static void _Init(T instance)
 {
     if (instance)
     {
         instance.gameObject.SetActive(true);
         RectTransform rt = GK.GetOrAddComponent <RectTransform>(instance.gameObject);
         rt.sizeDelta        = Vector2.zero;
         rt.anchoredPosition = Vector3.zero;
         UIController.AddUI(instance);
         instance.OnOpen();
     }
 }
Exemplo n.º 11
0
            public void Load()
            {
                GameObject go = GKEditor.LoadGameObject(path, true);

                sceneObj = go;

                GK.SetParent(go, UIController.instance.GetOrAddGroup("UIRoot"), false);
                var tran = go.GetComponent <RectTransform>();

                if (null != tran)
                {
                    tran.localPosition = Vector3.zero;
                    tran.sizeDelta     = Vector2.zero;
                }
                Selection.activeGameObject = go;
            }
Exemplo n.º 12
0
        public static void ExportTaskServerData()
        {
            ToyMakerTaskSettings.ToyMakerTask exportSetting = GK.LoadResource <ToyMakerTaskSettings>("Settings/ToyMakerTaskSettings").toyMakerBase;
            DirectoryInfo directoryInfo = new DirectoryInfo(exportSetting._defaultOverlordPath);

            FileInfo[]        files = directoryInfo.GetFiles("*.asset", SearchOption.TopDirectoryOnly);
            GKToyExternalData externalData;

            for (int i = 0; i < files.Length; i++)
            {
                externalData = AssetDatabase.LoadMainAssetAtPath(string.Format("{0}/{1}", exportSetting._defaultOverlordPath, files[i].Name)) as GKToyExternalData;
                if (null != externalData)
                {
                    _ExportGameDataByMenuItem(2, exportSetting, externalData.data);
                }
            }
        }
Exemplo n.º 13
0
        public void ResetDataArray <DATA_TYPE>(int length, ref DATA_TYPE[] dst) where DATA_TYPE : new()
        {
            var dt     = typeof(DATA_TYPE);
            var N      = length;
            var newArr = new DATA_TYPE[N];

            for (int i = 0; i < N; i++)
            {
                var o = GK.SafeGetElement(dst, i);
                if (o == null)
                {
                    o = new DATA_TYPE();
                }
                newArr[i] = o;
                dt.GetField("id").SetValue(o, i);
            }
            dst = newArr;
        }
Exemplo n.º 14
0
        /// <summary>
        /// 更新单根连线
        /// </summary>
        /// <param name="linkId">要更新连线的Id</param>
        public void UpdateLink(Link link, GKToyNode nextNode, int height)
        {
            bool    vertical = false;
            Vector2 src      = new Vector2(outputRect.x + outputRect.width, outputRect.y + outputRect.height * 0.5f);
            Vector2 dest     = Vector2.zero;

            // 参数链接.
            if (!string.IsNullOrEmpty(link.parmKey) && nextNode.parmRect.ContainsKey(link.parmKey))
            {
                dest = new Vector2(nextNode.parmRect[link.parmKey].rect.x, nextNode.parmRect[link.parmKey].rect.y + nextNode.parmRect[link.parmKey].rect.height * 0.5f);
            }
            // 节点链接.
            else
            {
                dest = new Vector2(nextNode.inputRect.x, nextNode.inputRect.y + nextNode.inputRect.height * 0.5f);
            }
            link.points          = new List <Vector2>(GK.ClacLinePoint(src, dest, out vertical, height));
            link.isFirstVertical = vertical;
        }
Exemplo n.º 15
0
        public void ResetDataArray <ENUM_TYPE, DATA_TYPE>(ref DATA_TYPE[] dst) where DATA_TYPE : new()
        {
            var dt     = typeof(DATA_TYPE);
            var values = GK.EnumValues <ENUM_TYPE>();
            var N      = values.Length;
            var newArr = new DATA_TYPE[N];

            for (int i = 0; i < N; i++)
            {
                var o = GK.SafeGetElement(dst, i);
                if (o == null)
                {
                    o = new DATA_TYPE();
                }
                newArr[i] = o;
                var t = values[i];
                dt.GetField("type").SetValue(o, t);
            }
            dst = newArr;
        }
Exemplo n.º 16
0
        public override void Execute(Map.World world)
        {
            Logger.Debug(" Death Of King Event Path 2");

            //Берём участников сцены
            var LeoricGhost    = world.GetActorBySNO(5365);
            var GhostKnights   = world.GetActorsBySNO(4182);
            var LachdananGhost = world.GetActorBySNO(4183);
            var SwordPlace     = world.GetActorBySNO(163449);

            TickTimer Timeout = new SecondsTickTimer(world.Game, 23f);
            var       ListenerKingSkeletons = System.Threading.Tasks.Task <bool> .Factory.StartNew(() => WaitToSpawn(Timeout));

            ListenerKingSkeletons.ContinueWith(delegate
            {
                LeoricGhost.Destroy();
                LachdananGhost.Destroy();
                foreach (var GK in GhostKnights)
                {
                    GK.Destroy();
                }
            });
        }
Exemplo n.º 17
0
        GameObject _CreateDialogueData(string path, int taskId, string dfgType)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            // 生成数据源.
            var       obj   = ScriptableObject.CreateInstance <GKToyExternalData>();
            GKToyData tData = new GKToyData();

            obj.data = tData.Clone() as GKToyData;
            string assetPath = string.Format("{0}{1}_{2}.Asset", path, dfgType, taskId);

            GKEditor.CreateAsset(obj, assetPath);
            var externalData = AssetDatabase.LoadMainAssetAtPath(assetPath) as GKToyExternalData;

            if (null == externalData)
            {
                return(null);
            }

            string myName = string.Format("{0}_{1}", dfgType, taskId);

            // 创建宿主.
            GameObject go          = new GameObject();
            var        tmpOverload = GK.GetOrAddComponent <GKToyBaseOverlord>(go);

            tmpOverload.internalData           = externalData;
            tmpOverload.name                   = myName;
            tmpOverload.internalData.data.name = myName;

            // 初始化首次数据.
            GKToyNode node = new GKToyStart(_GenerateGUID(tmpOverload.internalData.data.nodeGuid++));
            Type      type = node.GetType();

            node.className = string.Format("{0}.{1}", type.Namespace, type.Name);
            node.pos.x     = (_contentScrollPos.x + ToyMakerBase._minWidth * 0.5f) / Scale;
            node.pos.y     = (_contentScrollPos.y + ToyMakerBase._minHeight * 0.5f) / Scale;
            node.id        = node.ID;
            node.nodeType  = NodeType.Action;
            node.name      = "开始-1";
            node.Init(tmpOverload);
            node.comment = "";
            tmpOverload.internalData.data.nodeLst.Add(node.id, node);
            node           = new GKToyEnd(_GenerateGUID(_GenerateGUID(tmpOverload.internalData.data.nodeGuid++)));
            type           = node.GetType();
            node.className = string.Format("{0}.{1}", type.Namespace, type.Name);
            node.pos.x     = -10;
            node.pos.y     = -10;
            node.id        = node.ID;
            node.nodeType  = NodeType.Action;
            node.name      = "结束-2";
            node.Init(tmpOverload);
            node.comment = "";
            tmpOverload.internalData.data.nodeLst.Add(node.id, node);
            tmpOverload.Save();
            tmpOverload.Backup();
            string     prefabPath = string.Format("{0}{1}_{2}.prefab", path, dfgType, taskId);
            GameObject prefab;

            if (!File.Exists(prefabPath))
            {
                prefab = PrefabUtility.CreatePrefab(prefabPath, go);
            }
            else
            {
                prefab = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);
                prefab = PrefabUtility.ReplacePrefab(go, prefab);
            }
            DestroyImmediate(go);
            return(prefab);
        }
Exemplo n.º 18
0
 public GameObject TryFindChild(string name)
 {
     return(GK.FindChild(this.gameObject, name, true));
 }
Exemplo n.º 19
0
 public void ClearHUD()
 {
     GK.DestroyAllChildren(hudRoot);
 }
Exemplo n.º 20
0
        static public GKUIEventTriggerListener Get(GameObject go)
        {
            GKUIEventTriggerListener listener = GK.GetOrAddComponent <GKUIEventTriggerListener>(go);

            return(listener);
        }