Example #1
0
    private void Update()
    {
        respawn = Input.GetButtonDown("Respawn");
        esc     = Input.GetKeyDown(KeyCode.Escape);
        if (esc && escMenu != null)
        {
            // Debug.Log("esc pressed");
            Time.timeScale = escMenu.isOn? 1:0;
            escMenu.ActivateAll(!escMenu.isOn);
        }
        if (respawn)
        {
            SpawnController.instance.Respawn();
            transform.position = originPos;
            GetFalseDamage(0.5f);
        }
        if (canControl && Time.timeScale > 0 && !specialControl)
        {
            horizontal = Input.GetAxisRaw("Horizontal");
            jump       = Input.GetButtonDown("Jump");
            dash       = Input.GetButtonDown("Dash");
            fire       = Input.GetButtonDown("Fire");
            stillfire  = Input.GetButton("Fire");
            fireUp     = Input.GetButtonUp("Fire");

            if (stillfire)
            {
                fireButtonTime += Time.deltaTime;
                if (fireButtonTime > 1.0f)
                {
                    mover.SetProjectileTime(1.2f);
                }
            }
        }
        mover.Move(horizontal, jump, dash, fireLock? false : fire);
        if (fireUp)
        {
            mover.SetProjectileTime(fireButtonTime);
            fireButtonTime = 0f;
        }

        animator.SetFloat("Speed", Mathf.Abs(horizontal));

        jump = false;
    }