Пример #1
0
 public static void PlayerFxAudio(string name, float volume = 0.5f, bool isLoop = false)
 {
     ResMgr.GetInstance().LoadAsync <AudioClip>("Sound/" + name, (clip) =>
     {
         current.FXSource.loop   = isLoop;
         current.FXSource.volume = volume;
         current.FXSource.clip   = clip;
         current.FXSource.Play();
     });
 }
Пример #2
0
        static void Main()
        {
            LogMgr.init();
            ResMgr.getInstance().reload();
            ServiceMgr.getInstance().init();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Пример #3
0
 public void setForm(DataStatService.Form1 f)
 {
     m_form = f;
     if (m_form != null)
     {
         XmlConfig xml   = ResMgr.getInstance().getRes("dbserver.xml");
         string    mysql = xml.getString("mysql", "");
         m_form.setDbIP(DBMgr.getInstance().getIP(m_serverId), mysql);
     }
 }
Пример #4
0
    public void ShowPanel <T>(string panelName,
                              E_UI_Layer layer         = E_UI_Layer.Top,
                              UnityAction <T> callback = null) where T : BasePanel
    {
        //已经显示了此面板
        Debug.Log(panelName);
        if (panelDic.ContainsKey(panelName))
        {
            //Debug.Log(1111);
            //调用重写方法,具体内容自己添加
            panelDic[panelName].ShowMe();
            if (callback != null)
            {
                callback(panelDic[panelName] as T);
            }
            return;
        }
        ResMgr.GetInstance().LoadAsync <GameObject>("UI/" + panelName, (obj) => {
            //把它作为Canvas的子对象
            //并且设置它的相对位置
            //找到父对象
            Transform father = bot;
            switch (layer)
            {
            case E_UI_Layer.Mit:
                father = mid;
                break;

            case E_UI_Layer.Top:
                father = top;
                break;
            }
            //设置父对象
            obj.transform.SetParent(father);

            //设置相对位置和大小
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;

            (obj.transform as RectTransform).offsetMax = Vector2.zero;
            (obj.transform as RectTransform).offsetMin = Vector2.zero;

            //得到预设体身上的脚本(继承自BasePanel)
            T panel = obj.GetComponent <T>();
            panel.ShowMe();
            //执行外面想要做的事情
            if (callback != null)
            {
                callback(panel);
            }

            //在字典中添加此面板
            panelDic.Add(panelName, panel);
        });
    }
Пример #5
0
    /// <summary>
    /// 添加文件
    /// </summary>
    /// <param name="path"></param>
    /// <param name="groupName"></param>
    public static string AddAssetToGroup(string path, string groupName)
    {
        ResGroupCfg data = resInfo.GetGroupInfo(groupName);

        if (data == null)
        {
            return("");
        }

        string assetName = Path.GetFileNameWithoutExtension(path);

        if (!data.keys.Contains(assetName))
        {
            data.keys.Add(assetName);
            if (!resInfo.resources.Exists(a => a.name == assetName))
            {
                ResInfoData da = new ResInfoData();
                da.name           = assetName;
                da.path           = path.Replace("\\", "/");
                da.type           = Path.GetExtension(path);
                da.isFairyGuiPack = false;
                if (da.type == ".bytes")
                {
                    TextAsset text      = AssetDatabase.LoadAssetAtPath <TextAsset>(da.path);
                    byte []   descBytes = text.bytes;

                    if (ResMgr.ResIsFUIPack(descBytes))
                    {
                        da.isFairyGuiPack = true;
                    }
                }

                da.isKeepInMemory = true;

                da.isResourcesPath = da.path.Contains("Assets/Resources");
                if (da.isResourcesPath)
                {
                    string rootPath = da.path
                                      .Replace("Assets/Resources/", "");
                    rootPath  = Path.GetDirectoryName(rootPath);
                    da.ABName = rootPath;
                    //da.ABName = da.path.Replace(Application.dataPath + "/Resources")
                }
                else
                {
                    string rootPath = Path.GetDirectoryName(da.path);
                    rootPath  = rootPath.Substring(rootPath.LastIndexOf("/") + 1);
                    da.ABName = rootPath.ToLower();
                }
                resInfo.resources.Add(da);
            }
        }
        return(assetName);
    }
Пример #6
0
    public virtual void fight(short action, Creature attack, Creature target)
    {
        //	GameDebug.Log("fight:"+ID);

        GameObject bulletObj = ResMgr.getSingleton().getBullet();

        bulletObj.transform.position = this.transform.position;
        bullet b = bulletObj.GetComponent <bullet>();

        b.Init(attack, target, (int)action);
    }
Пример #7
0
        static int LoadObject_Lua(IntPtr L)
        {
            var obj = ResMgr.Load(Api.lua_tostring(L, 1));

            if (obj == null)
            {
                return(0);
            }
            lua.Lua.PushObjectInternal(L, obj);
            return(1);
        }
Пример #8
0
        static int Load_Lua(IntPtr L)
        {
            var obj = ResMgr.Load(Api.lua_tostring(L, 1), (System.Type)lua.Lua.ObjectAtInternal(L, 2));

            if (obj == null)
            {
                return(0);
            }
            lua.Lua.PushObjectInternal(L, obj);
            return(1);
        }
Пример #9
0
        static int LoadCustomObject_Lua(IntPtr L)
        {
            var obj = ResMgr.LoadCustomObject(Api.lua_chkstring(L, 1), Api.lua_chkstring(L, 2));

            if (obj == null)
            {
                return(0);
            }
            Lua.PushObjectInternal(L, obj);
            return(1);
        }
Пример #10
0
        static int LoadSprite_Lua(IntPtr L)
        {
            var sprite = ResMgr.Load <Sprite>(Api.lua_tostring(L, 1));

            if (sprite == null)
            {
                return(0);
            }
            lua.Lua.PushObjectInternal(L, sprite);
            return(1);
        }
Пример #11
0
        static int LoadTexture2D_Lua(IntPtr L)
        {
            var tex = ResMgr.Load <Texture2D>(Api.lua_tostring(L, 1));

            if (tex == null)
            {
                return(0);
            }
            lua.Lua.PushObjectInternal(L, tex);
            return(1);
        }
Пример #12
0
 protected virtual void OnInitSkin()
 {
     if (!string.IsNullOrEmpty(mainSkinPath))
     {
         _skin = ResMgr.GetInstance().CreateGameObject(mainSkinPath, false);
     }
     _skin.transform.parent           = this.transform;
     _skin.transform.localEulerAngles = Vector3.zero;
     _skin.transform.localPosition    = Vector3.zero;
     _skin.transform.localScale       = Vector3.one;
 }
Пример #13
0
 public override bool IsDone()
 {
     // 如果有依赖,要先判断依赖是否已经加载完成
     if (this.dependences != null)
     {
         for (int i = 0; i < this.dependences.Length; ++i)
         {
             if (!ResMgr.Instance().IsLoadedAssetBundle(this.dependences[i]))
             {
                 return(false);
             }
         }
     }
     // 判断自己是否加载完成
     if (base.LoadDoneCallback == null)
     {
         // 依赖资源,不需要LoadDone回调
         if (this.assetbundle != null)
         {
             return(true);
         }
         if (this.www.isDone)
         {
             this.assetbundle = this.www.assetBundle;
             this.www.Dispose();
             this.www = null;
             return(true);
         }
         return(false);
     }
     else
     {
         // 直接资源,需要LoadDone回调,所以需要从AssetBundle中提取资源对象
         if (this.assetbundleReq != null)
         {
             // 只有从assetbundle中提取出最终的资源对象,才算加载完成,保证所有的IO操作都是异步的
             return(this.assetbundleReq.isDone);
         }
         else
         {
             if (this.www.isDone)
             {
                 this.assetbundle = this.www.assetBundle;
                 // 从assetbundle中提取资源对象
                 string resPath = string.Format(ResMgr.AssetBundleFormation, base.ResName);
                 this.assetbundleReq = this.assetbundle.LoadAssetAsync(resPath);
                 this.www.Dispose();
                 this.www = null;
             }
             return(false);
         }
     }
 }
Пример #14
0
    byte[] customLoader(ref string fileName)
    {
        fileName = "lua/" + fileName.Replace('.', '/') + ".lua.txt";
#if UNITY_EDITOR
        fileName = SysDefine.PATH_ASSETBUNDLE_LOCAL + "/" + fileName;
        if (File.Exists(fileName))
        {
            return(File.ReadAllBytes(fileName.ToLower()));
        }
#endif
        return(ResMgr.GetLua(fileName).bytes);
    }
        // 动态生成菜单
        private void genMenu()
        {
            Dictionary <string, DbServerInfo> db = ResMgr.getInstance().getAllDb();

            foreach (DbServerInfo info in db.Values)
            {
                MenuItem item = new MenuItem();
                item.Text        = info.m_serverName;
                item.NavigateUrl = "/appaspx/SelectMachine.aspx?db=" + info.m_serverIp;
                NavigationMenu.Items.Add(item);
            }
        }
Пример #16
0
    /// <summary>
    /// 异步清理场景资源
    /// </summary>
    /// <returns></returns>
    IEnumerator CleanScene()
    {
        ResMgr.Instance().Unload();
        this.curLogicResObjDict.Clear();
        this.curLogicResObjDict = null;
        Debug.LogWarning("Unload in SceneMgr");
        AsyncOperation req = Resources.UnloadUnusedAssets();

        yield return(req);

        System.GC.Collect();
    }
Пример #17
0
 public virtual void CheckDependences()
 {
     this.dependences = ResMgr.Instance().GetDependences(base.SceneName);
     for (int i = 0; i < this.dependences.Length; ++i)
     {
         string dependence = this.dependences[i];
         if (!ResMgr.Instance().IsLoadedAssetBundle(dependence))
         {
             ResMgr.Instance().LoadRes(dependence);
         }
     }
 }
Пример #18
0
    public void AsyncLoad(string path, Action <AssetBundle> callback, bool isdepend = false)
    {
        if (m_manifest == null)
        {
            ResMgr.Log(Tag, "AsyncLoad", "manifest is null");
            return;
        }
        string abname;

        if (isdepend)
        {
            abname = path;
        }
        else
        {
            abname = XGamePath.Path2ResName(path);
        }
        int hash = abname.GetHashCode();
        AbAbstractLoader loader = null;

        if (m_Ab_Dic.TryGetValue(hash, out loader))
        {
            if (callback != null)
            {
                callback(loader.Bundle);
            }
            return;
        }

        string[] depends = AbMgr.GetInstance().GetDepends(abname);
        for (int i = 0; i < depends.Length; i++)
        {
            ResMgr.Log(Tag, "AsyncLoad|depends", depends[i]);
            int hash2 = depends[i].GetHashCode();
            AbAbstractLoader loader2 = null;
            if (m_Ab_Dic.TryGetValue(hash2, out loader2))
            {
                continue;
            }
            if (m_loading_Dic.ContainsKey(hash2))
            {
                AbAsyncLoader asyncloader = m_loading_Dic[hash2] as AbAsyncLoader;
                asyncloader.request.priority++;
                continue;
            }
            AbMgr.GetInstance().AsyncLoad(depends[i], null, true);
        }

        loader = new AbAsyncLoader(path, abname, callback);
        path   = XGamePath.GetStreamingAbPath(abname);
        loader.LoadAsset(path);
        m_loading_Dic.Add(hash, loader as AbAsyncLoader);
    }
Пример #19
0
        static int LoadObjects_Lua(IntPtr L)
        {
            var objs = ResMgr.LoadAll(Api.lua_tostring(L, 1));

            Api.lua_createtable(L, objs.Length, 0);
            for (int i = 0; i < objs.Length; ++i)
            {
                lua.Lua.PushObjectInternal(L, objs[i]);
                Api.lua_seti(L, -2, i);
            }
            return(1);
        }
Пример #20
0
    void Start()
    {
        GameObject pwarp = ResMgr.GetPrefab("ui/common/UIWarp.prefab");
        GameObject warp  = GameObject.Instantiate(pwarp);

        warp.transform.SetParent(parent, false);
        GameObject pgrid = ResMgr.GetPrefab("ui/bag/UIBagGrid.prefab");

        GameObject grid = GameObject.Instantiate(pgrid);

        grid.transform.SetParent(warp.transform, false);
    }
Пример #21
0
    public void LoadUIAsync(int uiid, Action callback)
    {
        string str = UIUtil.GetUITypeName(uiid);

        if (string.IsNullOrEmpty(str))
        {
            ResMgr.LogError(Tag, "LoadUIAsync", "UIMgr uiid not exist ==>" + uiid); return;
        }
        sb.Clear();
        sb.Append(string.Format(m_UIPath, str));
        ResMgr.LoadGobjAsync(sb.ToString(), callback);
    }
Пример #22
0
    private GameObject LoadUI(int uiid)
    {
        string str = UIUtil.GetUITypeName(uiid);

        if (string.IsNullOrEmpty(str))
        {
            return(null);
        }
        sb.Clear();
        sb.Append(string.Format(m_UIPath, str));
        return(ResMgr.LoadGameObject(sb.ToString()));
    }
Пример #23
0
        private void Start()
        {
            ResMgr.Init();

            mResLoader.LoadSync <GameObject>("Resources/GameObject")
            .Instantiate()
            .Name("这是使用ResKit加载的对象");

            mResLoader.LoadSync <GameObject>("AssetObj")
            .Instantiate()
            .Name("这是使用通过 AssetName 加载的对象");
        }
Пример #24
0
 static public int Unload(IntPtr l)
 {
     try {
         ResMgr self = (ResMgr)checkSelf(l);
         self.Unload();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #25
0
        // 游戏逻辑初始化
        public void AppInit(GameObject goMain, NBsn.MMain Main)
        {
            Log.Info("NBsn.CGlobal.AppInit()");

            m_goMain = goMain;
            m_Main   = Main;
            m_tfMain = m_goMain.transform;

            Coroutine.Init(m_Main);
            ResMgr.Init();
            UIMgr.Init(m_tfMain.Find("UI"));
        }
Пример #26
0
    //显示面板
    //面板名  面板层级 面板回调函数
    public void ShowPanel <T>(string panelName, UILayer layer = UILayer.Mid, UnityAction <T> callBack = null) where T : BasePanel
    {
        if (panelDic.ContainsKey(panelName))
        {
            panelDic[panelName].ShowThis();
            if (callBack != null)
            {
                callBack(panelDic[panelName] as T);
            }
        }

        ResMgr.GetInstance().LoadAsync <GameObject>("UI/" + panelName, (obj) =>
        {
            //加载完后需要做的事
            //找到父对象显示层级
            Transform father = bot;
            switch (layer)
            {
            case UILayer.Bot:
                father = bot;
                break;

            case UILayer.Mid:
                father = mid;
                break;

            case UILayer.System:
                father = system;
                break;

            case UILayer.Top:
                father = top;
                break;
            }
            //设置相对位置大小 和父对象
            obj.transform.SetParent(father);

            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            (obj.transform as RectTransform).offsetMax = Vector2.zero;

            //得到预设体的面板脚本
            T panel = obj.GetComponent <T>();
            //处理面板创建后的逻辑
            if (callBack != null)
            {
                callBack(panel);
            }

            panel.ShowThis();
            panelDic.Add(panelName, panel);
        });
    }
Пример #27
0
        public void AppUnInit()
        {
            Log.Info("NBsn.CGlobal.AppUnInit()");

            UIMgr.UnInit();
            ResMgr.UnInit();
            Coroutine.UnInit();

            m_tfMain = null;
            m_Main   = null;
            m_goMain = null;
        }
Пример #28
0
 public void Init()
 {
     ResMgr.Init();
     //初始化所有的 enemy 预制体
     foreach (var monster in GlobalManager.Instance.GameDevSetting.dic_monster_path)
     {
         if (!dic_name_enemyGO.ContainsKey(monster.Key))
         {
             dic_name_enemyGO[monster.Key] = mEnemyLoader.LoadSync <GameObject>(monster.Value);
         }
     }
 }
Пример #29
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         PoolMgr.GetInstance().GetObj("Cube", (o) => { o.transform.position = new Vector3(2, 2, 2); o.AddComponent <PoolPush>(); });
     }
     if (Input.GetMouseButtonDown(1))
     {
         ResMgr.GetInstance().LoadAsync <GameObject>("Cube", o => { o.name = "张鹏笨蛋"; });
         ResMgr.GetInstance().Load <GameObject>("Cube").gameObject.name = "王鹏笨蛋";
     }
 }
Пример #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RightMgr.getInstance().opCheck("service", Session, Response);
            m_res.InnerHtml = "";
            if (IsPostBack)
            {
                m_gen.m_way = m_queryWay.SelectedIndex;
            }
            else
            {
                m_queryWay.Items.Add("通过玩家id查询");
                m_queryWay.Items.Add("通过账号查询");
                m_queryWay.Items.Add("通过订单号查询");

                m_platform.Items.Add("###");
                for (int i = (int)PaymentType.e_pt_none + 1; i < (int)PaymentType.e_pt_max; i++)
                {
                    PlatformInfo data = ResMgr.getInstance().getPlatformInfo(i);
                    if (data == null)
                    {
                        m_platform.Items.Add("###");
                    }
                    else
                    {
                        m_platform.Items.Add(data.m_chaName);
                    }
                }

                /* m_gameServer.Items.Add("全部");
                 * Dictionary<string, DbServerInfo> db = ResMgr.getInstance().getAllDb();
                 * foreach (DbServerInfo info in db.Values)
                 * {
                 *   m_gameServer.Items.Add(new ListItem(info.m_serverName, info.m_serverId.ToString()));
                 * }*/

                m_rechargeResult.Items.Add("全部");
                m_rechargeResult.Items.Add("成功");
                m_rechargeResult.Items.Add("失败");

                if (m_gen.parse(Request))
                {
                    m_queryWay.SelectedIndex = m_gen.m_way;
                    m_param.Text             = m_gen.m_param;
                    m_time.Text = m_gen.m_time;
                    m_platform.SelectedIndex       = m_gen.m_platIndex;
                    m_rechargeResult.SelectedIndex = m_gen.m_result;
                    m_range.Text = m_gen.m_range;
                    //  m_gameServer.SelectedIndex = m_gen.m_serverIndex;
                    onQueryRecharge(null, null);
                }
            }
        }
Пример #31
0
 void Awake()
 {
     mInstance = this;
 }
Пример #32
0
 public static void DestroyInstance()
 {
     Instance = null;
 }
Пример #33
0
 // Awake is called when the script instance is being loaded.
 void Awake()
 {
     mInstance = this;
     DontDestroyOnLoad(this.gameObject);
     AttachEventListener(EventDef.ResLoadFinish, this);
     mProcessorCount = SystemInfo.processorCount > 0 && SystemInfo.processorCount <= 8 ? SystemInfo.processorCount : 1;
 }
Пример #34
0
 public static void CreateInstance()
 {
     Instance = new ResMgr();
 }