Пример #1
0
        public void Stop()
        {
            Puase();

            mTime = 0;
            UpdaterNotice.RemoveSceneUpdater(this);
        }
Пример #2
0
        private void SendLoadedNotice()
        {
            if (m_LoadedNoticeInfo.IsSendIDAsNotice && !m_LoadedNoticeInfo.IsReadyNoticeSend)
            {
                if (m_LoadedNoticeInfo.ApplyDefaultNoticeType)
                {
                    mIDAsNotice = Pooling <Notice> .From();
                }
                else
                {
                    ApplyCustomNotice();
                }

                if (m_LoadedNoticeInfo.ApplyCallLate)
                {
                    UpdaterNotice.SceneCallLater(SendLoadedNoticeAndRelease);
                }
                else
                {
                    SendLoadedNoticeAndRelease(0);
                }
            }
            else
            {
            }
        }
Пример #3
0
        /// <summary>
        /// 解压功能(下载后直接解压压缩文件到指定目录)
        /// </summary>
        public void SaveZip(string ID, byte[] zipByte, string password)
        {
            Operation = ZipOperation.Decompress;
            ZipID     = ID;
            mPassword = password;

            //直接使用 将byte转换为Stream,省去先保存到本地在解压的过程
            Stream stream = new MemoryStream(zipByte);

            mZipInputStream = new ZipInputStream(stream);

            if (!string.IsNullOrEmpty(mPassword))
            {
                mZipInputStream.Password = mPassword;
            }
            else
            {
            }

            if (!Directory.Exists(SavePath))
            {
                Directory.CreateDirectory(SavePath);
            }
            else
            {
            }

            UpdaterNotice.AddUpdater(this);
        }
Пример #4
0
        public static void AddUpdater(IUpdate target)
        {
            UpdaterNotice notice = Pooling <UpdaterNotice> .From();

            notice.ParamValue = target;
            ShipDockConsts.NOTICE_ADD_UPDATE.Broadcast(notice);
            Pooling <UpdaterNotice> .To(notice);
        }
Пример #5
0
        public static void RemoveSceneUpdater(IUpdate target)
        {
            UpdaterNotice notice = Pooling <UpdaterNotice> .From();

            notice.ParamValue = target;
            ShipDockConsts.NOTICE_REMOVE_SCENE_UPDATE.Broadcast(notice);
            Pooling <UpdaterNotice> .To(notice);
        }
Пример #6
0
        public void Stop()
        {
            Pause();

            Time      = 0;
            IsStarted = false;
            IsPause   = false;

            UpdaterNotice.RemoveSceneUpdater(this);
        }
Пример #7
0
        public void Recreate(float totalTime, Action method, Func <bool> cancelCondition = default, int repeats = 0)
        {
            TotalRepeats   = repeats;
            TotalTime      = totalTime;
            Completion     = method;
            mRepeats       = repeats;
            Repeatable     = mRepeats > 0;
            mCancelChecker = cancelCondition;

            UpdaterNotice.RemoveSceneUpdater(this);
        }
Пример #8
0
 public void RemoveUpdate(Action <int> method)
 {
     if (mUpdaterMapper.ContainsKey(method))
     {
         MethodUpdater updater = mUpdaterMapper.GetValue(method, true);
         UpdaterNotice.RemoveSceneUpdater(updater);
         updater.Dispose();
     }
     else
     {
     }
 }
Пример #9
0
 /// <summary>移除一个需要刷帧的对象</summary>
 protected virtual void RemoveUpdate(INoticeBase <int> param)
 {
     mNoticeRemoved = param as UpdaterNotice;
     if (mNoticeRemoved != null ||
         mNoticeRemoved.ParamValue == null ||
         (mNoticeAdded.NotifcationSender != null && !mNoticeAdded.CheckSender(this)))
     {
         return;
     }
     mItemRemoved = mNoticeRemoved.ParamValue;
     RemoveUpdaterItem(0);
     mNoticeRemoved = null;
 }
Пример #10
0
 public void Start()
 {
     HasStart       = true;
     IsTimeCounting = true;
     IsStarted      = true;
     if (IsPause)
     {
         IsPause = false;
     }
     else
     {
         UpdaterNotice.AddSceneUpdater(this);
     }
 }
