Example #1
0
        private void InitComp(GameObject go, SerializeEntity se)
        {
            if (se.Type.StartsWith("LE_"))
            {
                InitEventComp(go, se);
                return;
            }
            Type type = SerializeReg.GetType(se.Type);

            if (type == null)
            {
                LitLogger.ErrorFormat("{0} not registe in SerializeReg", se.Type);
                return;
            }

            if (type == typeof(Transform))
            {
                var trans = go.GetComponent <Transform>();
                TryDeserializeComp(trans, se);
            }
            else
            {
                var comp = go.AddComponent(type);
                TryDeserializeComp(comp, se);
            }
        }
Example #2
0
        void Start()
        {
            float layerValue = Mathf.Log(layer.value, 2);

            if (layerValue % 1 > 0)
            {
                LitLogger.ErrorFormat("LitUIDepth => Set Layer Error {0} , Layer:{1}", gameObject.name, layerValue);
            }
            gameObject.layer = (int)layerValue;

            if (isUI)
            {
                Canvas canvas = GetComponent <Canvas>();
                if (canvas == null)
                {
                    canvas = gameObject.AddComponent <Canvas>();
                }
                canvas.overrideSorting = true;
                canvas.sortingOrder    = order;
            }
            else
            {
                Renderer[] renders = GetComponentsInChildren <Renderer>();
                foreach (Renderer render in renders)
                {
                    render.sortingOrder = order;
                }
                if (isAttach <Renderer>())
                {
                    var render = GetComponent <Renderer>();
                    render.sortingOrder = order;
                }
            }
        }
Example #3
0
        public void RegistEvent(EventEntity litEvent)
        {
            switch (litEvent.EventType)
            {
            case LitEventType.LE_None:
                LitLogger.ErrorFormat("Register Invalid Event Type {0} , {1}",
                                      litEvent.EventType, litEvent.EventParam);
                break;

            case LitEventType.LE_UID:
                RegisterLifeEvent(litEvent);
                InitUID(litEvent.EventParam);
                break;

            case LitEventType.LE_Handler:
                RegisterLifeEvent(litEvent);
                InitLuaFile(litEvent.EventParam);
                break;

            case LitEventType.LE_InitDisable:
                InitLitState(litEvent);
                break;

            default:
                InitLifeEvent(litEvent);
                break;
            }
        }
Example #4
0
        private SerializeEntity TrySerialize(Component comp)
        {
            SerializeEntity retSE = null;

            if (comp is ISerializable)
            {
                var sa = comp as ISerializable;
                retSE = sa.Serialize();
            }
            if (comp is ISerializeEvent)
            {
                var se = comp as ISerializeEvent;
                var ee = se.Serialize();
                if (ee != null)
                {
                    retSE = ee.ToSerializeEntity();
                }
                return(retSE);
            }
            if (retSE == null)
            {
                retSE = TryCallSerializeByReflection(comp);
            }
            if (comp == null)
            {
                //TODO 完全通过反射的方式序列化对象
            }
            if (retSE != null && !SerializeReg.HasRegType(retSE.Type) && (!(comp is ISerializeEvent)))
            {
                LitLogger.ErrorFormat("{0} not register in SeriaLizeReg,Can'not be Serialized", retSE.Type);
                retSE = null;
            }
            return(retSE);
        }
Example #5
0
 public static T GetInstance()
 {
     if (_inst == null)
     {
         LitLogger.ErrorFormat("{0} Not Init in FaceMgr", typeof(T).Name);
     }
     return(_inst);
 }
Example #6
0
 private void Awake()
 {
     if (_inst != null)
     {
         GameObject.DestroyImmediate(_inst);
         LitLogger.ErrorFormat("Can not Repeat Create {0}", typeof(T).Name);
     }
     _inst = this as T;
     (_inst as SingletonBehaviour <T>).Init();
 }
Example #7
0
        public static Type GetType(string name)
        {
            Type t = null;

            allSerializeType.TryGetValue(name, out t);
            if (t == null)
            {
                LitLogger.ErrorFormat("The Type not resgister {0}", name);
            }
            return(t);
        }
