Example #1
0
        /// <summary>
        /// 增加格子容器按钮点击回调
        /// </summary>
        /// <param name="obj">按钮对象</param>
        /// <param name="gridIndex">所属格子索引</param>
        public void setClickObject(UIObject obj, int gridIndex)
        {
            Transform trans = obj.transform;

            long re  = 0;
            int  wei = 0;

            while (trans != null && trans != this.transform)
            {
                int index = trans.GetSiblingIndex();
                re   = (re << 8) | index;
                wei += 8;

                trans = trans.parent;
            }

            if (wei >= 63)
            {
                Ctrl.errorLog("grid层级过于多了", wei, obj.name);
                wei = 63;
            }

            re <<= (63 - wei);

            _clickObjectIndexMap.put(obj, re);
            _clickObjectMap.put(obj, gridIndex);
        }
Example #2
0
        private static XML preDoOneGenerate(string xmlPath)
        {
            XML xml = FileUtils.readFileForXML(xmlPath);

            //处理屏蔽
            foreach (XML xl in xml.getChildrenByName("ignoreMethod"))
            {
                string[] methods = xl.getProperty("methods").Split(',');

                SSet <string> dd = new SSet <string>();
                dd.addAll(methods);
                _clsIgnoreMethods.put(xl.getProperty("cls"), dd);
            }

            foreach (XML xl in xml.getChildrenByName("allowMethod"))
            {
                string[] methods = xl.getProperty("methods").Split(',');

                SSet <string> dd = new SSet <string>();
                dd.addAll(methods);
                _clsAllowMethods.put(xl.getProperty("cls"), dd);
            }

            foreach (XML xl in xml.getChildrenByName("namespace"))
            {
                _allowNameSpace.add(xl.getProperty("name"));
            }

            return(xml);
        }
Example #3
0
 /** 添加父记录 */
 public void addParent(FactoryClassInfo cls)
 {
     cls.methodDic.forEach((k, v) =>
     {
         parentMethodDic.put(k, v);
     });
 }
Example #4
0
        public void initObject(GameObject obj)
        {
            if (_inited)
            {
                dispose();
            }

            _inited = true;

            obj.SetActive(true);

            _transform                = obj.transform;
            _spineAnimation           = obj.GetComponent <SkeletonAnimation>();
            _spineAnimation.timeScale = 1f;

            var animations = _spineAnimation.SkeletonDataAsset.GetSkeletonData(true).Animations;

            for (int i = 0; i < animations.Count; i++)
            {
                string name     = animations.Items[i].Name;
                float  duration = animations.Items[i].Duration;

                _durationDic.put(name, duration);
            }

            (_skeleton = _spineAnimation.Skeleton).SetToSetupPose();
//			_spineAnimation.state.ClearTracks();

            _spineAnimation.state.Complete += onActionOver;
        }
Example #5
0
            public void toAddMethod(FMethod method)
            {
                //有了
                if (methodDic.contains(method.name))
                {
                    return;
                }

                methodList.add(method);
                methodDic.put(method.name, method);
            }
Example #6
0
        private static StringBuilderPool getPoolByThread(Thread thread)
        {
            StringBuilderPool pool = _dic.get(thread);

            if (pool == null)
            {
                _dic.put(thread, pool = new StringBuilderPool());
            }

            return(pool);
        }
Example #7
0
        public void test1()
        {
            _dic.clear();

            for (int i = 1; i < _len; ++i)
            {
                _dic.put(i, _arr[i]);
            }

            for (int i = 1; i < _len; ++i)
            {
                _re = _dic.get(i).level;
            }
        }
Example #8
0
 public DirtWordNode AppendChild(char c, bool canTerminate)
 {
     if (!children.contains(c))
     {
         DirtWordNode node = new DirtWordNode();
         node.Character    = c;
         node.Word         = word + c;
         node.CanTerminate = canTerminate;
         children.put(c, node);
         return(node);
     }
     else
     {
         return(children[c]);
     }
 }
