Esempio n. 1
0
 private void HandleProvideAccessTokenComplete (bool error = false)
 {
     IsError = error;
     IsDone = true;
     if (OnDone != null)
         OnDone.Invoke(this);
 }
Esempio n. 2
0
    public void ApplyTimeDelta(float delta)
    {
        if (_elementsInProgress.Count == 0)
        {
            return;
        }

        var inProgress = _elementsInProgress.Peek();

        inProgress.ApplyDelta(delta);

        if (OnTimeProductionChange != null)
        {
            OnTimeProductionChange.Invoke(inProgress);
        }

        if (inProgress.NormalizedProductionTime >= 1)
        {
            _elementsInProgress.Dequeue();
            if (OnProductionChange != null)
            {
                OnProductionChange.Invoke();
            }
            if (OnDone != null)
            {
                OnDone.Invoke(inProgress.Element);
            }
        }
    }
Esempio n. 3
0
 private void OnResourceDone(Resource res)
 {
     if (_loadingList.Count > 0 && _loadingList.First.Value == res)
     {
         while (_loadingList.Count > 0 && _loadingList.First.Value.isDone)
         {
             Resource first = _loadingList.First.Value;
             _loadingList.RemoveFirst();
             if (OnDone != null)
             {
                 OnDone.Invoke(first);
             }
         }
     }
     LoadNext();
     //bool succ = _loadingList.Remove(res);
     //if (succ)
     //{
     //    if (OnDone != null)
     //    {
     //        OnDone.Invoke(res);
     //    }
     //}
     //LoadNext();
 }
Esempio n. 4
0
 /**
  * Call when command function has finished
  **/
 protected void finish()
 {
     if (onDoneListener != null)
     {
         onDoneListener.Invoke();
     }
 }
Esempio n. 5
0
        void Play()
        {
            _timer = new ObservableTimer(_options.Duration);

            _timer.Progress += percentage => {
                float t   = _isBackwards ? (1f - percentage) : percentage;
                float cur = _options.GetCurrent(t);

                Current?.Invoke(cur);
            };

            _timer.OnDone += () => {
                if (_options.Count == -1)
                {
                    Switch();
                }
                else
                {
                    ++_counter;
                    if (_counter >= _options.Count)
                    {
                        _timer = null;

                        float cur = _options.GetCurrent(_isBackwards ? 0f : 1f);
                        Current?.Invoke(cur);

                        OnDone?.Invoke();
                    }
                    else
                    {
                        Switch();
                    }
                }
            };
        }
Esempio n. 6
0
        private void HandleWebRequestDone(AsyncOperation requestYeild)
        {
            if (webRequest.responseCode == GoogleDriveSettings.UNAUTHORIZED_RESPONSE_CODE)
            {
                HandleUnauthorizedResponse();
                return;
            }

            Error = webRequest.error;

            HandleResponseData(webRequest.downloadHandler);

            if (IsError)
            {
                Debug.LogError("UnityGoogleDrive: " + Error);
            }

            IsDone = true;

            if (OnDone != null)
            {
                OnDone.Invoke(ResponseData);
            }

            webRequest.Dispose();
        }
Esempio n. 7
0
    private IEnumerator MoveCoroutine()
    {
        isMoving = true;

        var previousTile = Maybe.None <MovementTile>();

        while (!path.ReachedEndPoint())
        {
            var nextPoint = path.Next();

            transform.up = nextPoint - transform.position;

            var nextTile = gridEngine.MovementGrid.GetTileAt(nextPoint);


            var calculatedSpeed = nextTile.Map(tile => tile.MovementCost)
                                  .Map(CalculateSpeedPenalty)
                                  .ValueOr(MoveSpeed);

            while (transform.position != nextPoint)
            {
                transform.position = Vector3.MoveTowards(transform.position, nextPoint, calculatedSpeed * Time.deltaTime);

                yield return(new WaitForEndOfFrame());
            }

            nextTile.MatchSome(tile => tile.Block());
            previousTile.MatchSome(tile => tile.Unblock());
            previousTile = nextTile;
        }

        OnDone?.Invoke();

        isMoving = false;
    }
Esempio n. 8
0
        public bool Update(float dt)
        {
            if (_lerpers.Count > 0)
            {
                TInterpolation peek     = _lerpers.Peek();
                bool           updating = peek.Run(dt);
                if (updating)
                {
                    TType cur = peek.Lerp();
                    // trigger the global lerp event
                    OnLerp?.Invoke(cur);
                }
                else
                {
                    _lerpers.Dequeue();
                    // update progress
                    Progress.Value.Add();
                    Progress.Broadcast();
                    // broadcast done if no more item in the queue
                    if (_lerpers.Count == 0)
                    {
                        OnDone?.Invoke();
                    }
                }

                return(true);
            }

            return(false);
        }
