示例#1
0
        /// <summary>
        /// 异步打开UI 但是返回值并不一定有值
        /// </summary>
        /// <param name="respath"></param>
        /// <param name="Parent"></param>
        /// <param name="mode"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public virtual GameUI OpenUIAsync(string respath, Transform Parent, AbstractParams p, LayoutLoadMode mode)
        {
            if (mode == LayoutLoadMode.None)
            {
                mode = this.DefaultMode;
            }

            GameUI ui = null;

            if (this.HasMode(mode, LayoutLoadMode.ContainCheck) && this.ContainsLoad(respath, Parent, p, out ui))
            {
                return(ui);
            }

            if (this.HasMode(mode, LayoutLoadMode.CacheCheck) && this.CanLoadFromCache(respath))
            {
                ui = CallCacheUI(respath, Parent, p);
                return(ui);
            }

            if (this.HasMode(mode, LayoutLoadMode.LoadDirect))
            {
                AsyncLoadUI(respath, Parent, p);
                return(null);
            }
            LogMgr.LogErrorFormat("{0} mode error", respath);
            return(null);
        }
示例#2
0
 public AbstractParams Invoke(AbstractParams ScriptParms)
 {
     if (ScriptFunc != null)
     {
         if (this.RetTp == typeof(void))
         {
             Action <AbstractParams> f = (Action <AbstractParams>)ScriptFunc;
             f(ScriptParms);
             return(null);
         }
         else
         {
             Func <AbstractParams, AbstractParams> f = (Func <AbstractParams, AbstractParams>)ScriptFunc;
             return(f(ScriptParms));
         }
     }
     else
     {
         if (weakref != null && weakref.IsAlive && method != null)
         {
             object ret = method.Invoke(weakref.Target, new object[] { ScriptParms });
             if (ret != null && ret is AbstractParams)
             {
                 return(ret as AbstractParams);
             }
             return(null);
         }
         else
         {
             LogMgr.LogWarningFormat("对象方法已经失效 :{0}", methodname);
             return(null);
         }
     }
 }
示例#3
0
 /// <summary>
 /// 异步加载
 /// </summary>
 /// <param name="respath"></param>
 /// <param name="Parent"></param>
 /// <param name="p"></param>
 private void AsyncLoadUI(string respath, Transform Parent, AbstractParams p)
 {
     this.loaderQueue.Add(new Tuple <string, Transform, AbstractParams>(respath, Parent, p));
     if (!ResBundleMgr.mIns.Cache.ContainsLoading(respath))
     {
         ResBundleMgr.mIns.LoadAsync(respath, AsyncDone);
     }
 }
示例#4
0
        public void CloseUI(Transform ui, AbstractParams p = null)
        {
            GameUI gameui = ui.GetComponent <GameUI>();

            if (gameui != null)
            {
                CloseUI(gameui, p);
            }
            RealRemove();
        }
示例#5
0
 public void OpenUI(AbstractParams p = null)
 {
     if (this.ParentLayout != null)
     {
         this.ParentLayout.OpenUI(this, p);
     }
     else
     {
         LogMgr.LogErrorFormat("Missing Layout {0}", this);
     }
 }
示例#6
0
 public override void RemoveToPool()
 {
     base.RemoveToPool();
     this.m_pausedtime       = 0f;
     this.m_pausedstarttime  = 0f;
     this.m_delay            = 0f;
     this.m_starttime        = 0f;
     this.Callback           = null;
     this.CallBackWithParams = null;
     this.cacheParams        = null;
 }
示例#7
0
        public AbstractParams NotifyToLua(int luaCmd, AbstractParams p)
        {
            ScriptCommand cmd = ScriptCommand.Create(luaCmd);

            cmd.SetCallParams(p);
            cmd.Excute();

            AbstractParams ret = cmd.ReturnParams;

            cmd.Release(false);
            return(ret);
        }
示例#8
0
 public GameUI OpenUIAsync(string respath, AbstractParams p, LayoutLoadMode mode)
 {
     if (this.ParentLayout != null)
     {
         return(this.ParentLayout.OpenUIAsync(respath, p, mode));
     }
     else
     {
         LogMgr.LogErrorFormat("Missing Layout {0}", this);
     }
     return(null);
 }
