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); }
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); }
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 }
void OnApplicationQuit() { try { LiteManager.Shutdown(); } catch (System.Exception Ex) { LLogger.LError($"{Ex.Message}\n{Ex.StackTrace}"); } }
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 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 bool Decode(IArchiveInfo Arc) { try { Arc.Decode(Decoder_); return(true); } catch (Exception Ex) { LLogger.LError(Ex.Message); return(false); } }
public bool Save() { try { WriteArchiveCrcCode(); return(WriteStream_.Save(ArchivePath_)); } 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_); }
public bool Save(string FilePath) { try { File.WriteAllBytes(FilePath, GetRawBuffer()); return(true); } catch (Exception Ex) { LLogger.LError(Ex.Message); return(false); } }
private bool CheckArchiveCrc() { var RawBuffer = ReadStream_.GetRawBuffer(); // Header foreach (var Ch in Header) { if (ReadStream_.ReadInt8() != (byte)Ch) { LLogger.LError("is invalid lite archive file"); return(false); } } // Version var VersionCode = ReadStream_.ReadInt32(); if (VersionCode < ForceVersionCode) { LLogger.LError($"force require version {ForceVersionCode}, current is {VersionCode}"); return(false); } if (VersionCode < CurrentVersionCode) { // compatible code } // Length var Length = ReadStream_.ReadInt32(); if (Length != RawBuffer.Length) { LLogger.LError($"error archive file length, expect : {Length}, but now : {RawBuffer.Length}"); return(false); } // Crc32 var CrcCode = ReadStream_.ReadUInt32(); var DataStart = Header.Length + 4 + 4 + 4; var DataLength = RawBuffer.Length - DataStart; var Code = Crc32.Calculate(RawBuffer, DataStart, DataLength); if (Code != CrcCode) { LLogger.LError("archive data is broken"); return(false); } return(true); }
public bool Encode(IArchiveInfo Arc) { try { Arc.Encode(Encoder_); Encoder_.Flush(); return(true); } catch (Exception Ex) { LLogger.LError(Ex.Message); return(false); } }
public bool Load(string FilePath) { try { var Buffer = File.ReadAllBytes(FilePath); Stream_ = new MemoryStream(Buffer); Stream_.Seek(0, SeekOrigin.Begin); return(true); } catch (Exception Ex) { LLogger.LError(Ex.Message); return(false); } }
void Awake() { Camera.main.orthographicSize = Screen.height / 100.0f / 2.0f; Style_ = new GUIStyle { fontSize = 30, normal = { background = null, textColor = Color.white } }; try { Logic_ = new GameLogic(); //Logic_ = new TestLogic(); LiteManager.Startup(this, Logic_); } catch (System.Exception Ex) { LLogger.LError($"{Ex.Message}\n{Ex.StackTrace}"); } }
private static Transform GetOrCreateGameObject(UIDescriptor Desc) { if (CacheList_.ContainsKey(Desc.Uri) && !Desc.OpenMore) { var UIObj = CacheList_[Desc.Uri]; CacheList_.Remove(Desc.Uri); return UIObj; } var Obj = AssetManager.CreatePrefabSync(Desc.Uri); if (Obj == null) { LLogger.LError($"Can't Create UI : {Desc.Uri}"); return null; } return Obj.transform; }
private static void SetAssetBundleName(string ResPath) { var Importer = AssetImporter.GetAtPath($"Assets/{LiteConfigure.StandaloneAssetsName}/{ResPath}"); if (Importer == null) { LLogger.LError($"unexpected asset path : {ResPath}"); return; } /*var Index = ResPath.LastIndexOf('.'); * if (Index == -1) * { * LLogger.LError($"unexpected asset path : {ResPath}"); * return; * } * * var BundleName = ResPath.Substring(0, Index);*/ /*var BundleName = ResPath; * * if (Importer is TextureImporter TexImporter) * { * var Index = ResPath.LastIndexOf('.'); * BundleName = ResPath.Substring(0, Index); * * if (TexImporter.textureType == TextureImporterType.Sprite) * { * BundleName = $"{BundleName}.sprite"; * } * else * { * BundleName = $"{BundleName}.texture"; * } * }*/ var BundleName = ResPath; Importer.assetBundleName = BundleName; Importer.assetBundleVariant = string.Empty; }
public static bool Startup() { 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); } return(true); }
void Awake() { try { var LogicType = System.Type.GetType(LogicClassName); if (LogicType == null) { throw new LiteException($"can't not find game logic class type : {LogicClassName}"); } if (!(System.Activator.CreateInstance(LogicType) is ILogic Logic)) { throw new LiteException("LiteMain Logic must not be null"); } LiteManager.Startup(this, Logic); } catch (System.Exception Ex) { LLogger.LError($"{Ex.Message}\n{Ex.StackTrace}"); } }
public bool Load() { try { if (!ReadStream_.Load(ArchivePath_)) { return(false); } if (!CheckArchiveCrc()) { return(false); } Decoder_.Flush(); return(true); } catch (Exception Ex) { LLogger.LError(Ex.Message); return(false); } }
public override void Play(string AnimationName, bool IsLoop = false, Action Finished = null) { if (Graphic_.SkeletonData.FindAnimation(AnimationName) == null) { LLogger.LError($"can't play animation '{AnimationName}'"); return; } Graphic_.AnimationState.SetAnimation(0, AnimationName, IsLoop); if (Finished == null) { Graphic_.AnimationState.Complete = null; } else { Graphic_.AnimationState.Complete = (Track) => { Finished?.Invoke(); Graphic_.AnimationState.Complete = null; }; } }
public bool Parse(byte[] Buffer) { if (Buffer == null || Buffer.Length == 0) { return(false); } try { IsLoaded = false; Keys_.Clear(); DataLines_.Clear(); Index_ = 0; Buffer_ = Buffer; var Column = ReadByte(); for (var Index = 0; Index < Column; ++Index) { var Key = ReadString2(); Keys_.Add(Key); } var HeaderType = new List <DataType>(); for (var Index = 0; Index < Column; ++Index) { var Type = ReadInt8(); HeaderType.Add((DataType)Type); } while (CanRead()) { var Line = new DataLine(); for (var Index = 0; Index < Column; ++Index) { switch (HeaderType[Index]) { case DataType.Int: Line.Add(Keys_[Index], new DataEntity <int>(ReadInt32())); break; case DataType.IntArray: Line.Add(Keys_[Index], new DataEntity <int[]>(ReadInt32Array())); break; case DataType.Short: Line.Add(Keys_[Index], new DataEntity <short>(ReadInt16())); break; case DataType.ShortArray: Line.Add(Keys_[Index], new DataEntity <short[]>(ReadInt16Array())); break; case DataType.Byte: Line.Add(Keys_[Index], new DataEntity <byte>(ReadInt8())); break; case DataType.ByteArray: Line.Add(Keys_[Index], new DataEntity <byte[]>(ReadInt8Array())); break; case DataType.Bool: Line.Add(Keys_[Index], new DataEntity <bool>(ReadBool())); break; case DataType.BoolArray: Line.Add(Keys_[Index], new DataEntity <bool[]>(ReadBoolArray())); break; case DataType.String: Line.Add(Keys_[Index], new DataEntity <string>(ReadString2())); break; case DataType.StringArray: Line.Add(Keys_[Index], new DataEntity <string[]>(ReadString2Array())); break; case DataType.BigInt: Line.Add(Keys_[Index], new DataEntity <BigInteger>(BigNumHelper.ToBigInt(ReadString()))); break; default: break; } } DataLines_.Add(Line.Get <int>("id"), Line); } IsLoaded = true; return(true); } catch (Exception Ex) { LLogger.LError(Ex.Message); return(false); } }