コード例 #1
0
    public override void Update()
    {
        // base.Update();

        if (AttackSetNormal())
        {
            AttackLoop();
        }
        else if (AttackSetSwitch())     // Fixes infinite firing bug when switching and firing at the same time
        {
            SetFireAnimation(false);
        }

        // Rotate capsule (camera is rotated in PlayerController)
        if (snapRotationQueued)
        {
            SnapRotation();
        }
        transform.rotation = Quaternion.Euler(_rotation);

        if (!Managers.PauseMenu.paused)
        {
            Movement();
        }

        if (HasWeapon())
        {
            // Reload
            ReloadLoop();

            // Make sure active weapon is enabled
            switchController.ActiveWeaponController(meleeTrigger, grenadeTrigger);

            // Zoom
            ZoomLoop();

            // Check if anything in melee box
            if (AttackSetMelee())
            {
                if (CheckMeleeBox(meleeWeaponHitBoxOrigin, 2f) && meleeTrigger)
                {
                    anim.SetBool("Attack", true);
                }
                else
                {
                    anim.SetBool("Attack", false);
                }
            }

            // For managing grenade launcher animations
            if (AttackSetGrenade())
            {
                if (grenadeTrigger)
                {
                    anim.SetBool("Attack", true);
                }
                else
                {
                    anim.SetBool("Attack", false);
                }
            }

            // Update Animation Speed
            UpdateAnimSpeed();
        }

        ShieldDrainCheck();
        SetInteractable();
        CheckMovingPlatform();
    }