示例#9
0
 public GameUI OpenUIAsync(string respath, Transform Parent, AbstractParams p)
 {
     if (this.ParentLayout != null)
     {
         return(this.ParentLayout.OpenUIAsync(respath, Parent, p));
     }
     else
     {
         LogMgr.LogErrorFormat("Missing Layout {0}", this);
     }
     return(null);
 }
示例#10
0
 private static void staticRelease(AbstractParams p)
 {
     if (p != null)
     {
         GameUI ui = p.ReadObject() as GameUI;
         ui.CallRelease();
     }
     else
     {
         LogMgr.LogError("gameui staticRelease params is Null ");
     }
 }
示例#11
0
 public GameUI OpenUI(string path, AbstractParams p = null)
 {
     if (this.ParentLayout != null)
     {
         return(this.ParentLayout.OpenUI(path, p));
     }
     else
     {
         LogMgr.LogErrorFormat("Missing Layout {0}", this);
     }
     return(null);
 }
示例#12
0
 static void Leave(AbstractParams p)
 {
     if (p != null && p.ArgCount == 1)
     {
         int value = p.ReadInt();
         getInstance()._tryCall(MainLoopEvent.OnLevelLeaved, value);
     }
     else
     {
         LogMgr.LogErrorFormat("params :{0} Error", p);
     }
 }
示例#13
0
 public virtual void CloseUI(GameUI ui, AbstractParams p = null)
 {
     for (int i = this.uicontainer.Count - 1; i >= 0; i--)
     {
         GameUI gameui = this.uicontainer[i];
         if (gameui == ui)
         {
             CloseAtIndex(gameui, i, false, p);
             break;
         }
     }
     RealRemove();
 }
示例#14
0
 /// <summary>
 /// 删除第一个符合条件的
 /// </summary>
 /// <param name="respath"></param>
 /// <param name="p"></param>
 public virtual void CloseUI(string respath, AbstractParams p = null)
 {
     for (int i = this.uicontainer.Count - 1; i >= 0; i--)
     {
         GameUI gameui = this.uicontainer[i];
         if (CompareUI(gameui, respath))
         {
             CloseAtIndex(gameui, i, false, p);
             break;
         }
     }
     RealRemove();
 }
示例#15
0
        /// <summary>
        /// 从缓存中加载
        /// </summary>
        /// <param name="respath"></param>
        /// <param name="Parent"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        private GameUI CallCacheUI(string respath, Transform Parent, AbstractParams p)
        {
            GameUI ui = LoadFromCache(respath);

            if (ui != null)
            {
                BindToCanvas(ui.gameObject, Parent, p);
                AddtoContioner(ui, Parent);

                ui.DoVisiable();
                CallUI(ui, p);
            }
            return(ui);
        }
示例#16
0
        /// <summary>
        /// 符合的全部刷新
        /// </summary>
        /// <param name="respath"></param>
        /// <param name="p"></param>
        private List <GameUI> RefreshUI(string respath, Transform trans, AbstractParams p)
        {
            this.ComparedValue = respath;
            this.ComparedTrans = trans;
            List <GameUI> uilist = GetUI(PathTransCompareUI);

            for (int i = 0; i < uilist.Count; ++i)
            {
                GameUI ui = uilist[i];
                CallUI(ui, p);
            }

            return(uilist);
        }
示例#17
0
        private void CallEnter(AbstractParams p)
        {
            if (enterParams != null)
            {
                LogMgr.LogFormat("{0} enter params will refresh :{1} => {2}", this, enterParams, p);
                enterParams.Release();
            }

            enterParams = p;
            if (!HasEnter)
            {
                NextFrame(null);
            }
        }
示例#18
0
        /// <summary>
        /// 删除第一个符合条件的
        /// </summary>
        /// <param name="respath"></param>
        /// <param name="p"></param>
        public virtual void CloseUI(string respath, Transform Parent, AbstractParams p = null)
        {
            for (int i = this.uicontainer.Count - 1; i >= 0; i--)
            {
                GameUI gameui = this.uicontainer[i];
                ///可能会出现都在最外面,parent is null,只是删除了第一个对象,所以最好持有对象然后删除
                if (CompareUI(gameui, respath, Parent))
                {
                    CloseAtIndex(gameui, i, false, p);
                    break;
                }
            }

            RealRemove();
        }
