Exemple #1
0
    public void Update()
    {
        if (!IsEnabled)
        {
            return;
        }
        if (Input.GetKeyDown(_key))
        {
            Begin?.Invoke(this, _lastPosition = Input.mousePosition);
        }
        else if (Input.GetKey(_key))
        {
            Vector3 currentMousePosition = Input.mousePosition;
            if (_lastPosition != currentMousePosition)
            {
                Moved?.Invoke(this, currentMousePosition);
                _lastPosition = currentMousePosition;
            }

            Pressed?.Invoke(this, currentMousePosition);
        }
        else if (Input.GetKeyUp(_key))
        {
            Ended?.Invoke(this, Input.mousePosition);
            _lastPosition = Vector3.zero;
        }
    }
Exemple #2
0
        // do NOT use ConfigureAwait(false) on ProcessAsync()
        // often calls events which prints to forms in the UI context
        public async Task <StatusHandler> ProcessAsync(LibraryBook libraryBook)
        {
            Begin?.Invoke(this, libraryBook);

            try
            {
                {
                    var statusHandler = await DecryptBook.TryProcessAsync(libraryBook);

                    if (statusHandler.HasErrors)
                    {
                        return(statusHandler);
                    }
                }

                {
                    var statusHandler = await DownloadPdf.TryProcessAsync(libraryBook);

                    if (statusHandler.HasErrors)
                    {
                        return(statusHandler);
                    }
                }

                return(new StatusHandler());
            }
            finally
            {
                Completed?.Invoke(this, libraryBook);
            }
        }
Exemple #3
0
    /// <summary>
    /// 异步加载场景
    /// </summary>
    /// <param name="levelName">场景名称(不带扩展名)</param>
    /// <param name="url">指定场景url</param>
    /// <param name="begin">开始加载事件</param>
    /// <param name="failed">失败事件</param>
    /// <param name="loading">进度事件</param>
    /// <param name="finish">完成事件</param>
    public void LoadOTALevelAsync(string levelName, string url, Begin begin, Failed failed, Loading loading, Finished finish)
    {
        if (m_Loading)
        {
            EB.Debug.LogLoadLevel("[SceneRootEntry]LoadOTALevelAsync: Loading is in progress.");
            return;
        }

        OnBegin    = begin;
        OnFailed   = failed;
        OnFinished = finish;
        OnLoading  = loading;

        m_LevelAssetIndex = 0;
        m_Loading         = true;

        OnBegin?.Invoke();

        if (m_SceneRoot != null)
        {
            OnLoading?.Invoke(m_LevelAssets.Length, m_LevelAssets.Length);
            OnFinished?.Invoke(this);
            ClearLoading();
        }
        else
        {
            //加载相应的场景JSON配置信息
            GM.AssetManager.FetchSceneDescriptionFile(levelName, url, LoadedSceneDescription);
        }
    }
Exemple #4
0
 private void onBegin()
 {
     if (Begin != null)
     {
         Begin.Invoke();
     }
 }
Exemple #5
0
        /// <summary>
        /// Called when on rendering begin.
        /// </summary>
        /// <param name="context">The GPU execution context.</param>
        protected virtual void OnBegin(GPUContext context)
        {
            Begin?.Invoke(this, context);

            // Resize buffers
            if (Output)
            {
                Buffers.Size = Output.Size;
            }
        }
        /// <summary>
        /// Called when on rendering begin.
        /// </summary>
        protected virtual void OnBegin()
        {
            Begin?.Invoke(this);

            // Resize buffers
            if (Output)
            {
                Buffers.Size = Output.Size;
            }
        }
Exemple #7
0
        internal void OnBegin()
        {
            BeginEventArgs e = new BeginEventArgs
            {
                UserData = UserData,
            };

            Begin?.Invoke(this, e);
            UserData = e.UserData;
        }
        private static void Collection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (Begin != null)
            {
                Begin.Invoke();
            }

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                if (Add != null)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Add.Invoke(e.NewItems, e.NewStartingIndex);
                    });
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                if (Remove != null)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Remove.Invoke(e.OldItems, e.OldStartingIndex);
                    });
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                if (Reset != null)
                {
                    //IOS 下,Device.BeginInvokeOnMainThread 导至 Reset 重复触发,
                    // TODO Android 下不确定,待测
                    //Device.BeginInvokeOnMainThread(() => {
                    Reset.Invoke();
                    //});
                }
                break;

            case NotifyCollectionChangedAction.Move:
                break;

            case NotifyCollectionChangedAction.Replace:
                break;
            }

            if (Finished != null)
            {
                Finished.Invoke();
            }
        }
        // do NOT use ConfigureAwait(false) on ProcessAsync()
        // often calls events which prints to forms in the UI context
        public async Task <StatusHandler> ProcessAsync(LibraryBook libraryBook)
        {
            Begin?.Invoke(this, libraryBook);

            try
            {
                return(await ProcessItemAsync(libraryBook));
            }
            finally
            {
                Completed?.Invoke(this, libraryBook);
            }
        }
Exemple #10
0
        private IEnumerator Start()
        {
            _spawnBounds = FindObjectOfType <TerrainCollider>();

            for (var waveIndex = 0; waveIndex < _waves.Length; CurrentWave++)
            {
                var wave       = _waves[waveIndex];
                var structures = new Structure[0];
                while (structures.Length < wave.MinimumStructures)
                {
                    yield return(new WaitForSeconds(_timeBetweenWaves));

                    structures = FindObjectsOfType <Structure>()
                                 .Where(s => s.enabled)
                                 .ToArray();
                }

                Begin?.Invoke(CurrentWave);
                AnalyticsEvent.Custom("wave_start", new Dictionary <string, object> {
                    { "counter", CurrentWave }
                });

                var alive = wave.SpawnCount;

                void OnDied()
                {
                    alive--;
                }

                var start   = FindWaveStartPoint(structures);
                var enemies = new Enemy[wave.SpawnCount];
                for (var i = 0; i < enemies.Length; i++)
                {
                    enemies[i]       = Instantiate(_enemyTemplate, start, Quaternion.identity);
                    enemies[i].Died += OnDied;
                }

                yield return(new WaitUntil(() => alive == 0));

                End?.Invoke(CurrentWave);
                AnalyticsEvent.Custom("wave_complete", new Dictionary <string, object> {
                    { "counter", CurrentWave }
                });

                if (waveIndex < _waves.Length - 1)
                {
                    waveIndex++;
                }
            }
        }
Exemple #11
0
        public async Task <StatusHandler> ProcessAsync(LibraryBook libraryBook)
        {
            Begin?.Invoke(this, libraryBook);

            try
            {
                if (AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId))
                {
                    return new StatusHandler {
                               "Cannot find decrypt. Final audio file already exists"
                    }
                }
                ;

                var outputAudioFilename = await aaxToM4bConverterDecryptAsync(AudibleFileStorage.DownloadsInProgress, AudibleFileStorage.DecryptInProgress, libraryBook);

                // decrypt failed
                if (outputAudioFilename is null)
                {
                    return new StatusHandler {
                               "Decrypt failed"
                    }
                }
                ;

                // moves files and returns dest dir
                _ = moveFilesToBooksDir(libraryBook.Book, outputAudioFilename);

                var finalAudioExists = AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId);
                if (!finalAudioExists)
                {
                    return new StatusHandler {
                               "Cannot find final audio file after decryption"
                    }
                }
                ;

                return(new StatusHandler());
            }
            finally
            {
                Completed?.Invoke(this, libraryBook);
            }
        }
Exemple #12
0
    public void Update()
    {
        if (!IsEnabled)
        {
            return;
        }

        if (Input.GetKeyDown(_key))
        {
            Begin?.Invoke(this, EventArgs.Empty);
        }
        if (Input.GetKeyUp(_key))
        {
            Ended?.Invoke(this, EventArgs.Empty);
        }
        else if (Input.GetKey(_key))
        {
            Pressed?.Invoke(this, EventArgs.Empty);
        }
    }
Exemple #13
0
        public void Update()
        {
            if (!IsEnabled)
            {
                return;
            }

            // отложеный Begin
            if (Input.GetKeyDown(_key))
            {
                _startInput = Time.time + _delayBeforInput;
                _begin      = true;
            }


            if (Time.time > _startInput)
            {
                if (_begin)
                {
                    _begin         = false;
                    CursorPosition = Input.mousePosition;
                    Begin?.Invoke(this, EventArgs.Empty);
                }
                else if (Input.GetKey(_key))
                {
                    Vector3 currentCursorPosition = Input.mousePosition;
                    if (CursorPosition != currentCursorPosition)
                    {
                        CursorPosition = currentCursorPosition;
                        Moved?.Invoke(this, EventArgs.Empty);
                    }
                }
                else if (Input.GetKeyUp(_key))
                {
                    CursorPosition = Input.mousePosition;
                    Ended?.Invoke(this, EventArgs.Empty);
                    CursorPosition = Vector3.zero;
                }
            }
        }
