public void AddShadowCaster(GameObject gOParam) { if (gOParam == null) { C_DebugHelper.LogError("C_ShadowProjector AddShadowCaster: gOParam is Null!"); return; } gOParam.layer = LayerMask.NameToLayer("ShadowCaster"); foreach (Transform child in gOParam.transform) { child.gameObject.layer = LayerMask.NameToLayer("ShadowCaster"); } foreach (GameObject gO in m_ShadowCasterList) { if (gO == gOParam) { return; } } m_ShadowCasterList.Add(gOParam); }
// 将用完的GameObject放入m_DormantObjects中 public void Despawn(Object objectParam, C_PoolChannel channel = C_PoolChannel.Global) { if (objectParam == null || channel == C_PoolChannel.None) { C_DebugHelper.LogError("C_PoolMgr Despawn: Object is Null!"); return; } if (string.IsNullOrEmpty(objectParam.name)) { C_DebugHelper.LogError("C_PoolMgr Despawn: Object name is Null or Empty!"); return; } // 添加通道 if (!m_PoolHandlerDict.ContainsKey(channel)) { m_PoolHandlerDict[channel] = new List <Object>(); } if (!m_PoolHandlerDict[channel].Contains(objectParam)) { m_PoolHandlerDict[channel].Add(objectParam); //Debug.LogError("添加 对象池"); } while (m_PoolHandlerDict[channel].Count > m_Capacity) { Object dob = m_PoolHandlerDict[channel][0]; m_PoolHandlerDict[channel].RemoveAt(0); Destroy(dob); } }
public static T GetAssetBundleFormCache <T>(string resName, string assetBundleFilePath, bool isInstantiate = false, bool isForever = false) where T : UnityEngine.Object { T result = null; try { C_AssetBundleRef bundle = C_MonoSingleton <C_AssetBundleMgr> .GetInstance().GetAssetBundleRefList(assetBundleFilePath); if (bundle != null) { result = bundle.LoadAsset <T>(resName); if (isInstantiate && result != null) { result = GameObject.Instantiate(result); } } } catch (Exception e) { C_DebugHelper.LogError("GetAssetBundleFormCache : " + e); } return(result); }
private static Byte[] ToByteArray(UInt32[] data, Boolean includeLength) { if (data == null) { return(null); } try { Int32 n; if (includeLength) { n = (Int32)data[data.Length - 1]; } else { n = data.Length << 2; } Byte[] result = new Byte[n]; for (Int32 i = 0; i < n; i++) { result[i] = (Byte)(data[i >> 2] >> ((i & 3) << 3)); } return(result); } catch (Exception e) { C_DebugHelper.LogError("C_XXTea ToByteArray e.Message = " + e.Message); } return(null); }
/// <summary> /// 添加延迟事件方法 /// </summary> /// <param name="time">延迟时间</param> /// <param name="timeUpAction">方法</param> /// <param name="name">方法名</param> /// <param name="loop">是否循环?</param> public void AddTimer(float time, Action timeUpAction, string name, int loop = 1) { if (timeUpAction == null) { C_DebugHelper.LogError("C_TimerMgr AddTimer timeUpAction is null!"); } m_TimerList.Add(new C_Timer(time, timeUpAction, name, loop)); }
public int AddTimer(float time, Action timeUpAction, int loop = 1) { if (timeUpAction == null) { C_DebugHelper.LogError("C_TimerMgr AddTimer timeUpAction is null!"); return(-1); } m_nTimerSequence++; m_TimerList.Add(new C_Timer(time, timeUpAction, m_nTimerSequence, loop)); return(m_nTimerSequence); }
public static T LoadAssetBundle <T>(string resName, string assetBundleFilePath, List <string> dpsList, bool isInstantiate = false, bool isForever = false) where T : UnityEngine.Object { if (string.IsNullOrEmpty(resName) || string.IsNullOrEmpty(assetBundleFilePath)) { return(null); } T result = null; try { C_AssetBundleRef[] abs = new C_AssetBundleRef[dpsList.Count]; for (int i = 0; i < abs.Length; i++) { C_DebugHelper.LogFormat("LoadResource abs[{0}]: {1}", i, dpsList[i]); abs[i] = C_MonoSingleton <C_AssetBundleMgr> .GetInstance().LoadFromFile(dpsList[i], isForever); } C_AssetBundleRef bundle = C_MonoSingleton <C_AssetBundleMgr> .GetInstance().LoadFromFile(assetBundleFilePath, isForever); if (bundle != null) { result = bundle.LoadAsset <T>(resName); if (isInstantiate && result != null) { result = GameObject.Instantiate(result); } bundle.AutoUnload(); } for (int i = 0; i < abs.Length; i++) { if (abs[i] != null) { abs[i].AutoUnload(); } } } catch (Exception e) { C_DebugHelper.LogError("LoadAssetBundle : " + e); } return(result); }
public static UInt32[] Decrypt(UInt32[] v, UInt32[] k) { if (v == null || k == null) { return(null); } try { Int32 n = v.Length - 1; if (n < 1) { return(v); } if (k.Length < 4) { UInt32[] key = new UInt32[4]; k.CopyTo(key, 0); k = key; } UInt32 z = v[n], y = v[0], delta = 0x9E3779B9, sum, e; Int32 p, q = 6 + 52 / (n + 1); sum = unchecked ((UInt32)(q * delta)); while (sum != 0) { e = sum >> 2 & 3; for (p = n; p > 0; p--) { z = v[p - 1]; y = unchecked (v[p] -= (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z)); } z = v[n]; y = unchecked (v[0] -= (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z)); sum = unchecked (sum - delta); } return(v); } catch (Exception e) { C_DebugHelper.LogError("C_XXTea Decrypt e.Message = " + e.Message); } return(null); }
public static UInt32[] Encrypt(UInt32[] v, UInt32[] k) { if (v == null || k == null) { return(null); } try { Int32 n = v.Length - 1; if (n < 1) { return(v); } if (k.Length < 4) { UInt32[] key = new UInt32[4]; k.CopyTo(key, 0); k = key; } UInt32 z = v[n], y = v[0], delta = 0x9E3779B9, sum = 0, e; Int32 p, q = 6 + 52 / (n + 1); while (q-- > 0) { sum = unchecked (sum + delta); e = sum >> 2 & 3; for (p = 0; p < n; p++) { y = v[p + 1]; z = unchecked (v[p] += (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z)); } y = v[0]; z = unchecked (v[n] += (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z)); } return(v); } catch (Exception e) { C_DebugHelper.LogError("C_XXTea Encrypt e.Message = " + e.Message); } return(null); }
private GameObject ReallyOpenUI(string uiName, string uiPath, bool isCloseOthers, params object[] uiParams) { if (string.IsNullOrEmpty(uiName)) { C_DebugHelper.LogError("C_UIMgr ReallyOpenUI uiName is null or empty!"); return(null); } if (isCloseOthers) { CloseUIAll(); } GameObject UIObject = GetUI(uiName); if (UIObject != null) { C_BaseUI listBaseUI = UIObject.gameObject.GetComponent <C_BaseUI>(); if (listBaseUI != null) { listBaseUI.OpenUI(uiParams); } return(UIObject); } UIObject = C_Singleton <GameResMgr> .GetInstance().LoadResource_UI(uiName, uiPath); if (UIObject != null) { UIObject.name = uiName; m_OpenedUIsList.Add(UIObject); C_BaseUI baseUI = UIObject.GetComponent <C_BaseUI>(); if (baseUI != null) { baseUI.OpenUI(uiParams); } } return(UIObject); }
public void RegisterState(string name, C_IState state) { if (string.IsNullOrEmpty(name)) { C_DebugHelper.LogError("C_StateMachine RegisterState name is null or empty!"); return; } if (state == null) { C_DebugHelper.LogError("C_StateMachine RegisterState state is null!"); return; } if (m_RegistedState.ContainsKey(name)) { C_DebugHelper.LogError("C_StateMachine RegisterState name = " + name + " is covered!"); } m_RegistedState[name] = state; }
public void RemoveShadowCaster(GameObject gOParam) { if (gOParam == null) { C_DebugHelper.LogError("C_ShadowProjector AddShadowCaster: gOParam is Null!"); return; } if (gOParam.layer == LayerMask.NameToLayer("ShadowCaster")) { C_DebugHelper.LogError("C_ShadowProjector AddShadowCaster: gOParam layer != ShadowCaster"); return; } for (int i = m_ShadowCasterList.Count - 1; i >= 0; i--) { if (m_ShadowCasterList[i] == gOParam) { m_ShadowCasterList.RemoveAt(i); } } }
//销毁同样名字的对象 public void Destory(string resName, C_PoolChannel channel = C_PoolChannel.Global) { if (string.IsNullOrEmpty(resName) || channel == C_PoolChannel.None) { C_DebugHelper.LogError("C_PoolMgr Destory: resName is Null or Empty!"); return; } resName = StandardResName(resName); if (m_PoolHandlerDict.ContainsKey(channel)) { for (int i = m_PoolHandlerDict[channel].Count - 1; i >= 0; i++) { if (m_PoolHandlerDict[channel][i] != null && m_PoolHandlerDict[channel][i].name == resName) { Object go = m_PoolHandlerDict[channel][i]; m_PoolHandlerDict[channel].RemoveAt(i); Destroy(go); } } } }
private static UInt32[] ToUInt32Array(Byte[] data, Boolean includeLength) { if (data == null) { return(null); } try { Int32 n = (((data.Length & 3) == 0) ? (data.Length >> 2) : ((data.Length >> 2) + 1)); UInt32[] result; if (includeLength) { result = new UInt32[n + 1]; result[n] = (UInt32)data.Length; } else { result = new UInt32[n]; } n = data.Length; for (Int32 i = 0; i < n; i++) { result[i >> 2] |= (UInt32)data[i] << ((i & 3) << 3); } return(result); } catch (Exception e) { C_DebugHelper.LogError("C_XXTea ToUInt32Array e.Message = " + e.Message); } return(null); }
public JsonData this[string prop_name] { get { EnsureDictionary(); if (inst_object[prop_name] == null) { C_DebugHelper.LogError(" assert "); } return(inst_object[prop_name]); } set { EnsureDictionary(); KeyValuePair <string, JsonData> entry = new KeyValuePair <string, JsonData> (prop_name, value); if (inst_object.ContainsKey(prop_name)) { for (int i = 0; i < object_list.Count; i++) { if (object_list[i].Key == prop_name) { object_list[i] = entry; break; } } } else { object_list.Add(entry); } inst_object[prop_name] = value; json = null; } }
void Update() { try { //强制卸载 if (m_ForceDirtyAssetBundleRefList.Count > 0) { for (int i = 0; i < m_ForceDirtyAssetBundleRefList.Count; i++) { // Debug.Log("--ab name:" + m_ForceDirtyAssetBundleRefList[i].Bundle.name + "start unload........."); if (m_ForceDirtyAssetBundleRefList[i].Bundle != null) { m_ForceDirtyAssetBundleRefList[i].Bundle.Unload(true); } } m_ForceDirtyAssetBundleRefList.Clear(); } if (m_UnloadAssetBundleRefList.Count > 0) { for (int i = 0; i < m_UnloadAssetBundleRefList.Count; i++) { if (m_UnloadAssetBundleRefList[i].Bundle != null) { m_UnloadAssetBundleRefList[i].Bundle.Unload(false); } } m_UnloadAssetBundleRefList.Clear(); //黄志龙,后续修改到loading界面去释放 Resources.UnloadUnusedAssets(); } for (int i = m_DirtyAssetBundleRefList.Count - 1; i >= 0; i--) { if (m_DirtyAssetBundleRefList[i] == null || m_DirtyAssetBundleRefList[i].Bundle == null) { m_DirtyAssetBundleRefList.RemoveAt(i); } else { m_UnloadAssetBundleRefList.Add(m_DirtyAssetBundleRefList[i]); m_DirtyAssetBundleRefList.RemoveAt(i); } } if (m_NeedLoadCacheDict.Count > 0) { List <string> keyList = new List <string>(m_NeedLoadCacheDict.Keys); for (int i = m_NeedLoadCacheDict.Count - 1; i >= 0; i--) { List <string> valueList = m_NeedLoadCacheDict[keyList[i]]; if (valueList.Count > 4) { LoadFromFile(valueList[valueList.Count - 1], true); LoadFromFile(valueList[valueList.Count - 2], true); LoadFromFile(valueList[valueList.Count - 3], true); LoadFromFile(valueList[valueList.Count - 4], true); m_NeedLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 1); m_NeedLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 1); m_NeedLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 1); m_NeedLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 1); } else if (valueList.Count > 0) { C_DebugHelper.Log("id:" + valueList.Count + "--ab name:" + valueList[valueList.Count - 1] + "start"); LoadFromFile(valueList[valueList.Count - 1], true); C_DebugHelper.Log("id:" + valueList.Count + "--ab name:" + valueList[valueList.Count - 1] + "end"); m_NeedLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 1); } else { m_NeedLoadCacheDict.Remove(keyList[i]); } } } if (m_UnLoadCacheDict.Count > 0) { List <string> keyList = new List <string>(m_UnLoadCacheDict.Keys); for (int i = m_UnLoadCacheDict.Count - 1; i >= 0; i--) { List <string> valueList = m_UnLoadCacheDict[keyList[i]]; /* if (valueList.Count > 4) * { * C_AssetBundleRef abr = GetAssetBundleRefList(valueList[valueList.Count - 1]); * if (abr != null) * abr.CacheUnload(); * * abr = GetAssetBundleRefList(valueList[valueList.Count - 2]); * if (abr != null) * abr.CacheUnload(); * abr = GetAssetBundleRefList(valueList[valueList.Count - 3]); * if (abr != null) * abr.CacheUnload(); * abr = GetAssetBundleRefList(valueList[valueList.Count - 4]); * if (abr != null) * abr.CacheUnload(); * * m_UnLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 1); * m_UnLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 2); * m_UnLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 3); * m_UnLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 4); * * } else*/if (valueList.Count > 0) { C_AssetBundleRef abr = GetAssetBundleRefList(valueList[valueList.Count - 1]); if (abr != null) { abr.CacheUnload(); C_DebugHelper.Log("id:" + valueList.Count + "--ab name:" + abr.Bundle.name); } m_UnLoadCacheDict[keyList[i]].RemoveAt(valueList.Count - 1); } else { m_UnLoadCacheDict.Remove(keyList[i]); } } } } catch (System.Exception e) { C_DebugHelper.LogError("NeedLoadCache error is :" + e); } }