Exemple #1
0
        //读取filelist
        public static XFileList LoadFileList(string path)
        {
            if (!XUtilities.IsFolder(path) || !Directory.Exists(path))
            {
                return(null);
            }
            var filelistPath = $"{path}/{FILE_LIST_NAME}";

            if (!XUtilities.ExistFile(filelistPath))
            {
                XDebug.Log(Tag, $"文件清单不存在 {filelistPath}");
                return(null);
            }
            try
            {
                var fileData = XUtilities.ReadFile(filelistPath);
                var content  = Encoding.UTF8.GetString(fileData);
                var result   = JsonUtility.FromJson <XFileList>(content);
                XDebug.Log(Tag, result.ToLog());
                return(result);
            }
            catch (Exception e)
            {
                XDebug.LogError(Tag, $"读取文件清单失败 {filelistPath}\n{e.ToString()}");
            }
            return(null);
        }
Exemple #2
0
 // Called when the state of the playable is set to Play
 public override void OnBehaviourPlay(Playable playable, FrameData info)
 {
     if (string.IsNullOrEmpty(EventName))
     {
         return;
     }
     XDebug.Log(XPlayableConst.Tag, $"触发事件 name:{EventName} param:{EventPara}");
     mono?.PostEvent(EventName, EventPara);
 }
 public void Revs(Action OnComplete = null, float time = 0f, EnumPlayMode mode = EnumPlayMode.Once, float delay = 0f)
 {
     XDebug.Log(XPlayableConst.Tag, $"开始倒放 {_GetPlayName()}");
     _PlayMode         = mode;
     _PlayTime         = _GetPlayTime(time);
     _IsReverse        = true;
     _OnComplete       = OnComplete;
     _DelayTime        = delay;
     _DelayTimeCounter = 0f;
     _PlayInternal();
 }
 public void Play(Action OnComplete = null, float time = 0f, EnumPlayMode mode = EnumPlayMode.Once, float delay = 0f)
 {
     XDebug.Log(XPlayableConst.Tag, $"开始播放 {_GetPlayName()} go:{gameObject.name}");
     _PlayMode         = mode;
     _PlayTime         = _GetPlayTime(time);
     _IsReverse        = false;
     _OnComplete       = OnComplete;
     _DelayTime        = delay;
     _DelayTimeCounter = 0f;
     _PlayInternal();
 }
Exemple #5
0
        void CheckValue()
        {
            var logger = XDebug.CreateMutiLogger("XMonoVariables");

            logger.Append($"===打印数据=== count:{values.Count}");
            foreach (var value in values)
            {
                logger.Append($"{value.name}:{value.GetValue()}");
            }
            logger.Log();
        }
            public bool HandleRequest()
            {
                onProgress?.Invoke(async.progress);
                if (!async.isDone)
                {
                    return(false);
                }
                var webRequest = async.webRequest;

                if (webRequest.isNetworkError ||
                    webRequest.isHttpError ||
                    webRequest.responseCode != HttpCode_OK)
                {
                    XDebug.LogError(Tag, $"url failed {webRequest.error}");
                    if (binResponse != null)
                    {
                        binResponse?.Invoke(webRequest.error, null);
                        binResponse = null;
                    }
                    if (strResponse != null)
                    {
                        strResponse?.Invoke(webRequest.error, null);
                        strResponse = null;
                    }
                }
                else
                {
                    XDebug.Log(Tag, $"url successed {webRequest.downloadHandler.text}");
                    var binResponseData = webRequest.downloadHandler.data;
                    //解密
                    if (!string.IsNullOrEmpty(encrypt))
                    {
                    }
                    if (binResponse != null)
                    {
                        binResponse.Invoke(string.Empty, binResponseData);
                        binResponse = null;
                    }
                    if (strResponse != null)
                    {
                        var strResponseData = Encoding.UTF8.GetString(binResponseData);
                        strResponse.Invoke(string.Empty, strResponseData);
                        strResponse = null;
                    }
                }
                return(true);
            }
        private void Update()
        {
            if (!_IsPlaying || _IsPause)
            {
                return;
            }
            if (_DelayTime > 0f && _DelayTimeCounter < _DelayTime)
            {
                _DelayTimeCounter += Time.deltaTime;
                if (_DelayTimeCounter < _DelayTime)
                {
                    return;
                }
            }
            _PlayTimeCounter += Time.deltaTime;
            //Debug.Log(_PlayTimeCounter + " " + _PlayTime);
            if (_PlayTimeCounter > _PlayTime)
            {
                _PlayTimeCounter = _PlayTime;
            }
            if (_PlayTime > 0f)
            {
                _UpdateInterval();
            }
            if (_PlayTimeCounter >= _PlayTime)
            {
                switch (_PlayMode)
                {
                case EnumPlayMode.Loop:
                    _PlayTimeCounter = _IsReverse ? 1f : 0f;
                    break;

                case EnumPlayMode.Once:
                    XDebug.Log(XPlayableConst.Tag, $"播放完成 {_GetPlayName()}");
                    _StopInternal();
                    _OnComplete?.Invoke();
                    break;

                case EnumPlayMode.OnceSample:
                    XDebug.Log(XPlayableConst.Tag, $"播放完成 {_GetPlayName()}");
                    _OnComplete?.Invoke();
                    break;
                }
            }
        }
