Ejemplo n.º 1
0
    private IEnumerator DashCooldown()
    {
        dashOnCooldown = true;
        OnDash?.Invoke(dashCooldownTimer);
        yield return(new WaitForSeconds(dashCooldownTimer));

        dashOnCooldown = false;
    }
Ejemplo n.º 2
0
 public void Dash()
 {
     if (!CanDash())
     {
         return;
     }
     _damageReceiver.Invincible = true;
     _invincibleWaitTime.Wait();
     // _hasDashed = true;
     LastDash = Time.time;
     OnDash?.Invoke();
 }
Ejemplo n.º 3
0
        private void Dash(Vector3 direction)
        {
            dashCollider_.enabled = true;
            this.DoAfterDelay(kDashDuration, () => {
                dashCollider_.enabled = false;
            });

            Vector3 endPosition = Player_.Rigidbody.position + (kDashDistance * Player_.WeightedRatio() * direction);

            Controller_.MoveTo(Player_, endPosition, kDashDuration, EaseType.CubicEaseOut);
            AudioConstants.Instance.Dash.PlaySFX();
            OnDash.Invoke();
            OnPlayerDash.Invoke(Player_);
        }
Ejemplo n.º 4
0
        public async void TryDash()
        {
            if (_timeFromLastDash < _settings.DefaultCharacterSettings.DashRate ||
                !_playerMovement.CanMove)
            {
                return;
            }
            _timeFromLastDash = 0;
            OnDash?.Invoke();
            _playerMovement.BlockMovement(true);
            await RemoteDash();

            _playerMovement.BlockMovement(false);
        }
Ejemplo n.º 5
0
            private void PerformDash()
            {
                Vector3 forward = Controller.InputingMovement ? Controller.MoveVector.normalized : (PinouApp.Entity.Mode2D == false ? Forward : Forward2D.ToV3());

                voAgent = _data._dashVelocityOverride.StartVelictyOverride(references.RigidBody, forward);
                if (HasStats == true)
                {
                    voAgent.SetStatsSpeedFactor(Stats.EvaluateMovementsStat(EntityMovementsStat.Acceleration, 1f));
                }
                voAgent.OnAgentStop.Subscribe(OnVelocityOverrideStops);

                _lastDashTime = Time.time - LastDashClampedDuration + DashCooldown;
                OnDash.Invoke(master, forward);
            }
Ejemplo n.º 6
0
    private void Dash()
    {
        if (isCrouching)
        {
            return;
        }

        dashing = true;
        OnDash?.Invoke();
        dashTimer = dashCooldown;
        StartDash().OnComplete(() =>
        {
            StartCoroutine(StopDashAfterSeconds(dashDuration));
        });
    }
Ejemplo n.º 7
0
        /// <summary>
        ///     New Path subscribed event function.
        /// </summary>
        /// <param name="sender"><see cref="Obj_AI_Base" /> sender</param>
        /// <param name="args">New Path event data</param>
        private static void ObjAiHeroOnOnNewPath(Obj_AI_Base sender, GameObjectNewPathEventArgs args)
        {
            var hero = sender as Obj_AI_Hero;

            if (hero != null && hero.IsValid)
            {
                if (!DetectedDashes.ContainsKey(hero.NetworkId))
                {
                    DetectedDashes.Add(hero.NetworkId, new DashArgs());
                }
                if (args.IsDash)
                {
                    var path = new List <Vector2> {
                        hero.ServerPosition.ToVector2()
                    };
                    path.AddRange(args.Path.ToList().ToVector2());

                    DetectedDashes[hero.NetworkId] = new DashArgs
                    {
                        StartTick = Variables.TickCount - (Game.Ping / 2),
                        Speed     = args.Speed,
                        StartPos  = hero.ServerPosition.ToVector2(), Unit = sender,
                        Path      = path,
                        EndPos    = DetectedDashes[hero.NetworkId].Path.Last(),
                        EndTick   =
                            DetectedDashes[hero.NetworkId].StartTick
                            + (int)
                            (1000
                             * (DetectedDashes[hero.NetworkId].EndPos.Distance(
                                    DetectedDashes[hero.NetworkId].StartPos)
                                / DetectedDashes[hero.NetworkId].Speed)),
                        Duration =
                            DetectedDashes[hero.NetworkId].EndTick
                            - DetectedDashes[hero.NetworkId].StartTick
                    };

                    OnDash?.Invoke(MethodBase.GetCurrentMethod().DeclaringType, DetectedDashes[hero.NetworkId]);
                }
                else
                {
                    DetectedDashes[hero.NetworkId].EndTick = 0;
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     New Path subscribed event function.
        /// </summary>
        /// <param name="sender"><see cref="Obj_AI_Base" /> sender</param>
        /// <param name="args">New Path event data</param>
        private static void EventDash(Obj_AI_Base sender, GameObjectNewPathEventArgs args)
        {
            var hero = sender as AIHeroClient;

            if (hero == null || !hero.IsValid)
            {
                return;
            }

            if (!DetectedDashes.ContainsKey(hero.NetworkId))
            {
                DetectedDashes.Add(hero.NetworkId, new DashArgs());
            }

            if (args.IsDash)
            {
                var path = new List <Vector2> {
                    hero.ServerPosition.ToVector2()
                };
                path.AddRange(args.Path.ToList().ToVector2());

                DetectedDashes[hero.NetworkId].Unit      = sender;
                DetectedDashes[hero.NetworkId].Path      = path;
                DetectedDashes[hero.NetworkId].Speed     = args.Speed;
                DetectedDashes[hero.NetworkId].StartPos  = hero.ServerPosition.ToVector2();
                DetectedDashes[hero.NetworkId].StartTick = Variables.TickCount - (Game.Ping / 2);
                DetectedDashes[hero.NetworkId].EndPos    = path.Last();
                DetectedDashes[hero.NetworkId].EndTick   = DetectedDashes[hero.NetworkId].StartTick
                                                           + (int)
                                                           (1000
                                                            * (DetectedDashes[hero.NetworkId].EndPos.Distance(
                                                                   DetectedDashes[hero.NetworkId].StartPos)
                                                               / DetectedDashes[hero.NetworkId].Speed));
                DetectedDashes[hero.NetworkId].Duration = DetectedDashes[hero.NetworkId].EndTick
                                                          - DetectedDashes[hero.NetworkId].StartTick;

                OnDash?.Invoke(MethodBase.GetCurrentMethod().DeclaringType, DetectedDashes[hero.NetworkId]);
            }
            else
            {
                DetectedDashes[hero.NetworkId].EndTick = 0;
            }
        }