示例#19
0
 private static void CallEnter(AbstractParams p)
 {
     if (p.ArgCount > 0)
     {
         FSMElement e = p.ReadObject() as FSMElement;
         if (e != null)
         {
             e.OnEnter();
         }
     }
     else
     {
         LogMgr.LogError("参数异常");
     }
 }
示例#20
0
        protected void CloseAtIndex(GameUI gameui, int index, bool force = false, AbstractParams p = null)
        {
            if (!removeList.Contains(gameui))
            {
                //check children
                GameUI[] childrenUI = gameui.GetComponentsInChildren <GameUI>();
                for (int i = 0; i < childrenUI.Length; ++i)
                {
                    if (childrenUI[i] != gameui)
                    {
                        for (int j = 0; j < uicontainer.Count; ++j)
                        {
                            if (uicontainer[j] == childrenUI[i])
                            {
                                CloseAtIndex(uicontainer[j], j, force);
                            }
                        }
                    }
                }

                ScriptCommand cmd = ScriptCommand.Create((int)FrameWorkCmdDefine.UICallExit);
                if (p != null)
                {
                    cmd.CallParams = p;
                }
                cmd.target = ScriptTarget.Sharp;
                cmd.CallParams.InsertObject(0, gameui);
                cmd.Excute();

                if (p != null)
                {
                    p.Release();
                }

                CacheCommand.CanCelAllBy(gameui);

                if (force)
                {
                    gameui.DestorySelf();
                }
                else
                {
                    DestroyUI(gameui);
                }

                removeList.Add(gameui);
            }
        }
示例#21
0
        private void _LuaScriptParmsCall(AbstractParams ScriptParms)
        {
            if (ScriptParms != null)
            {
                ScriptParms.ResetReadIndex();

                for (int i = 0; i < ScriptParms.ArgCount; ++i)
                {
                    int tp = ScriptParms.GetArgIndexType(i);
                    if (tp == (int)ParamType.INT)
                    {
                        this.luafunc.Push(ScriptParms.ReadInt());
                    }
                    else if (tp == (int)ParamType.BOOL)
                    {
                        this.luafunc.Push(ScriptParms.ReadBool());
                    }
                    else if (tp == (int)ParamType.SHORT)
                    {
                        this.luafunc.Push(ScriptParms.ReadShort());
                    }
                    else if (tp == (int)ParamType.FLOAT)
                    {
                        this.luafunc.Push(ScriptParms.ReadFloat());
                    }
                    else if (tp == (int)ParamType.DOUBLE)
                    {
                        this.luafunc.Push(ScriptParms.ReadDouble());
                    }
                    else if (tp == (int)ParamType.STRING)
                    {
                        this.luafunc.Push(ScriptParms.ReadString());
                    }
                    else if (tp == (int)ParamType.OBJECT)
                    {
                        this.luafunc.Push(ScriptParms.ReadObject());
                    }
                    else if (tp == (int)ParamType.UNITYOBJECT)
                    {
                        this.luafunc.Push(ScriptParms.ReadUnityObject());
                    }
                    else if (tp == (int)ParamType.LONG)
                    {
                        this.luafunc.Push(ScriptParms.ReadLong());
                    }
                }
            }
        }
示例#22
0
        public AbstractParams Invoke(AbstractParams ScriptParms)
        {
#if TOLUA
            if (LuaClient.Instance == null)
            {
                LogMgr.Log("未使用lua,但是程序集中包含了带有lua目标的函数的注册");
                return(null);
            }

            TryInit(this.attribute);

            if (this.luafunc == null)
            {
                this.luafunc = LuaClient.GetMainState().GetFunction(luafilepath.Split('.')[0] + "." + this.methodname);
                if (this.luafunc == null)
                {
                    //try get function from global
                    this.luafunc = LuaClient.GetMainState().GetFunction(this.methodname);
                }
            }

            if (this.luafunc != null)
            {
                int oldTop = this.luafunc.BeginPCall();
                //retry
                if (Luatable == null)
                {
                    this.Luatable = TryGetClassLuaFunction(this.luafilepath);
                }

                if (Luatable != null)
                {
                    this.luafunc.Push(Luatable);
                }

                this._LuaScriptParmsCall(ScriptParms);
                this.luafunc.PCall();
                AbstractParams retparams = this._LuaRetCall(oldTop);

                this.luafunc.EndPCall();
                return(retparams);
            }
#else
            LogMgr.LogError("Lua Client Missing Cant Invoke Lua Function");
#endif

            return(null);
        }
