Пример #1
0
        public object Frame(int frameTime)
        {
            if (parentGround == null)
            {
                parentGround = UnityUiUtility.FindUIObject(GroundParentPath);
            }

            if (parentBag == null)
            {
                parentBag = UnityUiUtility.FindUIObject(BagParentPath);
            }

            InitialBag();

            SimpleFreeUI bag = SingletonManager.Get <FreeUiManager>().GetUi("bagSystemUI");

            if (bag.Visible != isOpen)
            {
                if (!bag.Visible)
                {
                    SingletonManager.Get <FreeUiManager>().Contexts1.ui.uI.IsShowCrossHair = true;
                    SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.UnblockKey(bagBlockKeyId);
                    SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.UnblockPointer(bagBlockPointerId);
                }
                else
                {
                    SingletonManager.Get <FreeUiManager>().Contexts1.ui.uI.IsShowCrossHair = false;
                    bagBlockKeyId     = SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.BlockKey(UserInputManager.Lib.Layer.Ui);
                    bagBlockPointerId = SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.BlockPointer(UserInputManager.Lib.Layer.Ui);
                }
                isOpen = bag.Visible;

                if (CursorLocker.SystemUnlock)
                {
                    //Unlock
                    SingletonManager.Get <FreeUiManager>().Contexts1.ui.uI.IsShowCrossHair = false;
                    CursorLocker.SystemBlockKeyId     = SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.BlockKey(UserInputManager.Lib.Layer.System);
                    CursorLocker.SystemBlockPointerId = SingletonManager.Get <FreeUiManager>().Contexts1.userInput.userInputManager.Helper.BlockPointer(UserInputManager.Lib.Layer.System);
                }
            }

            if (bag.Visible)
            {
                FreePrefabLoader.CacheGameObject(new AssetInfo("ui/client/prefab/chicken", "ItemBar"), 50);
                FreePrefabLoader.CacheGameObject(new AssetInfo("ui/client/prefab/chicken", "CaseNameBar"), 5);

                if (parentGround != null && parentBag != null && DateTime.Now.Ticks - lastUpdateTime > 10000)
                {
                    lastUpdateTime = DateTime.Now.Ticks;

                    Contexts context = SingletonManager.Get <FreeUiManager>().Contexts1;

                    PlayerEntity player = context.player.flagSelfEntity;

                    RefreshGround(context, player);
                    RefreshBag(context, player);
                }
            }
            return(null);
        }
Пример #2
0
 public override void Recycle()
 {
     if (currentObj != null)
     {
         FreeUrl url = FreeResourceUtil.Convert(_particleName);
         currentObj.SetActive(false);
         FreePrefabLoader.ReturnGameObject(currentObj, new AssetInfo(url.BuddleName, url.AssetName));
     }
 }
Пример #3
0
        private void ReturnObject(ItemBar bar)
        {
            FreePrefabComponent prefab = bar.prefab;
            GameObject          obj    = (GameObject)prefab.currentObject;

            if (obj != null)
            {
                obj.GetComponent <Transform>().parent = null;
                FreePrefabLoader.ReturnGameObject(obj, prefab.assetInfo);

                string   imgUrl      = "";
                string[] fieldValues = bar.value.Split(FreeMessageConstant.SpliterRecord);

                foreach (string fieldValue in fieldValues)
                {
                    string[] vs = fieldValue.Split(FreeMessageConstant.SpilterField);
                    if (vs.Length == 2)
                    {
                        if (vs[0].Trim() == "IMG_WeaponIcon")
                        {
                            imgUrl = vs[1].Trim();
                        }
                    }
                }

                GameObject img = UnityUiUtility.FindUIObject(obj, "IMG_WeaponIcon");
                if (img != null && !string.IsNullOrEmpty(imgUrl))
                {
                    int       last       = imgUrl.Trim().LastIndexOf("/");
                    string    buddleName = imgUrl.Trim().Substring(0, last);
                    string    assetName  = imgUrl.Trim().Substring(last + 1);
                    AssetInfo info       = new AssetInfo(buddleName, assetName);

                    Graphic gra = img.GetComponent <Graphic>();
                    if (gra is Image)
                    {
                        FreeUILoader.ReturnGameObject(((Image)gra).sprite, info);
                    }
                    if (gra is RawImage)
                    {
                        FreeUILoader.ReturnGameObject(((RawImage)gra).texture, info);
                    }
                }
            }
        }
