Beispiel #1
0
 private void Update()
 {
     if (playerLight != null)
     {
         if (playerLight.GetRange() > dashCost)
         {
             playerLight.SetColor(Color.white);
             if (Input.GetKeyDown(KeyCode.LeftShift) && movement.CanMove && PlayerPrefs.GetInt("IsNavigator") == 1)
             {
                 movement.Dash(playerLight, playerLight.GetRange() - this.dashCost);
                 pv.RPC("Dash", RpcTarget.Others);
             }
         }
         else
         {
             playerLight.SetColor(new Color32(0xFB, 0xA5, 0xA5, 0xFF));
         }
     }
 }
Beispiel #2
0
    private IEnumerator DashCoroutine(Vector2 direction, PlayerLightRadius playerLight, float rangeTarget)
    {
        isDashing = true;
        playerLight.ShouldDecay = false;
        float lightDecayRate = (playerLight.GetRange() - rangeTarget) / dashDuration;

        Rigid.velocity = Vector2.zero;
        float   speed         = dashSpeed;
        Vector2 normDirection = direction.normalized;
        float   dashTime      = 0.0f;

        while (dashTime < dashDuration)
        {
            CharAnimator.SetInteger("State", IDLE);
            Rigid.velocity = speed * direction;
            speed          = Mathf.Abs(dashSpeed - (dashDecay * dashTime * dashTime)); // quadratic decay
            dashTime      += Time.deltaTime;
            playerLight.AdjustRange(-1 * Time.deltaTime * lightDecayRate);
            yield return(new WaitForFixedUpdate());
        }
        Rigid.velocity          = Vector2.zero;
        playerLight.ShouldDecay = true;
        isDashing = false;
    }