Exemplo n.º 1
0
 private void Dash(Vector2 direction)
 {
     if (IsDashing)
     {
         StopCoroutine(dashEndCoroutine);
     }
     IsDashing        = true;
     IsInjured        = false;
     rBody2D.velocity = Vector2.zero;
     rBody2D.AddForce(direction * forceMultiplier);
     rBody2D.gravityScale = 0;
     dashEndCoroutine     = StartCoroutine(StopDashingAfterTime());
     SetRotationToDirection(direction);
     ManulStatus.ModifyStamina(-ManulStatus.DashStaminaCost);
     dashEffect.Play();
 }
Exemplo n.º 2
0
        private void PlayerInput_OnSwipe(SwipeData data)
        {
            if (GameManager.GameIsPaused)
            {
                return;
            }
            if (!ManulStatus.CanDash())
            {
                return;
            }

            Vector2 direction = data.EndPosition - data.StartPosition;

            direction.Normalize();

            Dash(direction);
        }
Exemplo n.º 3
0
        private void Update()
        {
            if (GameManager.GameIsPaused)
            {
                return;
            }

            CurrentVelocity = rBody2D.velocity;

            CheckIsGrounded();
            if (IsGrounded)
            {
                ManulStatus.StaminaRegeneration(Time.deltaTime);
            }
            else
            {
                CheckIsFalling();
            }
        }
Exemplo n.º 4
0
        public void TakeHit(int damageAmount, Vector2 direction)
        {
            if (IsInjured)
            {
                return;
            }

            ManulStatus.ModifyHealth(-damageAmount);
            GameObject particle = Instantiate(takeHitParticlePrefab, transform.position, transform.rotation);

            Destroy(particle, 0.6f);

            rBody2D.velocity = Vector2.zero;
            if (IsGrounded)
            {
                rBody2D.AddForce(new Vector2(direction.x, 0.5f) * 400);
            }
            else
            {
                rBody2D.AddForce(direction * 400);
            }

            StartCoroutine(InjuredInvulnerability());
        }