示例#1
0
    public static ConfigHelper LoadConfig(TextAsset asset)
    {
        ConfigHelper config = new ConfigHelper();

        try
        {
            XmlTextReader xr = new XmlTextReader(new StringReader(asset.text));
            while (xr.Read())
            {
                if (xr.NodeType == XmlNodeType.Element)
                {
                    if (xr.Name == "game")
                    {
                        config.debug = bool.Parse(xr.GetAttribute("debug"));
                    }
                }
            }
            xr.Close();
        }
        catch (Exception ex)
        {
            LOG.LogError("[ConfigHelper] load fail." + ex.Message);
        }

        return(config);
    }
示例#2
0
    private IEnumerator LoadLevelBundle(string scene)
    {
        WWW www = new WWW(CDirectory.MakeFullWWWPath(string.Format("res/scenes/{0}.scene", scene)));

        while (!www.isDone)
        {
            progress = www.progress;
            yield return(null);
        }
        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            LOG.LogError("WWW download:" + www.error + "  path :  " + www.url);
            yield break;
        }
        if (www.isDone)
        {
            wwwProgress.Done();
            isDone  = true;
            SceneAB = www.assetBundle;
            www.Dispose();
            if (AutoLoadScene)
            {
                CSceneManager.LoadSceneAsync(this.SceneName);
            }
        }
    }
示例#3
0
 protected override void OnAwake()
 {
     _peerTable = CGame.luamgr.Global.CreateWindow(WindowName, this);
     if (_peerTable == null)
     {
         LOG.LogError("lua is no registry window.name=" + WindowName);
         return;
     }
     _OnLoaded                = _peerTable.Get <string, LuaFunction>("_OnLoaded");
     _OnPrepared              = _peerTable.Get <string, LuaFunction>("_OnPrepared");
     _OnInitialized           = _peerTable.Get <string, LuaFunction>("_OnInitialized");
     _OnCommand               = _peerTable.Get <string, LuaFunction>("_OnCommand");
     _OnRefresh               = _peerTable.Get <string, LuaFunction>("_OnRefresh");
     _OnPreShow               = _peerTable.Get <string, LuaFunction>("_OnPreShow");
     _OnPostShow              = _peerTable.Get <string, LuaFunction>("_OnPostShow");
     _OnUpdate                = _peerTable.Get <string, LuaFunction>("_OnUpdate");
     _OnLateUpdate            = _peerTable.Get <string, LuaFunction>("_OnLateUpdate");
     _OnPreHide               = _peerTable.Get <string, LuaFunction>("_OnPreHide");
     _OnPostHide              = _peerTable.Get <string, LuaFunction>("_OnPostHide");
     _OnShutdown              = _peerTable.Get <string, LuaFunction>("_OnShutdown");
     _OnRequestHide           = _peerTable.Get <string, LuaFunction>("_OnRequestHide");
     _OnRequestShow           = _peerTable.Get <string, LuaFunction>("_OnRequestShow");
     _OnRequestHideByRollback = _peerTable.Get <string, LuaFunction>("_OnRequestHideByRollback");
     _OnRequestShowByRollback = _peerTable.Get <string, LuaFunction>("_OnRequestShowByRollback");
 }
示例#4
0
        public void Update()
        {
            if (loading.Count > 0)
            {
                int       n    = 0;
                ArrayList list = new ArrayList(loading.Values);
                foreach (IRenderResource resource in list)
                {
                    if (!resource.loading)
                    {
                        ++n;
                        resource.Load();
                    }
                    if (resource.WWW == null || resource.WWW.isDone)
                    {
                        if (complete.ContainsKey(resource.name))
                        {
                            LOG.LogError("【IResourceFactory】加载资源出错 " + resource.name);
                            break;
                        }
                        complete_list.Add(resource.name);
                        complete[resource.name] = resource;
                        resource.Create();
                        break;
                    }

                    if (n == 3)
                    {
                        break;
                    }
                }

                for (int i = 0; i < complete_list.Count; ++i)
                {
                    loading.Remove(complete_list[i]);
                }
                complete_list.Clear();
            }

            float time = Time.realtimeSinceStartup;

            // 处理掉逗留时间过长的资源
            foreach (IRenderResource resource in idle.Values)
            {
                if (time < resource.idle_time + linger_time)
                {
                    continue;
                }
                resource.Destroy();
                complete_list.Add(resource.name);
            }
            for (int i = 0; i < complete_list.Count; ++i)
            {
                idle.Remove(complete_list[i]);
            }
            complete_list.Clear();
        }
示例#5
0
 public void ReInit()
 {
     if (m_TargetActionTween != null)
     {
         TryReInitActionTweenIfNeed();
     }
     else
     {
         LOG.LogError("ActionTween Must Statr ");
     }
 }
示例#6
0
 public void Kill()
 {
     if (m_TargetActionTween != null)
     {
         m_TargetActionTween.Kill();
     }
     else
     {
         LOG.LogError("ActionTween Must Statr ");
     }
 }