Esempio n. 9
0
        private IEnumerator Wrapper(IEnumerator target)
        {
            bool didComplete = false;

            try
            {
                while (target.MoveNext())
                {
                    if (target.Current is Cancelled)
                    {
                        OnCancelled?.Invoke();
                        yield break;
                    }

                    yield return(target.Current);
                }

                didComplete = true;
            }
            finally
            {
                if (didComplete)
                {
                    OnSuccessful?.Invoke();
                }
            }
            OnDone?.Invoke();
        }
Esempio n. 10
0
    private IEnumerator MoveCoroutine(Path path)
    {
        isMoving = true;

        while (!path.ReachedEndPoint())
        {
            var nextPoint = path.Next();

            transform.up = nextPoint - transform.position;

            while (transform.position != nextPoint)
            {
                transform.position = MoveTowards(nextPoint, MoveSpeed);

                yield return(new WaitForEndOfFrame());
            }
        }

        OnDone?.Invoke();

        isMoving = false;

        Vector3 MoveTowards(Vector3 nextPoint, float moveSpeed)
        {
            return(Vector3.MoveTowards(transform.position, nextPoint, moveSpeed * Time.deltaTime));
        }
    }
Esempio n. 11
0
        void _doDriveProcessing(string drive)
        {
            Working = true;
            try
            {
                bool isDrive = false;
                foreach (var d in DriveInfo.GetDrives())
                {
                    if (d.IsReady && d.RootDirectory.FullName.ToLower() == drive.ToLower())
                    {
                        isDrive = true;
                        break;
                    }
                }
                if (isDrive)
                {
                    Logger.WriteLine("Starting autocopier for " + drive);
                    var           files  = listFiles(drive);
                    List <string> target = new List <string>();
                    foreach (var word in SearchWords)
                    {
                        target.AddRange(files.Where(x => x.ToLower().Contains(word.ToLower())));
                    }
                    target = target.Distinct().ToList();

                    Dictionary <string, string> results = new Dictionary <string, string>();

                    foreach (var file in target)
                    {
                        string newFile = copyFile(file);
                        if (string.IsNullOrEmpty(newFile) == false)
                        {
                            results.Add(file, newFile);
                        }
                    }
                    if (results.Count > 0)
                    {
                        string       json       = JsonConvert.SerializeObject(results, Formatting.Indented);
                        string       reportPath = Path.Combine(SaveLocation, "_file_flags_" + Guid.NewGuid().ToString() + ".bin");
                        StreamWriter writer     = new StreamWriter(reportPath);
                        writer.Write(json);
                        writer.Close();
                        Logger.WriteLine("Auto copier saved " + results.Count + " file" + (results.Count == 1 ? string.Empty : "s"));
                    }
                    else
                    {
                        Logger.WriteLine("No files matching search words were found.");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLine("Auto copier error:" + Environment.NewLine + ex.ToString());
            }
            finally
            {
                Working = false;
                OnDone?.Invoke(this, EventArgs.Empty);
            }
        }
Esempio n. 12
0
 private void HandleRequestDone(TResponse responseData)
 {
     GoogleDriveRequest.OnDone -= HandleRequestDone;
     if (OnDone != null)
     {
         OnDone.Invoke(responseData);
     }
 }
 private void HandleRefreshComplete(bool error = false)
 {
     IsError = error;
     IsDone  = true;
     if (OnDone != null)
     {
         OnDone.Invoke(this);
     }
 }
Esempio n. 14
0
        private void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            //unzip
            ZipFile.ExtractToDirectory(mapZip, mapDir);
            File.Delete(mapZip);
            Map map = new Map();

            map.Load(mapJson);
            OnDone?.Invoke(this, map);
        }
Esempio n. 15
0
    private Func <float>[] DoneFunctions()
    {
        return(new Func <float>[] {
            () => Duration,
            () => {
                OnDone?.Invoke();

                return 0f;
            }
        });
    }
        private void btnOk_Click(object sender, EventArgs e)
        {
            Vehicle retVehicle = GetModifiedVehicle();

            if (retVehicle == null)
            {
                return;
            }

            OnDone?.Invoke(retVehicle);

            Close();
        }
Esempio n. 17
0
        private void OnAuthentication(string response, string schema)
        {
            Debug.Log("OnAuthentication: " + response + ", " + schema);
            var arguments = response.Substring(response.IndexOf(tokenArgName, StringComparison.InvariantCultureIgnoreCase)).Split('&').Select(q => q.Split('=')).ToDictionary(q => q.FirstOrDefault(), q => q.Skip(1).FirstOrDefault());

            if (arguments.ContainsKey(tokenArgName))
            {
                authorizationCode = arguments[tokenArgName];
            }
            OnDone?.Invoke(this);
            IsDone  = true;
            IsError = schema.Contains(cancelUri);
        }
Esempio n. 18
0
 public void Finish()
 {
     OnDone?.Invoke(this);
     _animator.SetTrigger(AnimatorConstants.kFinish);
     if (_state == State.Valid)
     {
         _validParticles.Play();
     }
     else
     {
         _invalidParticles.Play();
     }
     _isFinished = true;
 }
Esempio n. 19
0
    private void OnCompleteDrawingHandler()
    {
        if (_model.Points.Count > 2)
        {
            List <Vector3> worldPoints = new List <Vector3>();
            foreach (var point in _model.Points)
            {
                Vector3 worldPosition = ToWorldPosition(point);

                worldPoints.Add(worldPosition);
            }
            Clear();
            gameObject.SetActive(false);
            OnDone?.Invoke(worldPoints);
        }
    }
Esempio n. 20
0
            public void Run()
            {
                bool ok;

                try
                {
                    ok = RunCommand(executable, commandline, workingdir, timeout);
                }
                catch
                {
                    ok = false;
                    Log.Error("Caught unhandled exception in async process -- supressing so that we don't bring down Visual Studio");
                }

                callback?.Invoke(ok, callbackArg);
            }
Esempio n. 21
0
        public static bool Run(string executable, string commandline, string workingdir, OnDone callback, object callbackArg)
        {
            int timeout = 1000;

            if (!RunCommand(executable, commandline, workingdir, timeout))
            {
                Log.Debug("Failed to run immediate (process hung?), trying again on a remote thread: " + commandline);
                return(Schedule(executable, commandline, workingdir, callback, callbackArg));
            }
            else
            {
                callback?.Invoke(true, callbackArg);
            }

            return(true);
        }
Esempio n. 22
0
            /// <summary>
            ///     Notifies all listeners that this event has finished
            /// </summary>
            /// <param name="result"></param>
            public void Finish(object result = null)
            {
                if (_isFinished)
                {
                    return;
                }

                _isFinished = true;
                Result      = result;

                if (OnDone != null)
                {
                    OnDone.Invoke(this);
                }

                // Remove listeners
                OnDone = null;
            }
Esempio n. 23
0
        /// <summary>
        /// Updates and performs OnLerp automagically.
        /// </summary>
        public bool Run(float dt)
        {
            if (Update(dt))
            {
                T cur = Lerp();
                OnLerp?.Invoke(cur);

                bool stillUpdating = null != _timer;

                if (!stillUpdating)
                {
                    OnDone?.Invoke();
                }

                return(stillUpdating);
            }

            return(false);
        }
Esempio n. 24
0
        private async Task SaveAsync()
        {
            IsLoading = true;

            try
            {
                OnSave?.Invoke(true);

                using (Stream source = File.OpenRead(TempFilePath))
                {
                    await _storage.WriteAsync(SelectedBlob, source);
                }

                OnDone?.Invoke(true);
            }
            finally
            {
                IsLoading = false;
            }
        }
Esempio n. 25
0
        IEnumerator SpawnStar()
        {
            yield return(new WaitForSeconds(Delay));

            GameObject go = PrefabController.Instance.GetPrefabInstance(PrefabType.Star);

            go.transform.localScale = new Vector3(20, 20, 20);
            go.transform.position   = UnityEngine.Random.insideUnitSphere * Radius;
            go.GetComponent <Star>().Appear();
            _spawned++;

            if (_spawned == Amount)
            {
                Callback?.Invoke();
                OnDone?.Invoke();
            }
            else
            {
                MB.StartCoroutine(SpawnStar());
            }
        }
Esempio n. 26
0
            public bool UpdateTimer(float dt)
            {
                if (null == _timer)
                {
                    return(false);
                }

                bool updating = _timer.UpdateTimer(dt);

                if (updating)
                {
                    Progress?.Invoke(_timer.GetPercentage());
                }
                else
                {
                    _timer = null;

                    Progress?.Invoke(1f);
                    OnDone?.Invoke();
                }

                return(updating);
            }
Esempio n. 27
0
 void Done()
 {
     isDone = true;
     OnDone?.Invoke(this);
 }
 private void OnFinished()
 {
     OnDone?.Invoke();
 }
Esempio n. 29
0
 void Done()
 {
     OnDone?.Invoke(this, OutputFile);
 }
Esempio n. 30
0
 protected virtual void OnDoneCaller()
 {
     OnDone?.Invoke(this);
 }