public override IEnumerator LoadAsync() { if (IsLoad) { yield break; } IsLoad = false; Request_ = CreateBundleRequestAsync(AssetPath); yield return(Request_); if (Request_ == null || !Request_.isDone) { LLogger.LWarning($"Load AssetBundle : {AssetPath} Failed"); } else { RefCount_ = 0; IsLoad = true; Bundle_ = Request_.assetBundle; OnLoad(); Request_ = null; } yield break; }
private bool LoadAssetBundleManifest(string ResPath) { var FullPath = PathHelper.GetAssetFullPath(ResPath); if (string.IsNullOrEmpty(FullPath)) { LLogger.LError($"LoadAssetBundleManifest Failed : {FullPath}"); return(false); } var Bundle = UnityEngine.AssetBundle.LoadFromFile(FullPath); if (Bundle != null) { Manifest_ = Bundle.LoadAsset <UnityEngine.AssetBundleManifest>("AssetBundleManifest"); Bundle.Unload(false); AssetBundlePathList_.AddRange(Manifest_.GetAllAssetBundles()); return(true); } else { LLogger.LError($"LoadAssetBundleManifest Failed : {FullPath}"); } return(false); }
private void HandleTargetInOut(List <Bio> targetsEnter, List <Bio> targetsExit) { if (targetsEnter != null) { int c1 = targetsEnter.Count; for (int i = 0; i < c1; i++) { Bio target = targetsEnter[i]; this.OnTargetEnter(target); LLogger.Info("enter"); target.AddRef(); } } if (targetsExit != null) { int count = targetsExit.Count; for (int i = 0; i < count; i++) { Bio target = targetsExit[i]; LLogger.Info("exit"); this.OnTargetExit(target); target.RedRef(); } } }
public void UseSkill(Skill skill, Bio target, Vec3 targetPoint) { if (!this.CanUseSkill(skill)) { LLogger.Log("skill:{0} can not use.", skill.id); return; } if (skill.castType == CastType.Target && (target == null || target.isDead)) { return; } switch (skill.castType) { case CastType.Target: case CastType.Point: this.Pursue(skill, target, skill.castType == CastType.Immediately ? this.property.position : targetPoint); break; case CastType.Immediately: case CastType.Dash: this.Attack(skill, target, skill.castType == CastType.Immediately ? this.property.position : targetPoint); break; } }
public T[,] ReadArray2 <T>(string Key, T[,] Default) where T : IArchiveInfo, new() { if (!CacheList_.ContainsKey(Key)) { return(Default); } if (CacheList_[Key] is object[,] ArrayObj) { var Width = ArrayObj.GetLength(0); var Height = ArrayObj.GetLength(1); var OutputArray = new T[Width, Height]; for (var X = 0; X < Width; ++X) { for (var Y = 0; Y < Height; ++Y) { OutputArray[X, Y] = (T)ArrayObj[X, Y]; } } return(OutputArray); } LLogger.LWarning($"archive type error : {Key} - {typeof(T)}"); return(Default); }
private static void BindEvent(BaseUI UI) { var MethodList = UI.GetType().GetMethods(CustomFlags); foreach (var Method in MethodList) { var Attr = Method.GetCustomAttribute <LiteUIEventAttribute>(false); if (Attr != null) { try { if (Method.GetParameters().Length == 0) { UI.AddEventToChild(Attr.Path, Delegate.CreateDelegate(typeof(UnityAction), UI, Method) as UnityAction, Attr.EventType); } else { UI.AddEventToChild(Attr.Path, Delegate.CreateDelegate(typeof(Action <EventSystemData>), UI, Method) as UnityAction, Attr.EventType); } } catch (Exception Ex) { LLogger.LWarning(Ex.Message); LLogger.LWarning($"can't bind component : {Attr.Path}"); } } } }
public T[] ReadSubArray <T>(string Key, T[] Default) where T : IArchiveInfo, new() { if (!CacheList_.ContainsKey(Key)) { return(Default); } if (CacheList_[Key] is object[] ArrayObj) { var Len = Default?.Length ?? ArrayObj.Length; var OutputArray = new T[Len]; for (var Index = 0; Index < Len; ++Index) { if (Index < ArrayObj.Length) { OutputArray[Index] = (T)ArrayObj[Index]; } else { OutputArray[Index] = Default[Index]; } } return(OutputArray); } LLogger.LWarning($"archive type error : {Key} - {typeof(T)}"); return(Default); }
private static void BindNode(BaseUI UI) { var FieldList = UI.GetType().GetFields(CustomFlags); foreach (var Field in FieldList) { if (Field.FieldType != TransformType) { continue; } var Attr = Field.GetCustomAttribute <LiteUINodeAttribute>(false); if (Attr != null) { var NodeValue = UI.FindChild(Attr.Path); if (NodeValue == null) { LLogger.LWarning($"can't bind node : {Attr.Path}"); continue; } Field.SetValue(UI, NodeValue); } } }
private static void BindComponent(BaseUI UI) { var FieldList = UI.GetType().GetFields(CustomFlags); foreach (var Field in FieldList) { if (!Field.FieldType.IsSubclassOf(ComponentType)) { continue; } var Attr = Field.GetCustomAttribute <LiteUIComponentAttribute>(false); if (Attr != null) { var ComponentValue = UI.GetComponent(Attr.Path, Field.FieldType); if (ComponentValue == null) { LLogger.LWarning($"can't bind component : {Attr.Path}"); continue; } Field.SetValue(UI, ComponentValue); } } }
public static void GenerateFilesInfoFile() { if (!Directory.Exists(Path.Combine(Application.dataPath, "Resources"))) { Directory.CreateDirectory(Path.Combine(Application.dataPath, "Resources")); } var FilePath = Path.Combine(Application.dataPath, "Resources", FilesInfoFileName); var FileList = PathHelper.GetFileList(Application.streamingAssetsPath, (Path) => PathHelper.GetFileExt(Path) != ".meta"); if (File.Exists(FilePath)) { File.Delete(FilePath); } using (var OutStream = new StreamWriter(FilePath, false, Encoding.ASCII)) { foreach (var File in FileList) { var RelativePath = File.Substring(Application.streamingAssetsPath.Length + 1); OutStream.WriteLine(RelativePath); } OutStream.Close(); } LLogger.LWarning($"Generate FilesInfo Succeed -> {FilePath}"); }
public static bool CacheStreamingAssets(Action <int, int, int> Callback) { var Files = Resources.Load <TextAsset>(PathHelper.GetFileNameWithoutExt(FilesInfoFileName)); if (Files == null || string.IsNullOrWhiteSpace(Files.text)) { LLogger.LWarning("version.txt is empty"); return(false); } var FileList = Files.text.Split(new char[] { '\r', '\n' }); var FileListTrim = new List <string>(); foreach (var FileName in FileList) { if (string.IsNullOrWhiteSpace(FileName)) { continue; } FileListTrim.Add(FileName); } TaskManager.AddTask(CacheStreamingAssets(FileListTrim.ToArray(), Callback)); return(true); }
public static void DeleteStreamingAssets() { Directory.Delete(Application.streamingAssetsPath, true); Directory.CreateDirectory(Application.streamingAssetsPath); AssetDatabase.Refresh(); LLogger.LWarning("StreamingAssets Remove"); }
/// <summary> /// only support (Boolean, Int32, BigInteger, String) /// </summary> public T[] ReadArray <T>(string Key, T[] Default) { if (!CacheList_.ContainsKey(Key)) { return(Default); } if (CacheList_[Key] is T[] Value) { if (Default != null && Value.Length < Default.Length) { var NewValue = new T[Default.Length]; for (var Index = 0; Index < NewValue.Length; ++Index) { if (Index < Value.Length) { NewValue[Index] = Value[Index]; } else { NewValue[Index] = Default[Index]; } } return(NewValue); } return(Value); } LLogger.LWarning($"archive type error : {Key} - {typeof(T)}"); return(Default); }
public void AddRef(bool log = true) { ++this.reference; if (log) { LLogger.Info("[Add]{0}: {1}", this.rid, this.reference); } }
public void DisplayMsg() { if (IsValid()) { var Msg = $"[Profiler] {FullPath_} ({GetTotalTime():0.000}s)"; LLogger.LInfo(Msg); } }
public void RedRef(bool log = true) { if (log) { LLogger.Info("[Red]{0}: {1}", this.rid, this.reference); } --this.reference; }
void Update() { try { LiteManager.Tick(Time.deltaTime); } catch (System.Exception Ex) { LLogger.LError($"{Ex.Message}\n{Ex.StackTrace}"); } #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.F1)) { LiteManager.TimeScale = 0.5f; LLogger.LWarning($"TimeScale = {LiteManager.TimeScale}"); } else if (Input.GetKeyDown(KeyCode.F2)) { LiteManager.TimeScale = 1.0f; LLogger.LWarning($"TimeScale = {LiteManager.TimeScale}"); } else if (Input.GetKeyDown(KeyCode.F3)) { LiteManager.TimeScale = 5.0f; LLogger.LWarning($"TimeScale = {LiteManager.TimeScale}"); } else if (Input.GetKeyDown(KeyCode.PageUp)) { LiteManager.TimeScale--; LLogger.LWarning($"TimeScale = {LiteManager.TimeScale}"); } else if (Input.GetKeyDown(KeyCode.PageDown)) { LiteManager.TimeScale++; LLogger.LWarning($"TimeScale = {LiteManager.TimeScale}"); } if (Input.GetKeyDown(KeyCode.F5)) { LiteManager.Restart(); } else if (Input.GetKeyDown(KeyCode.F6)) { LiteManager.Shutdown(); } else if (Input.GetKeyDown(KeyCode.F9)) { EnableGizmos_ = !EnableGizmos_; } else if (Input.GetKeyDown(KeyCode.F12)) { OnApplicationPause(!LiteManager.IsPause); } #endif }
public static bool Startup(ILogic Logic) { MainLogic = Logic; LLogger.LInfo($"{nameof(DataManager)} Startup"); if (!DataManager.Startup()) { LLogger.LError($"{nameof(DataManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(AssetManager)} Startup"); if (!AssetManager.Startup()) { LLogger.LError($"{nameof(AssetManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(AudioManager)} Startup"); if (!AudioManager.Startup()) { LLogger.LError($"{nameof(AudioManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(SfxManager)} Startup"); if (!SfxManager.Startup()) { LLogger.LError($"{nameof(SfxManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(UIManager)} Startup"); if (!UIManager.Startup()) { LLogger.LError($"{nameof(UIManager)} Startup Failed"); return(false); } #if LITE_USE_LUA_MODULE LLogger.LInfo($"{nameof(LuaRuntime)} Startup"); if (!LuaRuntime.Startup()) { LLogger.LError($"{nameof(LuaRuntime)} Startup Failed"); return(false); } #endif if (MainLogic == null || !MainLogic.Startup()) { LLogger.LError($"Logic Startup Failed"); return(false); } return(true); }
public void Create(Navmesh navmesh) { this._navmesh = navmesh; //一定要保存起来,Navmesh的析构函数会把非托管内存的指针清掉!! NavStatus status = NavmeshQuery.Create(navmesh, 2048, out this._query); if (status != NavStatus.Sucess) { LLogger.Error(status); } }
public Vec3 SampleNavPosition(Vec3 searchPoint) { NavStatus status = this._pathManager.GetNearestPoint(searchPoint, out Vec3 resultPoint); if (status != NavStatus.Sucess) { LLogger.Warning(status); } return(resultPoint); }
internal bool DestroyBuffState(BSBase bs) { if (this._buffStatesToDestroy.Contains(bs)) { LLogger.Warning("BuffState {0} already in destroy list", bs.id); return(false); } this._buffStatesToDestroy.Add(bs); return(true); }
public static T OpenUI<T>(params object[] Params) where T : BaseUI, new() { var ScriptType = typeof(T); if (!LiteConfigure.UIDescList.ContainsKey(ScriptType)) { LLogger.LError($"Can't find UI Desc : {ScriptType.Name}"); return null; } return OpenUI<T>(LiteConfigure.UIDescList[ScriptType], Params); }
public void WriteSub <T>(string Key, T Value) where T : IArchiveInfo, new() { if (CacheList_.ContainsKey(Key)) { LLogger.LWarning($"archive repeat key : {Key}"); CacheList_[Key] = Value; return; } CacheList_.Add(Key, Value); }
void OnApplicationQuit() { try { LiteManager.Shutdown(); } catch (System.Exception Ex) { LLogger.LError($"{Ex.Message}\n{Ex.StackTrace}"); } }
public static bool Startup(UnityEngine.MonoBehaviour Instance) { LLogger.LInfo($"{nameof(EventManager)} Startup"); if (!EventManager.Startup()) { LLogger.LError($"{nameof(EventManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(ObjectPoolManager)} Startup"); if (!ObjectPoolManager.Startup()) { LLogger.LError($"{nameof(ObjectPoolManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(GroupManager)} Startup"); if (!GroupManager.Startup()) { LLogger.LError($"{nameof(GroupManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(TaskManager)} Startup"); if (!TaskManager.Startup(Instance)) { LLogger.LError($"{nameof(TaskManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(TimerManager)} Startup"); if (!TimerManager.Startup()) { LLogger.LError($"{nameof(TimerManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(MotionManager)} Startup"); if (!MotionManager.Startup()) { LLogger.LError($"{nameof(MotionManager)} Startup Failed"); return(false); } LLogger.LInfo($"{nameof(NetManager)} Startup"); if (!NetManager.Startup()) { LLogger.LError($"{nameof(NetManager)} Startup Failed"); return(false); } return(true); }
public override void Check() { if (OnEvent != null) { var CallbackList = OnEvent.GetInvocationList(); foreach (var Callback in CallbackList) { LLogger.LWarning($"{Callback.Method.ReflectedType.Name} : {Callback.Method.Name} UnRegister"); } } }
public bool NavMeshRaycast(Vec3 src, Vec3 dest, out Vec3 hitPosition, out Vec3 hitNormal) { NavStatus status = this._pathManager.Raycast(src, dest, out float hitParameter, out hitNormal); if (status != NavStatus.Sucess) { LLogger.Warning(status); } hitPosition = src + (dest - src) * hitParameter; //True if the ray is terminated before reaching target position. Otherwise returns false. return(hitParameter < 1); }
public void Set(Vec3[] corners) { this.path = new Path(corners); if (!this.path.vaild) { LLogger.Warning("Invalid path"); return; } this.complete = false; this.path.Next(); }
public bool Save(string FilePath) { try { File.WriteAllBytes(FilePath, GetRawBuffer()); return(true); } catch (Exception Ex) { LLogger.LError(Ex.Message); return(false); } }
public static void Connect(IPAddress Ip, int Port) { if (Codec == null) { LLogger.LError("NetManager.Codec is null"); return; } NetManager.Ip = Ip; NetManager.Port = Port; NetManager.TcpClient_ = new TcpClient(); NetManager.TcpClient_.BeginConnect(Ip, Port, OnTcpConnectResult, TcpClient_); }