/// <summary> /// 资源卸载 /// </summary> public override void Clear() { WndManager.DestroyAllWnd(); ResourceManger.ClearScenePools(); BattleM.Clear(); AntiRegisterHooks(); }
/// <summary> /// 根据地图数据加载地图 /// </summary> /// <param name="map"></param> public void LoadMap2Ball(GolfCourseMap map) { if (map == null) { return; } ResourceManger.LoadMap("GolfMap", transform, false, false, (g) => { if (g != null) { GolfRuler ruler = g.AddComponent <GolfRuler>(); ruler.SetAABB(map.AA2, map.BB2); } }); ResourceManger.LoadBall("GolfBall", transform, false, false, (ballGo) => { if (ballGo != null) { GolfBall ball = ballGo.GetComponent <GolfBall>(); if (ball == null) { ball = ballGo.AddComponent <GolfBall>(); } if (ball != null) { ball.SetBallPos(map.StartPos); } } }); }
/// <summary> /// 播放指定循环音效 /// </summary> /// <param name="voiceID">对应着game_voice表</param> public static void PlayloopVoice(uint voiceID) { GameVoiceConfig c = GameVoiceDao.Inst.GetCfg(voiceID); if (c != null) { ResourceManger.LoadVoice(c.VoiceName, false, (g) => { if (g != null) { if (g_SoundNode != null) { g_SoundNode.PlayLoopVoice(voiceID, g as AudioClip); } } else { Logging.Logger.LogDebug("voiceID:" + voiceID + "对应的音乐不存在"); } }); } else { Logging.Logger.LogDebug("voiceID:" + voiceID + "数据不存在"); } }
void OnApplicationQuit() { if (allowQuit) { return; } ResourceManger.Clear(); ModuleMgr.ClearAllModuleDC(); EventCenter.Free(); Application.Quit(); }
private TConfig[] LoadCfg() { //BaseCfgData<TConfig> cfgData = Resources.Load<BaseCfgData<TConfig>>("Config/" + GetName()); BaseCfgData <TConfig> cfgData = ResourceManger.LoadConfig(GetName()) as BaseCfgData <TConfig>; if (cfgData == null) { return(null); } return(cfgData.Data); }
private void InitResManger() { AssetLoad l = null; #if UNITY_EDITOR l = new AssetLoadEditor(); #else l = new AssetLoadRun(); #endif ResourceManger.SetLoadObj(this, l); ResourceManger.InitCache(); }
/// <summary> /// 显示tips /// </summary> /// <param name="msg">tip 内容</param> /// <param name="title">tip 标题</param> /// <param name="tipRect">弹出tips 的对象</param> /// <param name="align">对其方式</param> /// <param name="offset">修正偏移值</param> /// <returns></returns> public static bool ShowTips(string msg, string title, RectTransform tipRect, TipAlignment align, Vector2 offset) { ResourceManger.LoadWndItem("HintItem", (WndManager.GetUINode() as UINode).GetWndParent(WndType.DialogWnd), false, (obj) => { HintItem item = obj.GetComponent <HintItem>(); if (item != null) { item.SetData(new object[] { msg, title, tipRect, align, offset }); } }); return(true); }
// <summary> // 销毁窗口(下一帧) // </summary> public void DestroyWnd(float destroyTime = 0.0f) { if (destroyTime == 0.0f) { ResourceManger.FreeGo(gameObject); } else { PlayCloseAni(); StartCoroutine(FreeWndRes(destroyTime)); } }
/// <summary> /// 播放音乐 /// </summary> /// <param name="MusicID">对应着game_music表</param> /// <param name="volumeScale">默认0.0,使用系统设置音</param> /// <param name="ChangeStype">切换方式</param> /// <param name="isLoop">是否循环</param> public static void PlayMusic(uint MusicID, float volumeScale = 0.0f, PlayChangeType ChangeStype = PlayChangeType.Fade, bool isLoop = true) { if (g_curPlayMusicID == MusicID) { return; } GameMusicConfig c = GameMusicDao.Inst.GetCfg(MusicID); if (c != null) { volumeScale = c.Volume / 100f; ResourceManger.LoadMusic(c.MusicName, false, (g) => { if (g != null) { if (g_SoundNode != null) { if (ChangeStype == PlayChangeType.Fade) { if (GameMusicDao.Inst.GetCfg(g_curPlayMusicID) == null) { g_SoundNode.PlayMusicFadeOutIn(g as AudioClip, GetFadeinTime(), volumeScale, isLoop); } else { g_SoundNode.PlayMusicFadeOutIn(g as AudioClip, GetFadeOutTime(), GetFadeinTime(), volumeScale, isLoop); } } else { g_SoundNode.PlayMusicFlash(g as AudioClip, GetSwitchTime(), volumeScale, isLoop); } if (isLoop == true) { g_curPlayMusicID = MusicID; } } } else { Logging.Logger.LogDebug("MusicID:" + MusicID + "对应的音乐不存在"); } }); } else { Logging.Logger.LogDebug("MusicID:" + MusicID + "数据不存在"); } }
private void LoadDependeAB() { ReadABResourceInfo(); foreach (ABResourceUnit unit in m_abResource.listABUnit) { if (unit.ABdir == ResourcesPath.GetRelativePath(ResourcesType.Shader, ResourcesPathMode.AssetBundle) ) { foreach (ABFileUnitInfo ABfileUnit in unit.listAb) { ResourceManger.LoadDependeAB(unit.ABdir, ABfileUnit.ABfileName); } } } Shader.WarmupAllShaders(); }
static void Main(string[] args) { if (args.Contains("sfml")) { _engine = new ConsoleEngine.ConsoleEngine(WIDTH, HEIGHT, 24, TITLE);//Init engine what you want ResourceManger.LoadResourcesForConsoleEngine(_engine.Resources); } else { _engine = new SFMLEngine.SFMLEngine(WIDTH, HEIGHT, 25, TITLE); ResourceManger.LoadResourcesForSfmlEngine(_engine.Resources); } _engine.SetBackgroundColor(Color.White); var menu = new MenuArea(_engine.GameGrid); //Create area _engine.LoadArea(menu); //Load area _engine.Run(); //Run game }
/// <summary> /// 设置绑定icon /// </summary> /// <param name="img">img对象</param> /// <param name="altas">icon所在的图集</param> /// <param name="spriteName">icon sprite 名称</param> protected void SetImage(Image img, string altas, string spriteName) { if (img != null) { ResourceManger.LoadSprite(altas, spriteName, false, (g) => { if (null != g) { Sprite sprite = g as Sprite; if (null != sprite) { img.sprite = sprite; } } else { img.sprite = null; } }); } }
//如果不是特别“重”的常用窗口,尽量IsCache = false, 后台会帮你保留 public static bool CreateWnd <T>(WndType wndtype, bool IsCache, bool async, WndCreateHook pfun) where T : WndBase { bool ret = false; string WndName = typeof(T).ToString(); Transform parent = WndManager.GetWndParent(wndtype); // 已经存在 T wnd = FindWnd <T>(); if (wnd != null) { SetWndTop(wnd); //show the wnd wnd.ShowWnd(true); if (pfun != null) { pfun(wnd); } return(true); } // 不存在则创建了。 ResourceManger.LoadWnd(WndName, parent, IsCache, async, (g) => { if (g != null) { wnd = g.GetComponent <T> (); wnd.SetWndType(wndtype); AddWnd(wnd); if (pfun != null) { pfun(wnd); } ret = true; } }); return(ret); }
/// <summary> /// 预加载的加载接口 /// </summary> /// <param name="ResType"></param> /// <param name="ResName"></param> /// <param name="Count"></param> public static IEnumerator LoadGoCahce(string ResType, string ResName, int Count) { //包含此对象池,且有对象 CacheItems v = PoolManager.GetCacheItem(ResType, ResName); if (v.Count > 0) { yield return(v.CopyInstantiate(Count)); } else { // 为同步操作 GameObject prefab = null; ResourceManger.LoadPrefab(ResType, ResName, false, true, (g) => { prefab = g as GameObject; }); // 执行分帧加载。 if (prefab != null) { yield return(Yielders.EndOfFrame); GameObject go = GameObject.Instantiate(prefab); // 设置父亲结点 if (null != go) { CacheItem recycle = go.GetComponent <CacheItem>(); if (recycle == null) { recycle = go.AddComponent <CacheItem>(); } recycle.SetCacheKey(ResType, ResName); v.SetCacheData(recycle); yield return(Yielders.EndOfFrame); yield return(v.CopyInstantiate(Count)); } } } }
public T CreateItem <T>(int index, T item) where T : WndItem { UIMultiScrollIndex itemBase; if (_unUsedQueue.Count > 0) { itemBase = _unUsedQueue.Dequeue(); item = itemBase.GetComponent <T>(); } else { ResourceManger.LoadWndItem(typeof(T).ToString(), _content, false, (g) => { if (g != null) { item = g.GetComponent <T>(); } }); itemBase = item.GetComponent <UIMultiScrollIndex>(); } itemBase.Scroller = this; itemBase.Index = index; if (m_Fly) { itemBase.SetFlyIndex(maxPerLine, viewCount - 1, _movement); } DealFly(); _itemList.Add(itemBase); // 通知修改数据 OnSetItemData(index, itemBase.gameObject); return(item); }
private void Init() { if (m_IsInit == false) { if (GrayMat == null) { if (m_matKey == "") { Shader s = ResourceManger.LoadShader("UI/UIGrayScale"); if (s != null) { GrayMat = new Material(s); } } else { GrayMat = ShareMaterialM.GetMaterial(m_matKey); if (GrayMat == null) { Shader s = ResourceManger.LoadShader("UI/UIGrayScale"); if (s != null) { GrayMat = new Material(s); } ShareMaterialM.AddMaterial(m_matKey, GrayMat); } } } img = gameObject.GetComponent <Image>(); if (null != img) { MatImg = img.material == null ? null : img.material; } m_IsInit = true; } }
public void OnDrag(PointerEventData eventData) { m_isDrag = true; m_dragGolfPos = m_golf.transform.position; if (m_golf != null && m_GolfboxOut != null && m_uiCamera != null) { if (m_cloneBall == null) { ResourceManger.LoadWndItem("Btn_ballItem", m_golf.gameObject.transform, false, (obj) => { if (null == obj) { return; } m_cloneBall = obj; obj.transform.SetParent(m_golf.transform.parent); obj.transform.position = m_golfPos; obj.transform.localScale = new Vector3(1, 1, 1); }); } else { m_cloneBall.SetActive(true); } Vector3 globalMousePos; Vector3 mousePos; float z; // if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_GolfboxOut.GetComponentInParent <RectTransform>(), new Vector2(Input.mousePosition.x, Input.mousePosition.y), m_uiCamera, out mousePos)) { if (mousePos.x > m_GolfboxOut.GetComponent <RectTransform>().position.x) { z = Vector3.Angle(Vector3.down, m_golfPos - mousePos) - 180; } else { z = 180 - Vector3.Angle(Vector3.down, m_golfPos - mousePos); } //球跟随鼠标 if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_golf.GetComponent <RectTransform>(), Input.mousePosition, m_uiCamera, out globalMousePos)) { Vector3 compare = Vector3.zero; if (z < m_limitAngle && z > -m_limitAngle) { m_golf.GetComponent <RectTransform>().position = globalMousePos; } else { if (globalMousePos.y < m_golfPos.y) { if (m_limitAngle < 90) { m_moveGolfDis = Vector3.Distance(new Vector3(m_golfPos.x, globalMousePos.y, m_golfPos.z), m_golfPos) * Mathf.Tan(m_limitAngle * Mathf.Deg2Rad); if (compare != globalMousePos) { if (globalMousePos.x > m_golfPos.x) { m_golf.GetComponent <RectTransform>().position = new Vector3(m_golfPos.x + m_moveGolfDis, globalMousePos.y, globalMousePos.z); } else { m_golf.GetComponent <RectTransform>().position = new Vector3(m_golfPos.x - m_moveGolfDis, globalMousePos.y, globalMousePos.z); } } } } } compare = globalMousePos; } float dragDis = Vector3.Distance(new Vector3(m_golfPos.x, m_dragGolfPos.y, m_golfPos.z), m_golfPos) / m_disGolfBox; m_dragPower = dragDis; float num = ((m_disGolfBox - Vector3.Distance(new Vector3(m_golfPos.x, m_dragGolfPos.y, m_golfPos.z), m_GolfboxOut.transform.position)) / m_disGolfBox); float dis = CheckDis(num) ? 1 : num; Vector3 golfStraight = new Vector3(m_golfPos.x, m_dragGolfPos.y, m_golfPos.z); if (Vector3.Distance(golfStraight, m_golfPos) <= m_disGolfBox) { m_imgGolfOut.color = new Color(m_imgGolfOut.color.r, m_imgGolfOut.color.g, m_imgGolfOut.color.b, dis); m_imgGolfIn.color = new Color(m_imgGolfIn.color.r, m_imgGolfIn.color.g, m_imgGolfIn.color.b, dis); } else { m_imgGolfOut.color = new Color((133 + 122 * (1 - dis)) / 255, (250 - 60 * (1 - dis)) / 255, (239 - 239 * (1 - dis)) / 255, 1); m_imgGolfIn.color = new Color((133 + 122 * (1 - dis)) / 255, (250 - 60 * (1 - dis)) / 255, (239 - 239 * (1 - dis)) / 255, 1); } m_greenAngle = Mathf.Clamp(z, -m_limitAngle, m_limitAngle); m_ballAngle = Mathf.Clamp(CheckAngle(z), -m_limitAngle, m_limitAngle); m_GolfboxOut.transform.localRotation = Quaternion.Euler(0, 0, m_ballAngle); m_GolfboxIn.transform.localRotation = Quaternion.Euler(0, 0, m_ballAngle); if (BattleM.BallInAra == AreaType.PuttingGreen) { m_arrowGreenMoveBox.transform.eulerAngles = new Vector3(0, 0, -m_greenAngle); } } BoxScale(); } }
void Awake() { ResourceManger.LoadTextAsset("Assets.XLua.MyLua.Resources.GameManger.lua.txt", InitLua); }
private void OnEnable() { StartCoroutine(DelayAction(DelayTime, () => { ResourceManger.FreeGo(this.gameObject); })); }
/// <summary> /// 资源卸载 /// </summary> public override void Clear() { WndManager.DestroyAllWnd(); ResourceManger.ClearScenePools(); }
public void Init() { ResourceManger.LoadTextAsset("Assets.XLua.MyLua.Resources.GameManger.lua.txt", InitLua); Debug.Log("Create Battle"); }
private IEnumerator FreeWndRes(float destroyTime) { yield return(Yielders.GetWaitForSeconds(destroyTime)); ResourceManger.FreeGo(gameObject); }