Beispiel #1
0
 public virtual void AddListener(EventAction <T0, T1> call)
 {
     if (EventActions.Contains(call))
     {
         DebugHandler.LogError("EventActions Contains cal");
         return;
     }
     EventActions.Add(call);
 }
Beispiel #2
0
 /// <summary>
 /// 移除自身
 /// </summary>
 ///
 public void RemoveSelf()
 {
     if (Parent == null)
     {
         DebugHandler.LogError(" null  parent");
         return;
     }
     Parent.Remove(this);
 }
Beispiel #3
0
        public static string GetObjectMD5(object obj)
        {
            if (obj == null)
            {
                DebugHandler.LogError("obj is Null !");
                return("");
            }

            return(GetMD5(ByteTool.Object2Bytes(obj)));
        }
Beispiel #4
0
 public virtual void RemoveListener(EventAction <T0, T1> call)
 {
     if (EventActions.Contains(call))
     {
         EventActions.Remove(call);
     }
     else
     {
         DebugHandler.LogError("EventActions not Contains cal");
     }
 }
Beispiel #5
0
 public static T GetDataFromFile <T>(string path)
 {
     try
     {
         byte[] bytes = File.ReadAllBytes(path);
         return(ProtoBufUtils.ProtobufDeserialize <T>(bytes));
     }
     catch (System.Exception ex)
     {
         DebugHandler.LogError("GetDataFromFile" + ex.ToString());
     }
     return(default(T));
 }
Beispiel #6
0
        public void LoadAssetFromJson(string jsontxt)
        {
            JArray jay = (JArray)JsonConvert.DeserializeObject(jsontxt);

            if (jay == null)
            {
                DebugHandler.LogError("Null jay");
            }
            if (!ParseTable(jay))
            {
                DebugHandler.LogError("Null Parse jay" + jsontxt);
            }
        }
Beispiel #7
0
        public bool ParseRow(JObject jobj)
        {
            if (jobj == null)
            {
                DebugHandler.LogError("Null jobj");
            }
            id = (int)jobj["id"];
            AssetBundleName = (string)jobj["AssetBundleName"];
            AssetName       = (string)jobj["AssetName"];
            ResourceName    = (string)jobj["ResourceName"];

            return(true);
        }
Beispiel #8
0
 /// <summary>
 /// 删除子节点
 /// </summary>
 public virtual void Remove(Node <T> node)
 {
     if (m_childs.Contains(node))
     {
         m_childs.Remove(node);
         node.SetParent(null);
         node.OnExit();
     }
     else
     {
         DebugHandler.LogError("child not contain node");
     }
 }
Beispiel #9
0
 /// <summary>
 /// 添加子节点
 /// </summary>
 /// <param name="node"></param>
 public virtual void Add(Node <T> node)
 {
     if (node != null && node.Parent == null)
     {
         node.SetParent(this);
         m_childs.AddLast(node);
         node.OnEnter();
     }
     else
     {
         DebugHandler.LogError("node.Parent not null");
     }
 }
Beispiel #10
0
        public virtual void FireEvent(uint id, T0 t0, T1 t1)
        {
            EventBase <T0, T1> evtbase;

            if (DictEvents.TryGetValue(id, out evtbase))
            {
                evtbase.Invoke(t0, t1);
            }
            else
            {
                DebugHandler.LogError(string.Format("FireEvent Has No Evt{0}", id));
            }
        }
Beispiel #11
0
        public void RemoveEvent(uint id, EventAction <T0, T1> eact)
        {
            EventBase <T0, T1> evtbase;

            if (DictEvents.TryGetValue(id, out evtbase))
            {
                evtbase.RemoveListener(eact);
            }
            else//没有事件监听
            {
                DebugHandler.LogError("Has No Evt");
                return;
            }
            //if(evtbase.EventActions.Count==0)暂时不删除影响不大
        }
Beispiel #12
0
        protected void UnloadAssetBundleInternal(string assetBundleName)
        {
            LoadedAssetBundle bundle = GetLoadedAssetBundle(assetBundleName);

            if (bundle == null)
            {
                return;
            }

            if (--bundle.m_ReferencedCount == 0)
            {
                m_LoadedAssetBundles.Remove(assetBundleName);
                bundle.m_AssetBundle.Unload(true);
                DebugHandler.Log(assetBundleName + " has been unloaded successfully");
            }
        }
Beispiel #13
0
        public static void SaveDataToFile <T>(string path, T dt)
        {
            try
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                byte[] bys = ProtoBufUtils.ProtobufSerialize(dt);
                CreateFile(path, bys);
                //File.WriteAllBytes(path, bys);
            }
            catch (System.Exception ex)
            {
                DebugHandler.LogError("SaveDataToFile error" + ex.ToString());
            }

            //File.Create()
        }
Beispiel #14
0
        protected void LoadManifestDirectly(string assetBundleName)
        {
            if (m_LoadedAssetBundles.ContainsKey(assetBundleName))//已经加载
            {
                return;
            }


            string url = m_BaseDownloadingURL + assetBundleName;
            var    ab  = AssetBundle.LoadFromFile(url);

            if (ab == null)
            {
                DebugHandler.LogError("ab Null" + assetBundleName);
            }
            m_LoadedAssetBundles.Add(assetBundleName, new LoadedAssetBundle(ab));
            AssetBundleManifestObject = ab.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            if (AssetBundleManifestObject == null)
            {
                throw new GameFrameworkException("AssetBundleManifest");
            }
        }
Beispiel #15
0
        public static string GetFileMD5(string filePath)
        {
            try
            {
                FileInfo fileTmp = new FileInfo(filePath);
                if (fileTmp.Exists)
                {
                    FileStream fs   = new FileStream(filePath, FileMode.Open);
                    int        len  = (int)fs.Length;
                    byte[]     data = new byte[len];
                    fs.Close();

                    return(GetMD5(data));
                }
                return("");
            }
            catch (FileNotFoundException e)
            {
                DebugHandler.Log(e.Message);
                return("");
            }
        }