Exemple #1
0
 public void StepOver()
 {
     if (StepInto())
     {
         StepOutOf();
     }
     OnStep?.Invoke(this, EventArgs.Empty);
 }
Exemple #2
0
 public static void MainLoop()
 {
     while (Running)
     {
         Thread.Sleep(1000 / 60);
         OnStep?.Invoke(null, null);
     }
 }
Exemple #3
0
 /// <summary>
 /// 下载文件
 /// </summary>
 /// <returns></returns>
 public void DownFile()
 {
     Task.Run(() =>
     {
         if (_updateModel == null)
         {
             OnError?.Invoke("请先执行比较版本步骤");
             OnStep?.Invoke(UpdateStepEnum.Fail);
             return;
         }
         OnStep?.Invoke(UpdateStepEnum.DownFile);
         // 升级下载文件地址校验
         if (string.IsNullOrWhiteSpace(UpdateJsonAddress) || !_updateModel.DownFileAddress.MatchUrl())
         {
             OnError?.Invoke($"下载升级文件地址校验失败:{_updateModel.DownFileAddress}");
             OnStep?.Invoke(UpdateStepEnum.Fail);
             return;
         }
         _updateModel.DownFileSavePath = $"{DownFileSavePath}\\{Path.GetFileName(_updateModel.DownFileAddress)}";
         // 创建目录
         if (!Directory.Exists(DownFileSavePath))
         {
             Directory.CreateDirectory(DownFileSavePath);
         }
         // 验证证书
         ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true;
         // 下载
         var webClient = new WebClient();
         webClient.Headers.Add("User-Agent", "Mozilla / 5.0(compatible; MSIE 9.0; Windows NT 6.1; Trident / 5.0)");
         webClient.DownloadProgressChanged += (sender, e) =>
         {
             OnDownloadProgressChanged?.Invoke(e);
         };
         webClient.DownloadFileCompleted += (sender, e) =>
         {
             if (e.Error != null)
             {
                 OnError?.Invoke($"下载升级文件失败:{e.Error.Message} 地址:{_updateModel.DownFileAddress}");
                 OnStep?.Invoke(UpdateStepEnum.Fail);
                 return;
             }
             OnDownloadFileCompleted?.Invoke();
             if (IsSilent && IsExtract)
             {
                 // 解压文件
                 ExtractFile();
             }
             else
             {
                 // 删除文件
                 DeleteFile();
                 OnStep?.Invoke(UpdateStepEnum.Complete);
             }
         };
         // 开始下载
         webClient.DownloadFileAsync(new Uri(_updateModel.DownFileAddress), _updateModel.DownFileSavePath);
     });
 }
        public void Step(double seconds)
        {
            this.startTicks += TimeSpan.FromSeconds(seconds).Ticks;

            if (ElapsedTicks < 0)
            {
                SetTime(TimeSpan.Zero);
            }

            OnStep?.Invoke(this, EventArgs.Empty);
        }
        public void Restart()
        {
            startTicks = 0;

            if (sw.IsRunning)
            {
                sw.Restart();
            }
            else
            {
                sw.Reset();
            }

            OnStep?.Invoke(this, EventArgs.Empty);
        }
Exemple #6
0
    void OnPlayerMoved(Vector2 newPosition)
    {
        if (!IsLeader)
        {
            return;
        }

        if (newPosition == (Vector2)previousPosition && follower)
        {
            follower.ScatterCats();
            follower = null;
        }

        MoveCongaLine(new Vector3(newPosition.x, newPosition.y, -1));
        OnStep?.Invoke();
    }
Exemple #7
0
    public void OnAction(InputAction.CallbackContext context)
    {
        if (!context.started || !IsLeader || !follower)
        {
            return;
        }

        var last = FindLast();

        MoveCongaLine(last.targetPosition);

        IsLeader = false;
        follower.WillBeLeader = true;
        last.follower         = this;
        follower = null;
        isMoving = true;
        OnStep?.Invoke();
    }
Exemple #8
0
 /// <summary>
 /// 比较版本
 /// </summary>
 public void CompareVersion()
 {
     Task.Run(async() =>
     {
         OnStep?.Invoke(UpdateStepEnum.IsNeedUpdate);
         // 升级地址校验
         if (string.IsNullOrWhiteSpace(UpdateJsonAddress) || !UpdateJsonAddress.MatchUrl())
         {
             OnError?.Invoke($"升级配置地址校验失败:{UpdateJsonAddress}");
             OnStep?.Invoke(UpdateStepEnum.Fail);
             return;
         }
         // 获取升级Json文件并格式
         var updateString = await UpdateJsonAddress.HttpGetStringAsync();
         try
         {
             _updateModel = updateString.JsonDeserialize <UpdateModel>();
         }
         catch
         {
             OnError?.Invoke($"升级配置地址下载失败:{updateString}");
             OnStep?.Invoke(UpdateStepEnum.Fail);
             return;
         }
         // 版本号比较
         var nowVer = new Version(NowVersion);
         var newVer = new Version(_updateModel.Version);
         if (newVer.CompareTo(nowVer) > 0)
         {
             OnIsNeedUpdate?.Invoke(true, newVer);
             if (IsSilent)
             {
                 // 开始下载文件
                 DownFile();
             }
         }
         else
         {
             OnIsNeedUpdate?.Invoke(false, newVer);
             OnStep?.Invoke(UpdateStepEnum.Complete);
         }
     });
 }