Пример #11
0
        private void OnRemoveItem(INoticeBase <int> param)
        {
            if (IsDisposed)
            {
                return;
            }

            UpdaterNotice notice = param as UpdaterNotice;
            IUpdate       target = notice.ParamValue;

            if (!mDeleted.Contains(target))
            {
                mDeleted.Add(target);
            }
        }
Пример #12
0
 public void AddUpdate(Action <int> method)
 {
     if (!mUpdaterMapper.ContainsKey(method))
     {
         MethodUpdater updater = new MethodUpdater
         {
             Update = method
         };
         mUpdaterMapper[method] = updater;
         UpdaterNotice.AddSceneUpdater(updater);
     }
     else
     {
     }
 }
Пример #13
0
        public void OnUpdate(int dTime)
        {
            Uncompress();

            if (IsCompleted)
            {
                UpdaterNotice.RemoveUpdater(this);

                FileStream.Close();
                FileStream.Dispose();

                mZipInputStream = default;
            }
            else
            {
            }
        }
Пример #14
0
 public void AddLateUpdate(Action method)
 {
     if (!mLateUpdaterMapper.ContainsKey(method))
     {
         MethodUpdater updater = new MethodUpdater
         {
             LateUpdate   = method,
             IsLateUpdate = true,
             IsUpdate     = false,
         };
         mLateUpdaterMapper[method] = updater;
         UpdaterNotice.AddSceneUpdater(updater);
     }
     else
     {
     }
 }
Пример #15
0
        public void Dispose()
        {
            mIsDisposed = true;
            ShipDockConsts.NOTICE_REMOVE_UPDATE.Remove(RemoveUpdate);
            ShipDockConsts.NOTICE_ADD_UPDATE.Remove(AddUpdate);

            Utils.Reclaim(ref mTicksList);
            Utils.Reclaim(ref mListDeleted);
            Utils.Reclaim(mTicksLater);
            Utils.Reclaim(mThreadTicks);

            mItem          = null;
            mItemAdded     = null;
            mItemRemoved   = null;
            mNoticeAdded   = null;
            mNoticeRemoved = null;
            mTicksLater    = null;
            mThreadTicks   = null;
        }
Пример #16
0
 private void OnStateFrameUpdater(IState state, bool isAdd)
 {
     if (isAdd)
     {
         if (!mStateUpdaters.IsContainsKey(state))
         {
             MethodUpdater updater = new MethodUpdater
             {
                 Update = state.UpdateState
             };
             mStateUpdaters[state] = updater;
             UpdaterNotice.AddSceneUpdater(updater);
         }
     }
     else
     {
         IUpdate updater = mStateUpdaters[state];
         UpdaterNotice.RemoveSceneUpdater(updater);
     }
 }
Пример #17
0
        private void OnSceneUpdateReady(INoticeBase <int> obj)
        {
            ShipDockConsts.NOTICE_SCENE_UPDATE_READY.Remove(OnSceneUpdateReady);

            MethodUpdater updater = ShipDockComponentManagerSetting.isMergeUpdateMode ?
                                    new MethodUpdater
            {
                Update = MergeComponentUpdateModeInScene
            } :
            new MethodUpdater
            {
                Update = SingleFrameComponentUpdateModeInScene
            };

            UpdaterNotice notice = Pooling <UpdaterNotice> .From();

            notice.ParamValue = updater;
            ShipDockConsts.NOTICE_ADD_SCENE_UPDATE.Broadcast(notice);
            Pooling <UpdaterNotice> .To(notice);
        }
Пример #18
0
 private void OnFSMFrameUpdater(IStateMachine fsm, bool isAdd)
 {
     if (mFSMUpdaters == default)
     {
         return;
     }
     if (isAdd)
     {
         MethodUpdater updater = new MethodUpdater
         {
             Update = fsm.UpdateState
         };
         mFSMUpdaters[fsm] = updater;
         UpdaterNotice.AddSceneUpdater(updater);
     }
     else
     {
         IUpdate updater = mFSMUpdaters[fsm];
         UpdaterNotice.RemoveSceneUpdater(updater);
     }
 }
Пример #19
0
        public void Clean()
        {
            MethodUpdater updater;
            int           max = mUpdaterMapper.Size;

            for (int i = 0; i < max; i++)
            {
                updater = mUpdaterMapper.GetValueByIndex(i);
                UpdaterNotice.RemoveSceneUpdater(updater);
                updater.Dispose();
            }
            max = mUpdaterMapper.Size;
            for (int i = 0; i < max; i++)
            {
                updater = mLateUpdaterMapper.GetValueByIndex(i);
                UpdaterNotice.RemoveSceneUpdater(updater);
                updater.Dispose();
            }
            mUpdaterMapper?.Clear();
            mLateUpdaterMapper?.Clear();
        }
