Exemple #1
0
        /// <summary>
        /// 初始化界面。
        /// </summary>
        /// <param name="uiFormAssetName">界面资源名称。</param>
        /// <param name="uiGroup">界面所处的界面组。</param>
        /// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param>
        /// <param name="isNewInstance">是否是新实例。</param>
        /// <param name="userData">用户自定义数据。</param>
        public virtual void OnInit(string uiFormAssetName, IUIGroup uiGroup, bool pauseCoveredUIForm, bool isNewInstance, object userData)
        {
            this.m_UIFormAssetName = uiFormAssetName;

            if (isNewInstance)
            {
                this.m_UIGroup = uiGroup;
            }
            else if (this.m_UIGroup != uiGroup)
            {
                LTLog.Error("UI group is inconsistent for new-instance UI form.");
                return;
            }

            m_DepthInUIGroup     = uiGroup.Depth;
            m_PauseCoveredUIForm = pauseCoveredUIForm;

            if (!isNewInstance)
            {
                return;
            }

            RectTransform transform = GetComponent <RectTransform>();

            transform.anchorMin        = Vector2.zero;
            transform.anchorMax        = Vector2.one;
            transform.anchoredPosition = Vector2.zero;
            transform.sizeDelta        = Vector2.zero;
        }
Exemple #2
0
        /// <inheritdoc />
        public void BroadcastDataToGamePad <T>(T data)
        {
            if (m_BridgeClass != null)
            {
                string content = m_Json.ToJson(data);

                m_Log.Debug($"Sdk BroadcastDataToGamePad : {content}");

                IMessage msg    = MessagesFactory.Msg(content);
                string   base64 = Convert.ToBase64String(msg.Encode());

                m_Log.Debug($"Sdk BroadcastDataToGamePad Base64: {base64}");

                m_BridgeClass.CallStatic("broadcastDataToGamePad", base64);
            }
            else
            {
                if (App.HasBind <IGamepadServer>())
                {
                    string content = m_Json.ToJson(data);
                    m_Log.Debug($"BroadcastDataToGamePad : {content}");

                    IMessage msg = MessagesFactory.Msg(content);
                    App.Make <IGamepadServer>().BroadcastToGamepad(msg.Encode());
                }
                else
                {
                    LTLog.Debug($"GamepadServer not register, Broadcast cannot be used. ");
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 销毁有限状态机。
        /// </summary>
        /// <param name="owner">有限状态机持有者。</param>
        /// <returns>是否销毁有限状态机成功。</returns>
        public bool DestroyFsm(object owner)
        {
            Guard.Requires <ArgumentException>(owner != null, "FSM owner is invaild.");

            if (m_Fsms.TryGetValue(owner, out IFsm fsm))
            {
                fsm.Shutdown();
                m_Fsms.Remove(owner);

                if (m_CommonFsms.Contains(fsm))
                {
                    m_CommonFsms.Remove(fsm);
                }
                if (m_LogicFsms.Contains(fsm))
                {
                    m_LogicFsms.Remove(fsm);
                }

                return(true);
            }

            LTLog.Debug($"owner is not has fsm.{owner.ToString()}");

            return(false);
        }
Exemple #4
0
        //// <inheritdoc />
        public void AddProductTable <T>(List <T> productTable)
        {
            string str = m_Json.ToJson(productTable);

            LTLog.Debug($"AddProductTable:{str}");
            if (m_BridgeClass != null)
            {
                m_BridgeClass.CallStatic("addProductTable", str);
            }
        }
Exemple #5
0
        /// <summary>
        /// 保存配置。
        /// </summary>
        /// <returns>是否保存配置成功。</returns>
        public bool Save()
        {
            string data = this.m_PlayerPrefs.ToJson();

            if (App.DebugLevel == DebugLevel.Development)
            {
                LTLog.Debug($"{typeof(SettingJson)}.SavePath = {SavedPath}");
            }

            File.WriteAllText(SavedPath, data);
            return(true);
        }
Exemple #6
0
        /// <inheritdoc />
        public LTTask <Sprite> GetLinkQRCodeAsync(int width = 188, int height = 188)
        {
            string url = "";

            if (m_BridgeClass != null)
            {
                url = m_BridgeClass.CallStatic <string>("getQRcodePathByIP", width, height, "LinkQRCode.png");
            }

            LTLog.Debug($"url:{url}");
            LTTaskCompletionSource <Sprite> tcs = LTTaskCompletionSource.New <Sprite>();

            m_MonoDriver.StartCoroutine(InnerLoadGamepadQRCode(tcs, url));
            return(tcs.Task);
        }
Exemple #7
0
        /// <summary>
        /// 加载配置。
        /// </summary>
        /// <returns>是否加载配置成功。</returns>
        public bool Load()
        {
            if (App.DebugLevel == DebugLevel.Development)
            {
                LTLog.Debug($"{typeof(SettingJson)}.LoadPath = {SavedPath}");
            }

            if (!File.Exists(SavedPath))
            {
                return(true);
            }

            this.m_PlayerPrefs = JsonMapper.ToObject(File.ReadAllText(SavedPath));
            return(true);
        }
        /// <inheritdoc />
        public IUIForm CreateUIForm(object uiFormInstance, IUIGroup uiGroup, object userData)
        {
            GameObject gameObject = uiFormInstance as GameObject;

            if (gameObject == null)
            {
                LTLog.Error("UI form instance is invalid.");
                return(null);
            }

            Transform transform = gameObject.transform;

            transform.SetParent(((MonoBehaviour)uiGroup.Helper).transform);
            transform.localScale = Vector3.one;

            return(gameObject.GetComponent <IUIForm>());
        }