Exemple #8
0
        //创建filelist
        public static bool CreateFileList(string path)
        {
            if (!XUtilities.IsFolder(path) || !Directory.Exists(path))
            {
                return(false);
            }
            var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);

            if (files.Length < 1)
            {
                return(false);
            }

            try
            {
                var result = new XFileList();
                foreach (var file in files)
                {
                    if (file.Contains(FILE_LIST_NAME))
                    {
                        continue;
                    }
                    FileInfo sysFileInfo = new FileInfo(file);

                    var fileInfo = new XFileInfo();
                    fileInfo.name = sysFileInfo.Name;
                    fileInfo.path = file.Replace(path + "\\", string.Empty);
                    var fileStream = sysFileInfo.OpenRead();
                    fileInfo.md5 = ToMD5(fileStream);
                    fileStream.Close();
                    fileInfo.length = sysFileInfo.Length;
                    result.m_dictFileInfo.Add(fileInfo.name, fileInfo);
                }
                XDebug.Log(Tag, result.ToLog());
                var json         = JsonUtility.ToJson(result);
                var filelistPath = $"{path}/{FILE_LIST_NAME}";
                File.WriteAllText(filelistPath, json);
                return(true);
            }
            catch (Exception e)
            {
                XDebug.LogError(Tag, e.ToString());
            }
            return(false);
        }
Exemple #9
0
 public void Tick(T obj, float elapsedTime)
 {
     if (!string.IsNullOrEmpty(m_next))
     {
         XDebug.Log(Tag, $"state change {m_curr} -> {m_next}");
         _ChangeState(obj, m_next);
         m_next = string.Empty;
     }
     if (m_curState != null)
     {
         m_curState.OnUpdate(obj, elapsedTime);
         var next = m_curState.Transition(obj);
         if (!string.IsNullOrEmpty(next))
         {
             ChangeState(next);
         }
     }
 }
Exemple #10
0
 protected override void _OnInit()
 {
     if (AppointAnimation != null)
     {
         _Animation = AppointAnimation;
     }
     else
     {
         _Animation = GetComponent <Animation>();
     }
     if (_Animation != null)
     {
         _AnimationState = _Animation[AnimationName];
     }
     if (_AnimationState == null)
     {
         XDebug.Log(XPlayableConst.Tag, $"没有找到动画 {AnimationName} {gameObject.name}");
     }
 }
Exemple #11
0
        //保存filelist
        public static bool SaveFileList(string path, XFileList fileList)
        {
            if (!XUtilities.IsFolder(path) || !Directory.Exists(path))
            {
                return(false);
            }
            var filelistPath = $"{path}/{FILE_LIST_NAME}";

            try
            {
                var json = JsonUtility.ToJson(fileList);
                XUtilities.SaveFile(filelistPath, json);
                XDebug.Log(Tag, json);
                return(true);
            }
            catch (Exception e)
            {
                XDebug.LogError(Tag, $"保存文件清单失败 {filelistPath}\n{e.ToString()}");
            }
            return(false);
        }
Exemple #12
0
 void Apply()
 {
     XDebug.Initialize();
     XDebug.SetLogClass(XDebug.ReflectClassType);
     EditorUtility.DisplayDialog("提示", "应用成功", "OK");
 }
Exemple #13
0
 public override void Enter()
 {
     XDebug.Log(XTaskConst.Tag, $"wait {m_time.ToString("f2")} seconds");
     m_timeCounter = 0f;
 }