Пример #4
0
        public void Initial(params object[] ini)
        {
            InitialAuto(ini[1] as string);

            this.iniTime = DateTime.Now.Ticks;

            string[] settings = (ini[0] as string).Split(FreeMessageConstant.SpliterStyle);

            this.name = settings[0];
            this.valueList.Add(settings[1]);
            this.events = settings[2];

            int last = name.LastIndexOf("/");

            this.assetInfo = new AssetInfo(name.Substring(0, last),
                                           name.Substring(last + 1));

            FreePrefabLoader.Load(assetInfo.BundleName, assetInfo.AssetName,
                                  (prefab) =>
            {
                if (prefab == null)
                {
                    return;
                }
                this.currentObject = (GameObject)prefab;

                ((GameObject)prefab).transform.SetParent(_uiObject.gameObject.transform, false);
                RectTransform rt = ((GameObject)prefab).GetComponent <RectTransform>();
                ((GameObject)prefab).SetActive(true);

                try
                {
                    foreach (string values in valueList)
                    {
                        SetPureValue(values);
                    }
                    valueList.Clear();
                    AddEvent(events);
                    updateEventKey();
                }
                catch (Exception e)
                {
                    Debug.LogError("prefab component failed." + e.StackTrace);
                }

                if (parentObject != null)
                {
                    if (UIAddChildMessageHandler.clearTime.ContainsKey(parentObject.GetInstanceID()))
                    {
                        long clearTime = UIAddChildMessageHandler.clearTime[parentObject.GetInstanceID()];
                        if (iniTime > clearTime)
                        {
                            ((GameObject)prefab).transform.SetParent(parentObject.transform, false);
                        }
                        else
                        {
                            GameObject.Destroy(currentObject);
                            Debug.LogWarning(this.name + "=" + this.valueList + " is invalid");
                        }
                    }
                    else
                    {
                        ((GameObject)prefab).transform.SetParent(parentObject.transform, false);
                    }
                }

                UIAddChildMessageHandler.HandleNoeDone();

                rt.localScale = new Vector3(1, 1, 1);
            }, _uiObject.gameObject);
        }
Пример #5
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }
            _isDisposed = true;
            _clientSessionStateMachine.Dispose();
            FreePrefabLoader.Destroy();
            var _sessionObjects = _contexts.session.commonSession;

            _contexts.session.commonSession.Dispose();
            _contexts.session.clientSessionObjects.Dispose();

            if (_contexts.session.clientSessionObjects.NetworkChannel != null)
            {
                _contexts.session.clientSessionObjects.NetworkChannel.Dispose();
            }

            foreach (var info in _sessionObjects.GameContexts.AllContexts)
            {
                foreach (IGameEntity entity in info.GetEntities())
                {
                    foreach (var comp in entity.ComponentList)
                    {
                        if (comp is IAssetComponent)
                        {
                            ((IAssetComponent)comp).Recycle(_sessionObjects.AssetManager);
                        }
                    }

                    if (_sessionObjects.AssetManager != null)
                    {
                        _sessionObjects.AssetManager.LoadCancel(entity.RealEntity);
                    }
                    entity.Destroy();
                }
            }

            foreach (Entity entity in _contexts.ui.GetEntities())
            {
                DestroyEntity(_sessionObjects, entity);
            }


            foreach (Entity entity in _contexts.sceneObject.GetEntities())
            {
                DestroyEntity(_sessionObjects, entity);
            }

            _clientSessionStateMachine.ShutDown();
            try
            {
                _contexts.Reset();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("contexts.Reset error:{0}", ex.Message);
            }

            UiModule.DestroyAll();
            FreeUILoader.Destroy();
        }
Пример #6
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }
            _isDisposed = true;
            try
            {
                _clientSessionStateMachine.Dispose();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("_clientSessionStateMachine.Disposeerror:{0}", ex);
            }

            try
            {
                FreePrefabLoader.Destroy();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("FreePrefabLoader.Destroy(){0}", ex);
            }

            try
            {
                _contexts.session.commonSession.Dispose();
                _contexts.session.clientSessionObjects.Dispose();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(" _contexts.session {0}", ex);
            }

            var _sessionObjects = _contexts.session.commonSession;

            try
            {
                if (_contexts.session.clientSessionObjects.NetworkChannel != null)
                {
                    _contexts.session.clientSessionObjects.NetworkChannel.Dispose();
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(" _contexts.NetworkChannel {0}", ex);
            }


            RecycleEntitys(_contexts);

            try
            {
                _clientSessionStateMachine.ShutDown();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(" _clientSessionStateMachine.ShutDown {0}", ex);
            }

            try
            {
                _contexts.Reset();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("contexts.Reset error:{0}", ex.Message);
            }

            try
            {
                UiModule.DestroyAll();
                FreeUILoader.Destroy();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("contexts.Reset error:{0}", ex.Message);
            }
        }