Exemplo n.º 1
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. ");
                }
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }