Пример #1
0
    IEnumerator DashCo()
    {
        canRotate = false;
        isDashing = true;
        trail.SetEnabled(true);
        rigid.velocity = new Vector2(rigid.velocity.x, 0f);

        if (hMove == 0)
        {
            rigid.AddForce(new Vector2(dashDistance * direction * 2.5f, 0f), ForceMode2D.Impulse);
        }
        else
        {
            rigid.AddForce(new Vector2(dashDistance * direction, 0f), ForceMode2D.Impulse);
        }

        float gravity = rigid.gravityScale;

        rigid.gravityScale = 0;


        yield return(new WaitForSeconds(0.6f));

        hitbox.SetActive(true);
        canRotate          = true;
        isDashing          = false;
        rigid.gravityScale = 1;
        trail.SetEnabled(false);
    }
Пример #2
0
    void FixedUpdate()
    {
        if (GameState.Instance.gamestate == STATE.PLAYING)
        {
            isGround = Physics2D.OverlapCircle(posCheckGround.position, 0.05f, 1 << 8);
            if (isGround)
            {
                doubleJump = false;
                dashtrail.SetEnabled(false);
                effectRun.SetActive(true);
            }
            else
            {
                dashtrail.SetEnabled(true);
                effectRun.SetActive(false);
            }

            if (Input.GetMouseButtonDown(0) && isGround)
            {
                Jump(jumpForce);
            }
            if (Input.GetMouseButtonDown(0) && !isGround && !doubleJump)
            {
                Jump(jumpForce);
                doubleJump = true;
            }
            if (transform.position.y <= -6f)
            {
                MusicController.Instance.PlayDieSound();
                StartCoroutine(ActionTimer(0.5f, null, () => GameOver()));
                GameState.Instance.gamestate = STATE.GAMEOVER;
            }
        }
    }
Пример #3
0
    IEnumerator DashStart()
    {
        yield return(new WaitForSeconds(1f));

        trail.SetEnabled(true);

        yield return(new WaitForSeconds(2f));

        Vector2 dashTarget = new Vector2(player.position.x, rigid.position.y);
        Vector2 newPos     = Vector2.MoveTowards(rigid.position, dashTarget, 400 * Time.fixedDeltaTime);

        rigid.MovePosition(newPos);

        StartCoroutine(DashReset());
    }