Example #9
0
        /// <summary>
        /// 放回一个
        /// </summary>
        public virtual void back(T obj)
        {
            if (obj == null)
            {
                Ctrl.throwError("对象池添加空对象");
                return;
            }

            if (!_enable || _queue.size() >= _maxSize)
            {
                if (_releaseFunc != null)
                {
                    _releaseFunc(obj);
                }

                return;
            }

            if (_needClear)
            {
                if (obj is IPoolObject)
                {
                    ((IPoolObject)obj).clear();
                }
            }


            if (ShineSetting.openCheck)
            {
                if (_checkSet.contains(obj))
                {
                    Ctrl.print("上次调用", _callStackDic.get(obj));
                    Ctrl.throwError("对象池重复添加!", obj);
                    return;
                }

                _checkSet.add(obj);
                string stackTrace = Ctrl.getStackTrace();
                stackTrace = stackTrace.Replace("\n", " ");
                _callStackDic.put(obj, stackTrace);
            }


            _queue.add(obj);
        }
Example #10
0
        private static void loadAssembly()
        {
            //项目程序集
            Assembly assembly = typeof(ShineSetup).Assembly;

            Type[] types = assembly.GetTypes();

            foreach (Type vType in types)
            {
                string fullName = vType.FullName;

                //内部类不统计
                if (!fullName.Contains("+"))
                {
                    //命名空间允许
                    if (string.IsNullOrEmpty(vType.Namespace) || _allowNameSpace.contains(vType.Namespace))
                    {
                        string vName = vType.Name;

                        int index = vName.IndexOf('`');

                        //去掉泛型标记
                        if (index > 0)
                        {
                            vName = vName.Substring(0, index);
                        }

                        TypeInfo typeInfo = new TypeInfo();
                        typeInfo.clsName = vName;
                        typeInfo.clsType = vType;

                        if (_typeDic.contains(vName))
                        {
                            // Ctrl.print("类名重复",vName);
                            continue;
                        }

                        _typeDic.put(vName, typeInfo);
                    }
                }
            }
        }