示例#7
0
        public void Destroy()
        {
            if (destroy)
            {
                return;
            }

            try {
                if (children != null)
                {
                    for (PListNode n = children.next, next; n != children; n = next)
                    {
                        next = n.next;
                        IRenderObject child = (IRenderObject)n;
                        if (child != null)
                        {
                            child.SetParent(null);
                        }
                    }
                    children = null;
                }

                if (ctrls != null)
                {
                    foreach (IController c in ctrls.Values)
                    {
                        if (c != null)
                        {
                            c.Destroy();
                        }
                    }
                    ctrls.Clear();
                    ctrls = null;
                }

                if (timer != null)
                {
                    timer.Clear();
                }

                this.SetParent(null);
                this.OnDestroy();

                if (this.owner != null)
                {
                    this.owner.RemoveInstance(this);
                    this.owner = null;
                }
            } catch (Exception e) {
                LOG.LogError(e.ToString(), this.gameObject);
            }
            destroy = true;
        }
        public static IRenderObject CreateInstance(Type type, string filename, IRenderObject parent, params object[] args)
        {
            if (instance == null)
            {
                LOG.LogError("'RenderFactory' is null.Please initialize it.");
                return(null);
            }
            filename = filename.ToLower();
            IRenderObject inst = instance.AllocInstance(type, args) as IRenderObject;

            inst.LoadAsset(filename, parent);
            instance.renderObjs.Add(inst);
            return(inst);
        }
示例#9
0
        public T CreateInstance <T>(string filename, IRenderObject parent, bool unload, params object[] args)
            where T : IRenderObject
        {
            IRenderResource resource;

            filename = filename.ToLower();
            if (CMisc.isLegalNumber(filename))
            {
                LOG.LogError(Localization.Format("INVALID_LOAD_PATH", filename));
            }
            if (parent != null && parent.GetOwner() != null)
            {
                if (parent.GetOwner().unload_asset)
                {
                    unload = parent.GetOwner().unload_asset;
                }
            }

            if (idle.TryGetValue(filename, out resource))
            {
                idle.Remove(filename);
                if (resource.complete)
                {
                    complete.Add(filename, resource);
                }
                else
                {
                    loading.Add(filename, resource);
                }
                //LOG.Debug( "***** get resource {0} from idle, linger {1}s", filename, Time.realtimeSinceStartup -  resource.idle_time );
            }
            else if (!loading.TryGetValue(filename, out resource))
            {
                if (!complete.TryGetValue(filename, out resource))
                {
                    resource = new IRenderResource(filename, this);
                    resource.unload_asset = unload;
                    loading.Add(resource.name, resource);

                    Cookie cookie = GetCookie(filename);
                    ++cookie.create;
                }
            }
            if (resource == null)
            {
                return(null);
            }
            return(resource.CreateInstance <T>(parent, args));
        }
示例#10
0
        public List <string> GetDependenceFiles(string packageName)
        {
            if (packageDependences == null)
            {
                LOG.LogError("'UIPackageDependenceAsset' is null.Get package dependences failed.");
                return(new List <string>());
            }

            UIPackageDependence dependence = null;

            if (packageDependences.TryGetValue(packageName, out dependence))
            {
                return(dependence.dependenceFiles);
            }
            return(new List <string>());
        }
示例#11
0
 /// <summary>
 /// 安全回调函数
 /// </summary>
 /// <param name="callback"></param>
 /// <returns></returns>
 public bool OnTweenCallback(ActionTweenCallback callback)
 {
     if (ActionComponent.Instance.Config.UseSafetyMode)
     {
         try
         {
             callback();
         }
         catch (Exception e)
         {
             LOG.LogError("An error inside a tween callback was silently taken care of > " + e.Message + "\n\n" + e.StackTrace + "\n\n");
             return(false); // Callback error
         }
     }
     else
     {
         callback();
     }
     return(true);
 }
示例#12
0
        public void Dispose()
        {
            try
            {
                RenderFactory.RemoveRenderObject(this);
                AssetBundleManager.UnloadAssetBundle(name);
                if (children != null)
                {
                    for (var n = children.next; n != children;)
                    {
                        var           next  = n.next;
                        IRenderObject child = (IRenderObject)n;
                        if (child != null)
                        {
                            child.Parent = null;
                        }
                        n = next;
                    }
                    children = null;
                }

                if (components != null)
                {
                    if (dict == null)
                    {
                        dict = new Dictionary <IRenderComponent, bool>();
                    }
                    dict.Clear();

                    for (int i = 0; i < tempComponents.Count; i++)
                    {
                        var c = tempComponents[i];
                        if (c == null)
                        {
                            continue;
                        }
                        if (dict.ContainsKey(c))
                        {
                            continue;
                        }
                        dict[c] = true;
                        c.Destroy();
                    }
                    tempComponents.Clear();

                    components.Clear();
                    components = null;
                }

                if (timer != null)
                {
                    timer.Clear();
                }

                this.Parent = null;
                this.OnDestroy();
            }
            catch (Exception e)
            {
                LOG.LogError(e.ToString(), this.gameObject);
            }
        }