コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        piruet.set_health(piruet_timer);
        powerful.set_health(powerful_timer);
        heal.set_health(heal_timer);

        if ((movement.x != 0 || movement.y != 0))
        {
            prev_move = movement;
            animator.SetFloat("Atc_hor", prev_move.x);
            animator.SetFloat("Atc_vert", prev_move.y);
        }

        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");

        animator.SetFloat("Horizontal", movement.x);
        animator.SetFloat("Vertical", movement.y);
        animator.SetFloat("Speed", movement.sqrMagnitude);

        if (!Input.anyKey)
        {
            timer += Time.deltaTime;
        }
        else
        {
            animator.SetBool("Dance", false);
            timer = 0;
            if (Input.GetKeyDown(KeyCode.Space) && basic_attack_timer > basic_attack_time)
            {
                animator.SetTrigger("Basic_attack");
                active_animation = true;
                attacks.Basic_attack();
                basic_attack_timer = 0;
            }
            else if (Input.GetKeyDown(KeyCode.LeftControl) && piruet_timer >= piruet_cooldown)
            {
                animator.SetTrigger("Piruet");
                active_animation = true;
                attacks.Piruet();
                piruet_timer = 0;
            }
            else if (Input.GetKeyDown(KeyCode.LeftShift) && powerful_timer >= powerful_cooldown)
            {
                animator.SetTrigger("Powerful");
                active_animation = true;
                attacks.Powerful_attack();
                powerful_timer = 0;
            }
            else if (Input.GetKeyDown(KeyCode.LeftAlt) && heal_timer >= heal_cooldown)
            {
                animator.SetTrigger("Sword_up");
                active_animation = true;
                attacks.Heal();
                heal_timer = 0;
            }
        }

        if (timer > time_to_dance)
        {
            animator.SetBool("Dance", true);
        }

        if (basic_attack_timer < basic_attack_time)
        {
            basic_attack_timer += Time.deltaTime;
        }
        if (piruet_timer < piruet_cooldown)
        {
            piruet_timer += Time.deltaTime;
        }
        if (powerful_timer < powerful_cooldown)
        {
            powerful_timer += Time.deltaTime;
        }
        if (heal_timer < heal_cooldown)
        {
            heal_timer += Time.deltaTime;
        }

        if (basic_attack_timer > basic_attack_time && piruet_timer > piruet_time && powerful_timer > powerful_time && heal_timer > heal_time)
        {
            active_animation = false;
        }
    }