Example #11
0
        private static void doOneGenerate(XML xml, string controlClsPath, string adapterOutPath, int projectType)
        {
            clearGenerate();

            string[] fileList = FileUtils.getFileList(adapterOutPath, "cs");

            SMap <string, string> fileMap = new SMap <string, string>();

            foreach (string s in fileList)
            {
                string fN = FileUtils.getFileNameWithoutEx(s);

                if (fN.EndsWith("Adapter"))
                {
                    fileMap.put(fN.Substring(0, fN.Length - 7), s);
                }
            }

            _isShine = projectType == 0;

            int aLen = "Assets/".Length;

            //先处理包路径
            foreach (XML xl in xml.getChildrenByName("root"))
            {
                SList <string> ignoreList = new SList <string>();

                foreach (XML pXml in xl.getChildrenByName("ignorePath"))
                {
                    ignoreList.add(pXml.getProperty("path"));
                }

                StringIntMap hotfixPathDic = new StringIntMap();

                foreach (XML pXml in xl.getChildrenByName("hotfixPath"))
                {
                    hotfixPathDic.put(pXml.getProperty("path"), pXml.getProperty("needFactory").Equals("true") ? 1 : 0);
                }

                string rootPath = "Assets/" + xl.getProperty("path");

                string[] deepFileList = FileUtils.getDeepFileList(rootPath, "cs");

                foreach (string s in deepFileList)
                {
                    //编辑器类的跳过
                    if (s.Contains("/Editor/"))
                    {
                        continue;
                    }

                    string tailPath = s.Substring(rootPath.Length + 1);

                    bool failed = false;

                    //排除组
                    foreach (string ig in ignoreList)
                    {
                        if (tailPath.StartsWith(ig))
                        {
                            failed = true;
                            break;
                        }
                    }

                    if (failed)
                    {
                        continue;
                    }

                    string fQName = FileUtils.getFileFrontName(s.Substring(aLen));

                    String fName = FileUtils.getFileName(fQName);

                    _clsNameToPathDic.put(fName, fQName);

                    string[] keys   = hotfixPathDic.getKeys();
                    int[]    values = hotfixPathDic.getValues();
                    string   k;
                    int      v;

                    for (int i = keys.Length - 1; i >= 0; --i)
                    {
                        if ((k = keys[i]) != null)
                        {
                            v = values[i];

                            //需要
                            if (tailPath.StartsWith(k))
                            {
                                _adapterClsDic.add(fName);

                                if (v == 1)
                                {
                                    _factoryClsDic.add(fName);
                                }

                                break;
                            }
                        }
                    }
                }
            }


            string clsStr = FileUtils.readFileForUTF(controlClsPath);

            string projectMark    = getProjectMark(projectType);
            string factoryClsPath = getFactoryClsPath(projectType);

            ClsAnalysis.FactoryClassInfo factoryClass = null;
            string factoryClsName = null;

            if (!_isShine)
            {
                factoryClass   = ClsAnalysis.readFactory(factoryClsPath);
                factoryClsName = FileUtils.getFileFrontName(FileUtils.getFileName(factoryClsPath));

                //遍历父
                for (int i = projectType - 1; i >= Project_Common; i--)
                {
                    ClsAnalysis.FactoryClassInfo parentFactoryCls = ClsAnalysis.readFactory(getFactoryClsPath(i));

                    factoryClass.addParent(parentFactoryCls);
                }
            }

            StringBuilder sb = new StringBuilder();

            endClsLine(sb);

            if (!_isShine)
            {
                sb.Append("base.initOtherAdapters(appdomain);");
                endClsLine(sb);
            }


            TypeInfo factoryTypeInfo = null;

            if (!_isShine)
            {
                //工厂最后执行
                factoryTypeInfo = getTypeInfo(factoryClsName);

                _clsNameToPathDic.remove(factoryClsName);
            }

            //ex
            foreach (XML xl in xml.getChildrenByName("customClass"))
            {
                ILClassInfo cls = new ILClassInfo(xl.getProperty("name"));

                foreach (XML mXml in xl.getChildrenByName("method"))
                {
                    string visitTypeStr = mXml.getProperty("visitType");
                    int    visitType    = visitTypeStr.isEmpty() ? VisitType.Protected : VisitType.getTypeByName(visitTypeStr);

                    string needBaseCallStr = mXml.getProperty("needBaseCall");
                    bool   needBaseCall    = needBaseCallStr.isEmpty() ? true : StringUtils.strToBoolean(needBaseCallStr);

                    string   argsStr = mXml.getProperty("args");
                    string[] args    = argsStr.isEmpty() ? ObjectUtils.EmptyStringArr : argsStr.Split(',');

                    cls.addMethod(mXml.getProperty("name"), mXml.getProperty("returnType"), visitType, needBaseCall, args);
                }

                doOneClass(cls, adapterOutPath, _isShine, sb);
                fileMap.remove(cls.clsName);
            }

            foreach (string k in _clsNameToPathDic.getSortedMapKeys())
            {
                TypeInfo typeInfo = getTypeInfo(k);

                if (typeInfo == null)
                {
                    if (!_isShine)
                    {
                        Ctrl.throwError("不该找不到类型", k);
                    }
                }
                else
                {
                    if (typeInfo.hasHotfixMark || !typeInfo.isEmpty())
                    {
                        //需要工厂,并且不是虚类
                        if (!_isShine && !typeInfo.iCls.isAbstract && (typeInfo.needFactory || _factoryClsDic.contains(k)))
                        {
                            ClsAnalysis.FMethod method = factoryClass.addMethod(k, projectMark);
                            //补方法
                            factoryTypeInfo.iCls.addMethod("create" + method.name, method.returnType, VisitType.Public, true);
                        }

                        //需要适配器
                        if (typeInfo.hasHotfixMark || _adapterClsDic.contains(k))
                        {
                            doOneClass(typeInfo.iCls, adapterOutPath, _isShine, sb);
                            fileMap.remove(typeInfo.clsName);
                        }
                    }
                }
            }

            if (!_isShine)
            {
                doOneClass(factoryTypeInfo.iCls, adapterOutPath, _isShine, sb);
                fileMap.remove(factoryTypeInfo.clsName);
            }

            //去掉最后一个tab
            sb.Remove(sb.Length - 1, 1);

            clsStr = replaceMethod(clsStr, "protected " + (_isShine ? "virtual" : "override") + " void initOtherAdapters(AppDomain appdomain)", sb.ToString());

            if (!_isShine)
            {
                factoryClass.writeToPath(factoryClsPath);
            }

            FileUtils.writeFileForUTF(controlClsPath, clsStr);

            if (!fileMap.isEmpty())
            {
                fileMap.forEach((k, v) =>
                {
                    FileUtils.deleteFile(v);
                });
            }
        }