Exemple #9
0
        private StepMode ProcessStep(object sender, DebugInformation e)
        {
            lock (_syncRoot)
            {
                if (_breakType == BreakType.Step && !BreakOnNextStatement)
                {
                    return(StepMode.None);
                }

                BreakOnNextStatement = false;

                if (this.OnStep != null)
                {
                    OnStep.Invoke(this, e);
                }
                _event.WaitOne();
                return(_stepMode);
            }
        }
Exemple #10
0
    void Update()
    {
        Vector3 velo = character.velocity;

        yVelo = velo.y;

        float deltaV        = new Vector2(velo.x, velo.z).magnitude;
        float deltaDistance = deltaV * Time.deltaTime;

        if (deltaV < THRESHOLD_SPEED)
        {
            bobDistance = FIRST_STEP_DISTANCE;
        }

        bobDistance -= deltaDistance;

        bobTime -= Time.deltaTime;

        if (bobDistance < 0 && character.isGrounded)
        {
            OnStep?.Invoke();

            bobTime     = bobDuration;
            bobDistance = bobAfterDistance;
        }

        float yTarget = character.velocity.y * 0.1f;

        if (bobTime > 0)
        {
            yTarget += bobHeight;
        }
        yTarget  = Mathf.Clamp(yTarget, -1, 0.1f);
        yTarget += startHeight;

        float y = Mathf.SmoothDamp(head.localPosition.y, yTarget, ref ySmoothVelo, headSmoothing);

        head.localPosition = new Vector3(0, y, 0);
    }
Exemple #11
0
        /// <summary>
        /// Handles the internal process of stepping.
        /// </summary>
        /// <param name="transition">The selected transition to handle.</param>
        private void StepInternal(IStateTransition transition)
        {
            if (transition == null)
            {
                throw new ArgumentNullException(nameof(transition), "The transition can not be null!");
            }

            if (transition.SourceState != CurrentState)
            {
                throw new ArgumentException("The transition's source isn't the current state!", nameof(transition));
            }

            if (!transition.HandlesSymbol(CurrentInputSymbol))
            {
                throw new ArgumentException("The transition can't handle the current input symbol!", nameof(transition));
            }

            CurrentState = transition.TargetState;

            ++CurrentInputIndex;

            OnStep?.Invoke();
        }
Exemple #12
0
        private void Start()
        {
            _selectors = transform.GetComponentsInChildren <BinarySelector>().ToList();

            foreach (var selector in _selectors)
            {
                selector.OnToggle = b =>
                {
                    var selectorId     = selector.name;
                    var selectorTypeId = selector.TypeId;
                    var step           = new Step(selectorId, selectorTypeId, b);
                    OnStep?.Invoke(step);
                };

                selector.Check = b =>
                {
                    var selectorId     = selector.name;
                    var selectorTypeId = selector.TypeId;
                    var step           = new Step(selectorId, selectorTypeId, b);
                    return(CheckStep(step));
                };
            }
        }
Exemple #13
0
 /// <summary>
 /// 解压文件
 /// </summary>
 public void ExtractFile()
 {
     Task.Run(() =>
     {
         if (_updateModel == null)
         {
             OnError?.Invoke("请先执行比较版本步骤");
             OnStep?.Invoke(UpdateStepEnum.Fail);
             return;
         }
         OnStep?.Invoke(UpdateStepEnum.ExtractFile);
         if (string.IsNullOrWhiteSpace(_updateModel.DownFileSavePath) || !File.Exists(_updateModel.DownFileSavePath))
         {
             OnError?.Invoke($"解压升级文件不存在:{_updateModel.DownFileSavePath}");
             OnStep?.Invoke(UpdateStepEnum.Fail);
             return;
         }
         try
         {
             // 解压
             var compressor = new SevenZipCompressor(null);
             compressor.Decompress(_updateModel.DownFileSavePath, DownFileExtractPath);
             OnExtractFiled?.Invoke();
             OnStep?.Invoke(UpdateStepEnum.Complete);
         }
         catch (Exception e)
         {
             OnError?.Invoke($"解压升级文件失败:{e.Message}");
             OnStep?.Invoke(UpdateStepEnum.Fail);
         }
         finally
         {
             // 删除文件
             DeleteFile();
         }
     });
 }
Exemple #14
0
    private void FixedUpdate()
    {
        OnStep?.Invoke();
        Time.timeScale = TimeScale;

        DecayHyperparameters();

        int action;

        if (Random.Range(0f, 1f) < ExplorationFactor)
        {
            action = Random.Range(0, 4);
        }
        else
        {
            action = QTable[currentState].ToList().IndexOf(QTable[currentState].Max());
        }

        var envResult = AgentMover.Move(action);

        if (envResult.reward == 1)
        {
            OnEpisodeComplete?.Invoke();
        }


        float oldQValue = QTable[currentState][action];

        var nextMax = QTable[envResult.state].Max();

        var newQValue = oldQValue + LearningRate * (envResult.reward + DiscountFactor * nextMax - oldQValue);

        QTable[currentState][action] = newQValue;

        currentState = envResult.state;
    }
Exemple #15
0
 public void Step()
 {
     value++; OnStep?.Invoke();
 }
Exemple #16
0
 public void Step()
 {
     OnStep?.Invoke(this, null);
 }
Exemple #17
0
 public void Step()
 {
     Emulator.Execute();
     OnStep?.Invoke(this, EventArgs.Empty);
 }
 public static void DebugProgress(string msg) => OnStep?.Invoke(msg);