Example #8
0
        public static void _Swap <T>(this IList <T> lists, int a, int b)
        {
            if (!lists._isValidIndex(a) || !lists._isValidIndex(b))
            {
                LitLogger.ErrorFormat("Invalid Index : {0} , {1}", a, b);
                return;
            }
            T tmp = lists[a];

            lists[a] = lists[b];
            lists[b] = tmp;
        }
Example #9
0
 public virtual void GC()
 {
     if (_active)
     {
         pool.AddLast(this as T);
         this.OnDisable();
         _active = false;
     }
     else
     {
         LitLogger.ErrorFormat("Obj has been GC <{0}>", this);
     }
 }
Example #10
0
 public void RegisterLifeEvent(EventEntity e)
 {
     if (!e.isValid)
     {
         LitLogger.ErrorFormat("Invalid Event : {0}", e.ToString());
         return;
     }
     if (LifeEvents == null)
     {
         LifeEvents = new List <EventEntity>();
     }
     LifeEvents.Add(e);
 }
Example #11
0
 private static void InitCompsByJsonData(SerializeObj so, JsonData jsonData)
 {
     if (so == null || jsonData == null || jsonData.Count <= 0)
     {
         LitLogger.ErrorFormat("{0} components is Empty {1}", so.ObjName, jsonData);
         return;
     }
     for (int i = 0; i < jsonData.Count; i++)
     {
         var             data = jsonData[i];
         SerializeEntity se   = new SerializeEntity(data);
         so.AddComp(se);
     }
 }
Example #12
0
 public static void UID_Register(string uid, LitLua obj)
 {
     if (uid.isEmpty() || obj == null)
     {
         LitLogger.ErrorFormat("Register Invalid UID : <{0}> , <{1}>", uid, obj);
     }
     else if (UID_Contains(uid))
     {
         LitLogger.WarningFormat("UID <{0}> repeated !! => {1} will replace by {2}", uid, UID_Get(uid), obj);
         UIDMap[uid] = obj;
     }
     else
     {
         UIDMap.Add(uid, obj);
     }
 }
Example #13
0
        public void GenerateEvent(LitEventType type, object sender)
        {
            if (type == LitEventType.LE_None || sender == null)
            {
                LitLogger.ErrorFormat("Trriger Invalid Event : {0} , {1}", type, sender);
                return;
            }
            var ee = GetEventEntity(type);

            if (ee != null)
            {
                TrrigerEvent te = new TrrigerEvent(ee, sender);
                curEvent = te;
                TryHandleEvent();
            }
        }
Example #14
0
        private List <SerializeEntity> GetObjAllComps(GameObject go)
        {
            List <SerializeEntity> comps = new List <SerializeEntity>();
            var compList = go.GetComponents <Component>();

            for (int i = 0; i < compList.Length; i++)
            {
                var so = TrySerialize(compList[i]);
                if (so != null)
                {
                    comps.Add(so);
                }
                else
                {
                    LitLogger.ErrorFormat("Can'not Serialize Component {0} on {1}", compList[i].GetType().Name, go.name);
                }
            }
            return(comps);
        }
Example #15
0
        public bool Destroy(string poolName)
        {
            SpawnPool spawnPool;

            if (!this._pools.TryGetValue(poolName, out spawnPool))
            {
                Debug.LogError(
                    string.Format("PoolManager: Unable to destroy '{0}'. Not in PoolManager",
                                  poolName));
                return(false);
            }
            if (this._pools.Remove(poolName))
            {
                UnityEngine.Object.Destroy(spawnPool.gameObject);
            }
            else
            {
                LitLogger.ErrorFormat("Destroy Pool Error: {0}", poolName);
            }
            return(true);
        }
Example #16
0
        public void TryHandleEvent()
        {
            if (curEvent == null)
            {
                return;
            }
            CallLuaFunc(curEvent.EventInfo.EventParam, curEvent.Sender);

            if (curEvent != null)
            {
                var p = GetParent();
                if (p == null)
                {
                    LitLogger.ErrorFormat("{0} No Handler for Event : {1}", curEvent.Sender, curEvent.EventInfo);
                    CatchEvent();
                }
                else
                {
                    p.TryHandleEvent();
                }
            }
        }