/// <summary>
    /// Performs Dash Action.
    /// </summary>
    public void Dash(Vector3 dashDirection)
    {
        if (IsMoving)
        {
            TriggerCoyoteTime = true;
            return;
        }

        // checks if you have enough moves left for a dash
        int movesLeft = AmountOfMoves - DashCost;

        if (movesLeft < 0)
        {
            AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.ChargingRejection, audioEvents, gameObject);
            StartCoroutine(ChangeTextColorRoutine());
            return;
        }

        attachToPlane.Detach();

        isDashing             = true;
        trailRenderer.enabled = true;
        previousPosition      = transform.position;
        AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.ChargedDash, audioEvents, gameObject);
        previousPosition = transform.position;
        Vector3 targetPosition = transform.position + dashDirection * DashDistance;

        StartCoroutine(MoveRoutine(targetPosition, DashDuration, DashCost));

        ResetDash();
    }
예제 #2
0
    /// <summary>
    /// Performs Dash Action if charged or Move otherwise.
    /// </summary>
    public void Release(Vector3 direction)
    {
        // Play Animation
        _anim.Release();

        // Play Sound
        AudioEvent.SendAudioEvent(
            IsDashing ? AudioEvent.AudioEventType.ChargedDash : AudioEvent.AudioEventType.Dash,
            _audioEvents,
            gameObject
            );

        // Initiate Vibration
        if (IsDashing)
        {
            Vibration.Vibrate(200);
        }

        // Perform Action
        _attachToPlane.Detach();
        StartCoroutine(MoveRoutine(
                           transform.position + direction * (IsDashing ? DashDistance: MoveDistance),
                           IsDashing ? DashDuration : MoveDuration
                           ));

        // Reset State
        IsCharging = false;
        IsDashing  = false;
        _dashTimer = 0;
    }
 private void DestroyPlane()
 {
     if (playerAttachedToThis)
     {
         playerAttached.Detach();
         Destroy(gameObject);
         //gameObject.SetActive(false);
     }
     else
     {
         Destroy(gameObject);
     }
     RemoveFromGameLoop();
 }