示例#23
0
        public void Init(AbstractParams InitParams)
        {
            object passObject = InitParams.ReadObject();

            if (passObject != null && passObject is Delegate)
            {
                ScriptFunc      = passObject as Delegate;
                this.RetTp      = InitParams.ReadObject() as Type;
                this.methodname = InitParams.ReadString();
            }
            else if (passObject != null)
            {
                weakref = new WeakReference(passObject);
                method  = InitParams.ReadObject() as MethodInfo;
            }
        }
示例#24
0
 private static void staticEnter(AbstractParams p)
 {
     if (p != null)
     {
         System.Object o  = p.ReadObject();
         GameUI        ui = o as GameUI;
         if (ui == null)
         {
             LogMgr.LogError("really??");
         }
         ui.CallEnter(p);
     }
     else
     {
         LogMgr.LogError("gameui staticEnter params is Null ");
     }
 }
示例#25
0
 private bool RemoveLoading(string name, out AbstractParams p, out Transform tr)
 {
     for (int i = 0; i < loaderQueue.Count; ++i)
     {
         Tuple <string, Transform, AbstractParams> kv = this.loaderQueue[i];
         if (kv.k1 == name)
         {
             tr = kv.k2;
             p  = kv.k3;
             this.loaderQueue.RemoveAt(i);
             return(true);
         }
     }
     p  = null;
     tr = null;
     return(false);
 }
示例#26
0
 private void CallUI(GameUI ui, AbstractParams p)
 {
     if (ui.HasEnter)
     {
         ui.CallRefresh(p);
     }
     else
     {
         ScriptCommand cmd = ScriptCommand.Create((int)FrameWorkCmdDefine.UICallEnter);
         if (p != null)
         {
             cmd.CallParams = p;
         }
         cmd.CallParams.InsertObject(0, ui);
         cmd.target = ScriptTarget.Sharp;
         cmd.Excute();
     }
 }
示例#27
0
        /// <summary>
        /// 同步加载
        /// </summary>
        /// <param name="respath"></param>
        /// <param name="Parent"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        private GameUI SyncLoadUI(string respath, Transform Parent, AbstractParams p)
        {
            GameObject instance = ResBundleMgr.mIns.Load(respath).SimpleInstance();

            if (instance == null)
            {
                return(null);
            }

            GameUI ui = BindToCanvas(instance, Parent, p);

            if (ui != null)
            {
                ui.InitLua(respath);
            }
            AddtoContioner(ui, Parent);
            CallUI(ui, p);
            return(ui);
        }
示例#28
0
        private bool ContainsLoad(string respath, Transform Parent, AbstractParams p, out GameUI gameui)
        {
            List <GameUI> uilist = RefreshUI(respath, Parent, p);

            if (uilist.Count > 0)
            {
                if (uilist.Count > 1)
                {
                    LogMgr.LogWarningFormat("{0} contains multi ui elements at the {1}", respath, Parent);
                }

                gameui = uilist[0];
                ListPool.TryDespawn(uilist);

                return(true);
            }
            gameui = null;
            return(false);
        }
示例#29
0
            public AbstractParams Invoke(AbstractParams ScriptParms)
            {
                try
                {
                    return(this.Loader.Invoke(ScriptParms));
                }
                catch (FrameWorkException ex)
                {
                    LogMgr.LogException(ex);

                    ex.RaiseExcption();
                    return(null);
                }
                catch (Exception ex)
                {
                    LogMgr.LogException(ex);
                    return(null);
                }
            }
示例#30
0
        private void AsyncDone(bool ret, AssetBundleResult result)
        {
            if (ret)
            {
                AbstractParams p      = null;
                Transform      Parent = null;
                while (this.RemoveLoading(result.LoadPath, out p, out Parent))
                {
                    GameObject instance = result.SimpleInstance();
                    GameUI     ui       = BindToCanvas(instance, Parent, p);

                    if (ui != null)
                    {
                        ui.InitLua(result.LoadPath);
                    }

                    AddtoContioner(ui, Parent);
                    CallUI(ui, p);
                }
            }
        }