コード例 #1
0
        public virtual void InitArgs(int zOrder, GameObject go, IViewMgr mgr, params object[] args)
        {
            this._zOrder  = zOrder;
            this._uiObj   = go;
            this._viewMgr = mgr;
            this._evtSet  = new HashSet <string>();

            try
            {
                CnUiComponent comp = this.GetCnUiComponent();
                if (comp != null)
                {
                    bool ret = comp.InitUiComponent(this._uiObj.transform);
                    ZLog.I(this._uiObj, "ui {0}  init compent {1}", this.GetName(), ret ?"ok":"failed");
                }
                else
                {
                    ZLog.I(this._uiObj, "ui {0} no init compent", this.GetName());
                }
                this.OnLoad(args);
            }catch (Exception e)
            {
                ZLog.E(this._uiObj, " ui {0} OnLoad err {1}", this.GetName(), e.ToString());
            }
        }
コード例 #2
0
        UnityEngine.Object LoadRes(string name)
        {
            string full_path = root_path + name + ".prefab";

            ZLog.I(null, "{0}", full_path);
            return(LoadResource.LoadAssetAtPath(full_path, typeof(GameObject)));
        }
コード例 #3
0
        public bool Update()
        {
            CheckErr();
            bool goon = true;

            switch (netWorkState)
            {
            case NetWorkState.CLOSING:
                HandleClosing();
                break;

            case NetWorkState.CONNECTING:
                //CheckTimeOut();
                break;

            case NetWorkState.CONNECTED:
                HandleConnect();
                break;

            case NetWorkState.Running:
                PeekMessage();
                break;

            case NetWorkState.CLOSED:
                goon = false;
                break;

            default:
                ZLog.I(_mb, "stop socket {0}", netWorkState);
                goon = false;
                break;
            }
            return(goon);
        }
コード例 #4
0
        public GameObject InitResEx(string name, Transform parent)
        {
            GameObject ins = null;

            do
            {
                GameObject go = this.FindUIRes(name);
                if (null == go)
                {
                    ZLog.E(null, "no ui {0}", name);
                    break;
                }
                ins = GameObject.Instantiate(go) as GameObject;
                if (ins == null)
                {
                    ZLog.E(null, "{0} Instantiate fail", name);
                    break;
                }
                string[] strList  = name.Split(new Char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
                string   new_name = strList[strList.Length - 1];
                ins.transform.SetParent(parent, false);
                ins.transform.localPosition = Vector3.zero;
                ins.transform.localScale    = Vector3.one;
                ins.transform.localRotation = Quaternion.identity;
                ins.name = new_name;
                ZLog.I(null, "Load {0} ok", name);
            } while (false);
            return(ins);
        }
コード例 #5
0
 void CheckTimeOut()
 {
     if (Time.realtimeSinceStartup - _startConnectTime > _connectTimeout)
     {
         ZLog.I(_mb, "connect timeout");
         OnDisconnect(9, "connect timeout");
     }
 }
コード例 #6
0
 void CheckTimeOut()//超时暂时无法中止
 {
     if (Time.realtimeSinceStartup - _startConnectTime > _connectTimeout)
     {
         ZLog.I(_mb, "connect timeout");
         _webSocket.CloseAsync(CloseStatusCode.NoStatus);
         //Close();
         //OnDisconnect(9, "connect timeout");
     }
 }
コード例 #7
0
        void OnApplicationQuit()
        {
            ZLog.I(this, "OnQuit");
            _mainEntryEvent.TriggerQuit();

            /*
             * if ( _hasLogFile && _logFile != null)
             * {
             *  _logFile.Close();
             * }*/
        }
コード例 #8
0
        private IEnumerator _AutoUpdate()
        {
            bool running = true;

            while (running)
            {
                try {
                    running = Update();
                }catch (Exception e)
                {
                    ZLog.E(_mb, "{0}", e);
                }
                yield return(1);
            }
            ZLog.I(_mb, "{0}:{1} exit loop", _host, _port);
        }
コード例 #9
0
        /*
         * //config
         * public bool     _hasLogFile ;
         * public string   _startClass ;
         *
         *
         * LogFile         _logFile;
         *
         * void InvokeAwake()
         * {
         *  if ( _startClass == null || "" == _startClass)
         *  {
         *      _startClass = "Main";
         *  }
         *
         *  try
         *  {
         *      Assembly currentAssem = Assembly.GetExecutingAssembly();
         *      Type type = currentAssem.GetType(_startClass);
         *      type.InvokeMember("Awake",
         *          System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public
         *          , null, null, null);
         *      ZLog.I(this, "Invoke {0}.Awake ok", _startClass);
         *  }
         *  catch (Exception e)
         *  {
         *      ZLog.E(this, "Invoke {0}.Awake failed, reason {1}", _startClass, e.ToString());
         *  }
         * }
         */
        void Awake()
        {
            _mainEntryEvent = MainEntryEvent.Instance;
            _mainEntryEvent.SetMb(this);

            /*
             * if (_hasLogFile)
             * {
             *  _logFile = new LogFile();
             * }
             */
            ZLog.I(this, "OnAwake");

            //InvokeAwake();

            _mainEntryEvent.TriggerAwake();
        }
コード例 #10
0
 // Use this for initialization
 void Start()
 {
     ZLog.I(this, "OnStart");
     _mainEntryEvent.TriggerStart();
 }