Ejemplo n.º 1
0
 public void Update()
 {
     lock (LOCK)
     {
         completes.Clear();
         foreach (var agent in Agents)
         {
             try
             {
                 if (agent.Update())
                 {
                     completes.Add(agent);
                 }
             }
             catch (Exception e)
             {
                 DebugConsole.Error("Fromto", "Update", e.StackTrace);
                 Agents.Remove(agent);
                 return;
             }
         }
         foreach (FromToAgent agent in completes)
         {
             Agents.Remove(agent);
             if (agent.OnComplete != null)
             {
                 agent.OnComplete();
             }
         }
     }
 }
Ejemplo n.º 2
0
 protected virtual void OnError(string error)
 {
     IsCompleted = true;
     Success     = false;
     DebugConsole.Error("Read [" + SourcePath + FilePath + "] faild!");
     OnReadCompleted.Dispatch(this);
     if (_loader != null)
     {
         _loader.DestroySelf();
     }
 }
Ejemplo n.º 3
0
        public PictureLoader(DownLoadAgent config)
            : base(config)
        {
            switch (config.cacheType)
            {
            case DownLoadAgent.LocalCacheType.File: _localCache = new LcTexture2DFile(cacheName); break;

            case DownLoadAgent.LocalCacheType.PlayerPrefs: DebugConsole.Error("Loader", "TextureLoader", "不能选择PlayerPrefs"); break;

            case DownLoadAgent.LocalCacheType.Memory:
                _localCache = new LcMemory <Texture2D>(cacheName); break;
            }
        }
Ejemplo n.º 4
0
    public override IEnumerator DoAsync()
    {
        using (WWW www = new WWW(SourcePath + FilePath))
        {
            yield return(www);

            if (www.isDone && string.IsNullOrEmpty(www.error))
            {
                OnCompleted(www.text, www.bytes);
            }
            else
            {
                DebugConsole.Error(www.error);
                OnError(www.error);
            }
        }
    }
    void OnWirteComplete(FileWriter writer)
    {
        if (writer.IsCompleted)
        {
            IncProgress(true);
#if UNITY_EDITOR
            Debug.Log("File [" + writer.FullFileName + "] update success!");
#else
            DebugConsole.Info("File [" + writer.FullFileName + "] update success!");
#endif
        }
        else
        {
#if UNITY_EDITOR
            Debug.LogError("File [" + writer.FullFileName + "] update faild!");
#else
            DebugConsole.Error("File [" + writer.FullFileName + "] update faild!");
#endif
        }
    }
Ejemplo n.º 6
0
    public void AddData(FileMd5Data data)
    {
        if (_dictrionary == null)
        {
            _dictrionary = new Dictionary <string, FileMd5Data>();
        }

        if (!_dictrionary.ContainsKey(data.FileName))
        {
            _dictrionary.Add(data.FileName, data);
        }
        else
        {
#if UNITY_EDITOR
            Debug.LogError("File:[" + data.FileName + "] already exist!");
#else
            DebugConsole.Error("File:[" + data.FileName + "] already exist!");
#endif
        }
    }
Ejemplo n.º 7
0
 public void Play()
 {
     try
     {
         if (state == ActionPlayerState.Pause)
         {
             return;
         }
         if (Current != null)
         {
             while ((this.PlayingAction = this.Current.GetNextAction()) != null)
             {
                 if (PlayingAction.CurrentPlayer != null && PlayingAction.CurrentPlayer != this && PlayingAction.State == ActionBase.ActionState.End)
                 {
                     DebugConsole.Warning("Action", "Play", "同一个动作对象在多个player中同步执行" + PlayingAction.CurrentPlayer.name + ":" + this.name);
                 }
                 state.SetState(ActionPlayerState.Play);
                 PlayingAction.CurrentPlayer = this;
                 PlayingAction.Play();
                 if (PlayingAction.State != ActionBase.ActionState.End)
                 {
                     state.SetState(ActionPlayerState.Wait);
                     return;
                 }
             }
         }
         state.SetState(ActionPlayerState.Idle);
         Environment.Clear();
         if (OnEnd != null)
         {
             OnEnd();
         }
     }
     catch (Exception e)
     {
         DebugConsole.Error("Action", "Play", e.StackTrace);
     }
 }