Esempio n. 1
0
    void Update()
    {
        if (loading.Count > 0)
        {
            ArrayList keys = new ArrayList(loading.Keys);
            foreach (var k in keys)
            {
                string       key   = k as string;
                CGameUIAsset asset = loading[key] as CGameUIAsset;
                if (asset != null)
                {
                    asset.Update();
                }
            }
        }

        for (int i = 0; i < uis.Length; ++i)
        {
            if (uis[i] == null)
            {
                continue;
            }
            if (uis[i].asset != null)
            {
                uis[i].asset.Update();
            }
        }
    }
Esempio n. 2
0
    public void Remove(CGameUI ui)
    {
        if (!ui || ui.disposed)
        {
            return;
        }
        if (ui.index < 0)
        {
            return;
        }
        uis[ui.index] = null;
        ui.Close();
        names.Remove(ui.Name);
        index_pool.Free(ui.index);
        ui.index = -1;

        if (loading.ContainsKey(ui.Name))
        {
            CGameUIAsset asset = loading[ui.Name] as CGameUIAsset;
            CClientCommon.DestroyImmediate(ref asset);
            loading.Remove(ui.Name);
        }
        ui.Dispose();
        ui = null;
    }
Esempio n. 3
0
    public void Clear(bool reconnectToServer = false)
    {
        for (int i = 0; i < uis.Length; ++i)
        {
            if (uis[i] != null)
            {
                if (!uis[i].dontDestoryOnLoad)
                {
                    Remove(uis[i]);
                }
                else
                {
                    if (!reconnectToServer)
                    {
                        uis[i].OnLoadLevelBegin();
                    }
                }
            }
        }

        ArrayList keys = new ArrayList(loading.Keys);

        foreach (var k in keys)
        {
            string       key   = k as string;
            CGameUIAsset asset = loading[key];
            if (asset != null && !asset.dontDestoryOnLoad)
            {
                CClientCommon.DestroyImmediate(ref asset);
            }

            loading.Remove(key);
        }
    }
Esempio n. 4
0
 public void SetAsset(CGameUIAsset asset)
 {
     this.asset = asset;
     if (this.asset != null)
     {
         this.asset.dontDestoryOnLoad = _dontDestoryOnLoad;
     }
 }
Esempio n. 5
0
 public void UIDispose()
 {
     for (int i = 0; i < uis.Length; ++i)
     {
         if (uis[i] != null)
         {
             Remove(uis[i]);
         }
     }
     names.Clear();
     foreach (var e in loading.Values)
     {
         CGameUIAsset asset = e as CGameUIAsset;
         CClientCommon.DestroyImmediate(ref asset);
     }
     loading.Clear();
 }
Esempio n. 6
0
    public void LoadUI(Type ui_type, object context = null, bool needwait = false)
    {
        if (ui_type == null || !ui_type.IsSubclassOf(typeof(CGameUI)))
        {
            return;
        }
        string  ui_name = rg.Match(ui_type.Name).Value;
        CGameUI exists  = Global.ui_mgr.Get(ui_name) as CGameUI;

        if (exists != null)
        {
            exists.context = context;//在界面还没有show前赋值所传的参数列表
            if (!exists.IsShow())
            {
                exists.Show();
            }
            exists.LoadUICallback();
            return;
        }
        // 防止重复加载
        if (IsLoading(ui_name))
        {
            return;
        }
        CGameUIAsset asset = CResourceFactory.CreateInstance <CGameUIAsset>(string.Format("res/ui/uiprefab/{0}.ui", ui_name).ToLower(), null);

        AddLoading(ui_name, asset);

        asset.RegisterCompleteCallback(delegate(CGameUIAsset e)
        {
            CGameUI ui = e.gameObject.AddComponent(ui_type) as CGameUI;
            ui.SetName(ui_name);
            ui.SetAsset(e);
            ui.context = context;
            Global.ui_mgr.Add(ui);
            ui.LoadUICallback();
            RemoveLoading(ui_name);
        });
    }
Esempio n. 7
0
 private void AddLoading(string name, CGameUIAsset asset)
 {
     loading.Add(name, asset);
 }