Exemple #14
0
        // do NOT use ConfigureAwait(false) on ProcessAsync()
        // often calls events which prints to forms in the UI context
        public async Task <StatusHandler> ProcessAsync(LibraryBook libraryBook)
        {
            Begin?.Invoke(this, libraryBook);

            try
            {
                var aaxFilename = AudibleFileStorage.AAX.GetPath(libraryBook.Book.AudibleProductId);

                if (aaxFilename == null)
                {
                    return new StatusHandler {
                               "aaxFilename parameter is null"
                    }
                }
                ;
                if (!File.Exists(aaxFilename))
                {
                    return new StatusHandler {
                               $"Cannot find AAX file: {aaxFilename}"
                    }
                }
                ;
                if (AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId))
                {
                    return new StatusHandler {
                               "Cannot find decrypt. Final audio file already exists"
                    }
                }
                ;

                var outputAudioFilename = await aaxToM4bConverterDecrypt(aaxFilename, libraryBook);

                // decrypt failed
                if (outputAudioFilename == null)
                {
                    return new StatusHandler {
                               "Decrypt failed"
                    }
                }
                ;

                var destinationDir = moveFilesToBooksDir(libraryBook.Book, outputAudioFilename);

                var config = Configuration.Instance;
                if (config.RetainAaxFiles)
                {
                    var newAaxFilename = FileUtility.GetValidFilename(
                        destinationDir,
                        Path.GetFileNameWithoutExtension(aaxFilename),
                        "aax");

                    File.Move(aaxFilename, newAaxFilename);
                }
                else
                {
                    Dinah.Core.IO.FileExt.SafeDelete(aaxFilename);
                }

                var finalAudioExists = AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId);
                if (!finalAudioExists)
                {
                    return new StatusHandler {
                               "Cannot find final audio file after decryption"
                    }
                }
                ;

                return(new StatusHandler());
            }
            finally
            {
                Completed?.Invoke(this, libraryBook);
            }
        }
Exemple #15
0
        public void Do(ReplaceLogicParam param, IProgress <int> informer)
        {
            //処理対象のファイル一覧
            var targets = new List <string>();

            //ディレクトリを見つけた場合は、一度スタックにつめる
            var directories = new Stack <String>();

            directories.Push(param.RootDir);

            //ディレクトリの中身を確認
            while (directories.Count > 0)
            {
                // ファイルを取得し、ファイル名が処理対象のパターンを満たすか確認
                var directory = directories.Pop();
                foreach (var newFile in Directory.GetFiles(directory))
                {
                    // 隠しファイルは無視するか?
                    if (param.IgnoreHide)
                    {
                        var fileinfo = new FileInfo(newFile);
                        if (fileinfo.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }
                    }

                    // パターンのチェック
                    foreach (var filePtnRegex in param.FilePatternRegexes)
                    {
                        if (filePtnRegex.IsMatch(newFile))
                        {
                            // 処理対象
                            targets.Add(newFile);
                            break;
                        }
                    }
                }

                // ディレクトリを取得し、スタックに詰める
                foreach (var newDirectory in Directory.GetDirectories(directory))
                {
                    // 隠しファイルは無視するか?
                    if (param.IgnoreHide)
                    {
                        var dirInfo = new DirectoryInfo(newDirectory);
                        if (dirInfo.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }
                    }

                    // 一度スタックにつめる
                    directories.Push(newDirectory);
                }
            }

            // ファイルを1件ずつ置換処理開始
            long index = 1;
            long total = targets.Count;

            foreach (var target in targets)
            {
                try
                {
                    if (Begin != null)
                    {
                        Begin.Invoke(target);
                    }
                    TryReplace(target, param.Encoding, param.Keywords);
                    if (End != null)
                    {
                        End.Invoke();
                    }
                }
                catch (IOException ioe)
                {
                    if (ErrorEnd != null)
                    {
                        ErrorEnd.Invoke(ioe.Message);
                    }
                }

                informer.Report((int)(Int32.MaxValue * index / total));
                ++index;
            }
        }
 internal void OnBegin(GPUContext context)
 {
     Begin?.Invoke(this, context);
 }
Exemple #17
0
 protected void OnBegin(LibraryBook libraryBook)
 {
     Serilog.Log.Logger.Debug("Event fired {@DebugInfo}", new { Name = nameof(Begin), Book = libraryBook.LogFriendly() });
     Begin?.Invoke(this, libraryBook);
 }
 public void CloseWelcome()
 {
     TogglePanel(Panels.WelcomeClose);
     Begin?.Invoke(this, null);
 }
Exemple #19
0
 private void BeginCallback(PrimitiveType type)
 {
     Begin?.Invoke(this, new TessellatorBeginEventArgs(type));
 }