public bool LoadSceneExtLocalPalletTex(string sceneFileName, int group) { Texture2D tex = this.LocalPalletTex; if (tex != null) { return(true); } if (string.IsNullOrEmpty(sceneFileName) || group < 0 || m_Image < 0 || mParentLib == null) { return(false); } string fileName = GlobalConfigMgr.GetConfigFileNameNoExt(sceneFileName); string globalFileName = string.Format("{0}.act.bytes", fileName); tex = mParentLib.GetScenePalletTexture(globalFileName); if (tex == null) { fileName = string.Format("{0}_{1:D}-{2:D}.act.bytes", fileName, group, m_Image); tex = mParentLib.GetScenePalletTexture(fileName); } bool ret = tex != null; if (ret) { mLocalPalletTex = tex; } return(ret); }
public string GeneratorPalletFileName(string playerName, string palletName) { palletName = GlobalConfigMgr.GetConfigFileNameNoExt(palletName); string fileName = string.Format("{0}@{1}/{2}.act.bytes", AppConfig.GetInstance().PlayerRootDir, playerName, palletName); return(fileName); }
// 取第一个有效的PalletName private string GetFirstVaildPalletName() { GlobalPlayer player = this.GPlayer; if (player == null || player.PlayerCfg == null || !player.PlayerCfg.IsVaild || player.PlayerCfg.Files == null) { return(string.Empty); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal1)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal1)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal2)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal2)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal3)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal3)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal4)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal4)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal5)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal5)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal6)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal6)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal7)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal7)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal8)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal8)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal9)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal9)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal10)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal10)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal11)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal11)); } if (!string.IsNullOrEmpty(player.PlayerCfg.Files.pal12)) { return(GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.pal12)); } return(string.Empty); }
public void Init() { Clear(); m_ImgLib = new ImageLibrary(Is32BitPallet); DefaultLoaderPlayer loadPlayer = GetComponent <DefaultLoaderPlayer> (); var player = loadPlayer.GetGlobalPayer(); string spriteName = GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.sprite); LoadOk = m_ImgLib.LoadChar(loadPlayer.GetPlayerName(), player.AirCfg, spriteName); }
// 进入当前场景 public bool EnterCurrentScene() { SceneImageRes imgRes = this.ImageRes; if (imgRes == null || m_Config == null || !m_Config.IsVaild) { return(false); } var bgCfg = m_Config.BgCfg; if (bgCfg == null) { return(false); } var bgDef = m_Config.bgDef; if (bgDef == null || string.IsNullOrEmpty(bgDef.spr)) { return(false); } var name = bgDef.spr; name = GlobalConfigMgr.GetConfigFileNameNoExt(name); if (string.IsNullOrEmpty(name)) { return(false); } string sceneRoot; if (string.IsNullOrEmpty(DefaultSceneRoot)) { sceneRoot = string.Format("{0}@{1}/{2}", AppConfig.GetInstance().SceneRootDir, DefaultSceneName, name); } else { sceneRoot = string.Format("{0}{1}/@{2}/{3}", AppConfig.GetInstance().SceneRootDir, DefaultSceneRoot, DefaultSceneName, name); } string fileName = string.Format("{0}.sff.bytes", sceneRoot); if (!imgRes.LoadScene(fileName, m_Config)) { Debug.LogErrorFormat("[sff] {0} is not found~!!!", fileName); return(false); } m_LoadedSceneName = this.DefaultSceneName; m_LoadedSceneFileName = sceneRoot; // 創建場景 CreateScene(); AppConfig.GetInstance().StartFollow(); PlayCurrSceneAudio(); return(true); }
public GlobalPlayer GetGlobalPayer() { if (!GlobalConfigMgr.GetInstance().HasLoadPlayer(this)) { return(null); } GlobalPlayerLoaderResult result; var ret = GlobalConfigMgr.GetInstance().LoadPlayer(this, out result); return(ret); }
private void CreateClsn(Rect[] r, bool isCls2, bool showSprite) { if (r == null || r.Length <= 0) { return; } string name; if (isCls2) { name = "clsn2"; } else { name = "clsn1"; } var mgr = GlobalConfigMgr.GetInstance(); for (int i = 0; i < r.Length; ++i) { Rect s = r [i]; if (showSprite) { if (m_ClsnSpriteRoot == null) { GameObject obj = new GameObject("clsn"); m_ClsnSpriteRoot = obj.transform; m_ClsnSpriteRoot.SetParent(this.CachedTransform, false); m_ClsnSpriteRoot.localPosition = Vector3.zero; m_ClsnSpriteRoot.localRotation = Quaternion.identity; m_ClsnSpriteRoot.localScale = Vector3.one; } mgr.CreateClsnSprite(name, m_ClsnSpriteRoot, s.min.x, s.min.y, s.width, s.height, isCls2); } if (m_LoaderPlayer != null) { if (m_ClsnBoxRoot == null) { GameObject obj = new GameObject("box"); m_ClsnBoxRoot = obj.transform; m_ClsnBoxRoot.SetParent(this.CachedTransform, false); m_ClsnBoxRoot.localPosition = Vector3.zero; m_ClsnBoxRoot.localRotation = Quaternion.identity; m_ClsnBoxRoot.localScale = Vector3.one; } mgr.CreateClsnBox(m_LoaderPlayer.PlayerType, name, m_ClsnBoxRoot, s.min.x, s.min.y, s.width, s.height, isCls2); } } }
public bool Load(DefaultLoaderPlayer loaderPlayer) { if (m_IsInited) { return(true); } if (loaderPlayer == null) { return(false); } GlobalPlayerLoaderResult result; var player = GlobalConfigMgr.GetInstance().LoadPlayer(loaderPlayer, out result); if (player == null || player.PlayerCfg == null || !player.PlayerCfg.IsVaild || player.PlayerCfg.Files == null) { return(false); } string soundName = player.PlayerCfg.Files.sound; if (string.IsNullOrEmpty(soundName)) { return(false); } soundName = GlobalConfigMgr.GetConfigFileNameNoExt(soundName); if (string.IsNullOrEmpty(soundName)) { return(false); } string playerName = loaderPlayer.GetPlayerName(); if (string.IsNullOrEmpty(playerName)) { return(false); } string fileName = string.Format("{0}@{1}/{2}.snd.bytes", AppConfig.GetInstance().PlayerRootDir, playerName, soundName); byte[] buffer = AppConfig.GetInstance().Loader.LoadBytes(fileName); if (buffer == null || buffer.Length <= 0) { return(false); } m_IsInited = true; IsLoadedOk = LoadFromBuffer(buffer); return(IsLoadedOk); }
static int RegisterAnimationState(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); GlobalConfigMgr obj = (GlobalConfigMgr)ToLua.CheckObject <GlobalConfigMgr>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); obj.RegisterAnimationState(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetInstance(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); GlobalConfigMgr o = MonoSingleton <GlobalConfigMgr> .GetInstance(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetLuaCnsCfg(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); GlobalConfigMgr obj = (GlobalConfigMgr)ToLua.CheckObject <GlobalConfigMgr>(L, 1); string arg0 = ToLua.CheckString(L, 2); LuaCnsConfig o = obj.GetLuaCnsCfg(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void DestroyAllClsn() { if (m_ClsnSpriteRoot != null && m_ClsnSpriteRoot.childCount > 0) { for (int i = m_ClsnSpriteRoot.childCount - 1; i >= 0; --i) { var trans = m_ClsnSpriteRoot.GetChild(i); if (trans == null) { continue; } var sp = trans.GetComponent <SpriteRenderer> (); if (sp == null) { continue; } GlobalConfigMgr.GetInstance().DestroyClsn(sp); } } if (m_ClsnBoxRoot != null && m_ClsnBoxRoot.childCount > 0) { for (int i = m_ClsnBoxRoot.childCount - 1; i >= 0; --i) { var trans = m_ClsnBoxRoot.GetChild(i); if (trans == null) { continue; } var box = trans.GetComponent <Clsn>(); if (box == null) { continue; } GlobalConfigMgr.GetInstance().DestroyBoxCollider(box); } } }
private void FrmTableLayout_FormClosing(object sender, FormClosingEventArgs e) { GlobalConfigMgr.SaveTables(); }
private bool?SaveOrUpdate(GuestInfo info) { bool success = false; try { var name = info.Name; var gender = info.Gender; var labels = info.Labels; var tableNo = info.TableNo; var imagePath = info.ImagePath; var entourageText = info.Entourage; var guestType = info.GuestType; var userId = info.Id; if (string.IsNullOrEmpty(userId)) { userId = System.Guid.NewGuid().ToString().Replace("-", "").ToUpper(); } var imageFileName = Path.Combine($"GuestImages\\{userId}.jpg"); var img = Bitmap.FromFile(imagePath); var option = new FaceOption() { User_Info = $"姓名: {name} \n身份: {labels}\n桌号: {tableNo} ", }; var guest = GlobalConfigs.Guests.FirstOrDefault(x => x.Name == name); BaseResponse <FaceRegisterResult> jObj; if (guest == null)//新增 { jObj = FaceApi.FaceSaveOrUpdate(new Bitmap(img), GlobalConfigs.Configurations.GroupId, userId, option); success = (jObj != null && jObj.error_code == 0); if (success) { var entourages = entourageText.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); var entourageNum = entourages.Count(); GlobalConfigs.Guests.Add(new ee.Models.GuestInfo() { Id = userId, Name = name, Gender = gender, GuestType = guestType, Entourage = entourageText, EntourageNum = entourageNum, Labels = labels, TableNo = tableNo, ImagePath = imageFileName, CreateTime = DateTime.Now, }); if (entourages != null) { foreach (var item in entourages) { GlobalConfigs.Guests.Add(new ee.Models.GuestInfo() { Id = System.Guid.NewGuid().ToString().Replace("-", "").ToUpper(), ParentId = userId, Name = $"{name}_{item}", Gender = 0, GuestType = guestType, Entourage = "", EntourageNum = 0, Labels = labels, TableNo = tableNo, ImagePath = null, CreateTime = DateTime.Now, }); } } GlobalConfigMgr.SaveGuests(); } } else { jObj = FaceApi.FaceSaveOrUpdate(new Bitmap(img), GlobalConfigs.Configurations.GroupId, guest.Id, option); success = (jObj != null && jObj.error_code == 0); if (success) { var entourages = entourageText.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); var entourageNum = entourages.Count(); guest.Name = name; guest.Gender = gender; guest.GuestType = guestType; guest.Entourage = entourageText; guest.EntourageNum = entourageNum; guest.Labels = labels; guest.TableNo = tableNo; guest.ImagePath = null; guest.CreateTime = DateTime.Now; for (int i = 0; i < GlobalConfigs.Guests.Count; i++) { if (GlobalConfigs.Guests[i].ParentId == userId) { GlobalConfigs.Guests.Remove(GlobalConfigs.Guests[i]); } } if (entourages != null) { foreach (var item in entourages) { GlobalConfigs.Guests.Add(new ee.Models.GuestInfo() { Id = System.Guid.NewGuid().ToString().ToUpper(), ParentId = userId, Name = $"{name}_{item}", Gender = 0, GuestType = guestType, Entourage = "", EntourageNum = 0, Labels = labels, TableNo = tableNo, ImagePath = null, IsAttend = guest.IsAttend, AttendTime = guest.AttendTime, CreateTime = DateTime.Now, }); } } GlobalConfigMgr.SaveGuests(); } } var newImage = new Bitmap(img); img.Dispose(); if (File.Exists(imageFileName)) { File.Delete(imageFileName); } newImage.Save(imageFileName, ImageFormat.Jpeg); newImage.Dispose(); return(success); } catch (Exception ex) { return(false); } }
private bool Init(string playerName, out GlobalPlayerLoaderResult result, string cnsName = "") { Clear(); result = GlobalPlayerLoaderResult.None; m_PlayerName = playerName; if (string.IsNullOrEmpty(playerName)) { result = GlobalPlayerLoaderResult.ParamError; return(false); } try { m_PlayerConfig = new PlayerConfig(); m_PlayerConfig.LoadPlayer(playerName); } catch (Exception e) { #if DEBUG Debug.LogError(e.ToString()); #endif Clear(); result = GlobalPlayerLoaderResult.PlayerConfigError; return(false); } if (!m_PlayerConfig.IsVaild) { Clear(); result = GlobalPlayerLoaderResult.PlayerConfigError; return(false); } try { string airName = string.Empty; if (m_PlayerConfig != null && m_PlayerConfig.Files != null) { airName = m_PlayerConfig.Files.anim; airName = GlobalConfigMgr.GetConfigFileNameNoExt(airName); } m_AirConfig = new AirConfig(playerName, airName); if (!m_AirConfig.IsVaild) { Clear(); result = GlobalPlayerLoaderResult.AirConfigError; return(false); } } catch (Exception e) { #if DEBUG Debug.LogError(e.ToString()); #endif Clear(); result = GlobalPlayerLoaderResult.AirConfigError; return(false); } // 判断LUA bool isLua = false; try { if (m_PlayerConfig != null && m_PlayerConfig.Files != null && m_PlayerConfig.Files.HasLuaFile) { isLua = true; m_LuaConfig = new LuaCnsConfig(); if (!m_LuaConfig.LoadFromFile(m_PlayerConfig.Files.lua)) { result = (GlobalPlayerLoaderResult)((int)result | (int)GlobalPlayerLoaderResult.LUAConfigError); } } } catch (Exception e) { #if DEBUG Debug.LogError(e.ToString()); #endif result = (GlobalPlayerLoaderResult)((int)result | (int)GlobalPlayerLoaderResult.LUAConfigError); } //---------------------------- 加载Cmd if (!isLua) { try { if (m_PlayerConfig != null && m_PlayerConfig.Files != null) { string cmdName = m_PlayerConfig.Files.cmd; if (string.IsNullOrEmpty(cmdName)) { cmdName = playerName; } else { cmdName = GlobalConfigMgr.GetConfigFileNameNoExt(cmdName); } string fileName = string.Format("{0}@{1}/{2}.cmd.txt", AppConfig.GetInstance().PlayerRootDir, playerName, cmdName); m_CmdConfig = new CmdConfig(); if (!m_CmdConfig.LoadFromFile(fileName)) { result = GlobalPlayerLoaderResult.CmdConfigError; } } } catch (Exception e) { #if DEBUG Debug.LogError(e.ToString()); #endif result = GlobalPlayerLoaderResult.CmdConfigError; } } //--------------------------- 最后加载cns if (!isLua) { try { if (string.IsNullOrEmpty(cnsName)) { if (m_PlayerConfig == null || m_PlayerConfig.Files == null) { cnsName = playerName; } else { cnsName = m_PlayerConfig.Files.cns; cnsName = GlobalConfigMgr.GetConfigFileNameNoExt(cnsName); } } string fileName = string.Format("{0}@{1}/{2}.cns.txt", AppConfig.GetInstance().PlayerRootDir, playerName, cnsName); m_CNSConfig = new CNSConfig(); if (!m_CNSConfig.LoadFromFile(fileName)) { //Clear(); result = (GlobalPlayerLoaderResult)((int)result | (int)GlobalPlayerLoaderResult.CNSConfigError); //return false; } } catch (Exception e) { #if DEBUG Debug.LogError(e.ToString()); #endif //Clear (); result = (GlobalPlayerLoaderResult)((int)result | (int)GlobalPlayerLoaderResult.CNSConfigError); //return false; } } if (result == GlobalPlayerLoaderResult.None) { result = GlobalPlayerLoaderResult.Ok; } return(true); }