Example #12
0
        private static void doOneGenerate(string xmlPath, string controlClsPath, string adapterOutPath, int projectType)
        {
            clearGenerate();

            _isShine = projectType == 0;

            //TODO:根据类型取父factory

            XML xml = FileUtils.readFileForXML(xmlPath);

            int aLen = "Assets/".Length;

            //处理屏蔽
            foreach (XML xl in xml.getChildrenByName("ignoreMethod"))
            {
                string[] methods = xl.getProperty("methods").Split(',');

                SSet <string> dd = new SSet <string>();
                dd.addAll(methods);
                _clsIgnoreMethods.put(xl.getProperty("cls"), dd);
            }

            foreach (XML xl in xml.getChildrenByName("allowMethod"))
            {
                string[] methods = xl.getProperty("methods").Split(',');

                SSet <string> dd = new SSet <string>();
                dd.addAll(methods);
                _clsAllowMethods.put(xl.getProperty("cls"), dd);
            }

            //先处理包路径
            foreach (XML xl in xml.getChildrenByName("root"))
            {
                SList <string> ignoreList = new SList <string>();

                foreach (XML pXml in xl.getChildrenByName("ignorePath"))
                {
                    ignoreList.add(pXml.getProperty("path"));
                }

                StringIntMap hotfixPathDic = new StringIntMap();

                foreach (XML pXml in xl.getChildrenByName("hotfixPath"))
                {
                    hotfixPathDic.put(pXml.getProperty("path"), pXml.getProperty("needFactory").Equals("true") ? 1 : 0);
                }

                string rootPath = "Assets/" + xl.getProperty("path");

                string[] deepFileList = FileUtils.getDeepFileList(rootPath, "cs");

                foreach (string s in deepFileList)
                {
                    //编辑器类的跳过
                    if (s.Contains("/Editor/"))
                    {
                        continue;
                    }

                    string tailPath = s.Substring(rootPath.Length + 1);

                    bool failed = false;

                    //排除组
                    foreach (string ig in ignoreList)
                    {
                        if (tailPath.StartsWith(ig))
                        {
                            failed = true;
                            break;
                        }
                    }

                    if (failed)
                    {
                        continue;
                    }

                    string fQName = FileUtils.getFileFrontName(s.Substring(aLen));

                    String fName = FileUtils.getFileName(fQName);

                    _clsNameToPathDic.put(fName, fQName);

                    string[] keys   = hotfixPathDic.getKeys();
                    int[]    values = hotfixPathDic.getValues();
                    string   k;
                    int      v;

                    for (int i = keys.Length - 1; i >= 0; --i)
                    {
                        if ((k = keys[i]) != null)
                        {
                            v = values[i];

                            //需要
                            if (tailPath.StartsWith(k))
                            {
                                _adapterClsDic.add(fName);

                                if (v == 1)
                                {
                                    _factoryClsDic.add(fName);
                                }

                                break;
                            }
                        }
                    }
                }
            }

            //再处理命名空间
            foreach (XML xl in xml.getChildrenByName("namespace"))
            {
                _allowNameSpace.add(xl.getProperty("name"));
            }

            //项目程序集
            Assembly assembly = typeof(ShineSetup).Assembly;

            Type[] types = assembly.GetTypes();

            foreach (Type vType in types)
            {
                string fullName = vType.FullName;

                //内部类不统计
                if (!fullName.Contains("+"))
                {
                    //命名空间允许
                    if (string.IsNullOrEmpty(vType.Namespace) || _allowNameSpace.contains(vType.Namespace))
                    {
                        string vName = vType.Name;

                        int index = vName.IndexOf('`');

                        //去掉泛型标记
                        if (index > 0)
                        {
                            vName = vName.Substring(0, index);
                        }

                        TypeInfo typeInfo = new TypeInfo();
                        typeInfo.clsName = vName;
                        typeInfo.clsType = vType;

                        if (_typeDic.contains(vName))
                        {
                            // Ctrl.print("类名重复",vName);
                            continue;
                        }

                        _typeDic.put(vName, typeInfo);
                        //类路径
                        typeInfo.clsPath = _clsNameToPathDic.get(vName);
                    }
                }
            }

            string clsStr = FileUtils.readFileForUTF(controlClsPath);

            string factoryClsPath = getFactoryClsPath(projectType);

            ClsAnalysis.FactoryClassInfo factoryClass = ClsAnalysis.readFactory(factoryClsPath);
            string projectMark = getProjectMark(projectType);

            string factoryClsName = FileUtils.getFileFrontName(FileUtils.getFileName(factoryClsPath));

            //遍历父
            for (int i = projectType - 1; i >= Project_Common; i--)
            {
                ClsAnalysis.FactoryClassInfo parentFactoryCls = ClsAnalysis.readFactory(getFactoryClsPath(i));

                factoryClass.addParent(parentFactoryCls);
            }


            StringBuilder sb = new StringBuilder();

            endClsLine(sb);

            if (!_isShine)
            {
                sb.Append("base.initOtherAdapters(appdomain);");
                endClsLine(sb);
            }


            XML reXMl = new XML();

            reXMl.name = "info";

            //工厂最后执行
            TypeInfo factoryTypeInfo = getTypeInfo(factoryClsName);

            _clsNameToPathDic.remove(factoryClsName);

            foreach (string k in _clsNameToPathDic.getSortedMapKeys())
            {
                TypeInfo typeInfo = getTypeInfo(k);

                if (typeInfo == null)
                {
                    Ctrl.throwError("不该找不到类型", k);
                }

                if (typeInfo.hasHotfixMark || !typeInfo.isEmpty())
                {
                    //需要工厂,并且不是虚类
                    if (!typeInfo.iCls.isAbstract && (typeInfo.needFactory || _factoryClsDic.contains(k)))
                    {
                        ClsAnalysis.FMethod method = factoryClass.addMethod(k, projectMark);

                        //补方法
                        factoryTypeInfo.iCls.addMethod("create" + method.name, method.returnType, VisitType.Public, true);
                    }

                    //需要适配器
                    if (typeInfo.hasHotfixMark || _adapterClsDic.contains(k))
                    {
                        doOneClass(typeInfo.iCls, adapterOutPath, _isShine, sb);
                    }

                    // reXMl.appendChild(typeInfo.writeXML());
                }
            }

            doOneClass(factoryTypeInfo.iCls, adapterOutPath, _isShine, sb);

            //去掉最后一个tab
            sb.Remove(sb.Length - 1, 1);

            clsStr = replaceMethod(clsStr, "protected " + (_isShine ? "virtual" : "override") + " void initOtherAdapters(AppDomain appdomain)", sb.ToString());

            factoryClass.writeToPath(factoryClsPath);
            FileUtils.writeFileForUTF(controlClsPath, clsStr);

            // FileUtils.writeFileForXML("/Users/sunming/E/temp3/aa.xml",reXMl);
        }