Пример #20
0
 private void OnFSMFrameUpdater(IStateMachine fsm, bool isAdd)
 {
     if (isAdd)
     {
         if (!mFSMUpdaters.ContainsKey(fsm))
         {
             MethodUpdater updater = new MethodUpdater
             {
                 Update = fsm.UpdateState
             };
             mFSMUpdaters[fsm] = updater;
             UpdaterNotice.AddSceneUpdater(updater);
         }
         else
         {
         }
     }
     else
     {
         IUpdate updater = mFSMUpdaters.GetValue(fsm, true);
         UpdaterNotice.RemoveSceneUpdater(updater);
     }
 }
Пример #21
0
        private void OnServersInit()
        {
            Components = new ShipDockComponentManager
            {
                FrameTimeInScene = (int)(UnityEngine.Time.deltaTime * 1000)
            };

            MethodUpdater updater = ShipDockComponentManagerSetting.isMergeUpdateMode ?
                                    new MethodUpdater
            {
                Update = MergeComponentUpdateMode
            } :
            new MethodUpdater
            {
                Update = SingleFrameComponentUpdateMode
            };
            UpdaterNotice notice = Pooling <UpdaterNotice> .From();

            notice.ParamValue = updater;
            ShipDockConsts.NOTICE_ADD_UPDATE.Broadcast(notice);
            Pooling <UpdaterNotice> .To(notice);

            ShipDockConsts.NOTICE_SCENE_UPDATE_READY.Add(OnSceneUpdateReady);
        }
Пример #22
0
 private void ComponentUnitUpdateInScene(Action <int> target)
 {
     UpdaterNotice.SceneCallLater(target);
 }
Пример #23
0
 public void Start()
 {
     HasStart       = true;
     IsTimeCounting = true;
     UpdaterNotice.AddSceneUpdater(this);
 }
Пример #24
0
        private void DuringDecompress()
        {
            if (!IsCompleted)
            {
                try
                {
                    int    size;
                    int    fixSize = 2048;
                    byte[] data;
                    string fileName;
                    while ((mEnt = mZipInputStream.GetNextEntry()) != null)
                    {
                        if (!string.IsNullOrEmpty(mEnt.Name))
                        {
                            fileName = Path.Combine(SavePath, mEnt.Name);

                            #region Android
                            fileName = fileName.Replace('\\', '/');

                            "log:Start uncompress zip, file name is {0}".Log(fileName);

                            if (fileName.EndsWith(StringUtils.PATH_SYMBOL))
                            {
                                Directory.CreateDirectory(fileName);
                                continue;
                            }
                            else
                            {
                            }
                            #endregion

                            FileStream = File.Create(fileName);

                            size = fixSize;
                            data = new byte[size];
                            while (true)
                            {
                                size = mZipInputStream.Read(data, 0, data.Length);

#if LOG_UNPRESS_ZIP
                                bool isReadAll = size <= 0;
                                if (isReadAll)
                                {
                                    "log:File {0} uncompress end.".Log(fileName);
                                }
                                else
                                {
                                    "log:Zip stream read size {0}".Log(size.ToString());
                                }
#endif
                                if (size > 0)
                                {
                                    FileStream.Write(data, 0, size);//解决读取不完整情况
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                        else
                        {
                            "error".Log("Next Entry name is empty..");
                        }
                    }
                }
                catch (Exception e)
                {
                    "error:Zip exception {0}".Log(e.ToString());
                }
                finally
                {
                    if (FileStream != null)
                    {
                        FileStream.Close();
                        FileStream.Dispose();
                    }
                    else
                    {
                    }

                    if (mZipInputStream != null)
                    {
                        mZipInputStream.Close();
                        mZipInputStream.Dispose();
                    }
                    else
                    {
                    }

                    if (mEnt != null)
                    {
                        mEnt = null;
                    }
                    else
                    {
                    }

                    GC.Collect();
                    GC.Collect(1);

                    IsCompleted = true;
                    Operation   = ZipOperation.None;
                    UpdaterNotice.SceneCallLater((t) => { OnCompleted?.Invoke(); });
                }
            }
            else
            {
            }
        }