コード例 #1
0
    private void AimWeapon(WeaponHandler weaponHandler)
    {
        if (Input.GetMouseButtonDown(1))
        {
            weaponHandler.Aim(true);
        }

        if (Input.GetMouseButtonUp(1))
        {
            weaponHandler.Aim(false);
        }
    }
コード例 #2
0
    // Handles weapon logic
    void WeaponLogic()
    {
        if (!weaponHandler)
        {
            return;
        }

        if (Input.GetAxis("Aiming") <= -0.25f || debugAim)
        {
            aiming = true;
        }
        else
        {
            aiming = false;
        }

        if (weaponHandler.currentWeapon)
        {
            weaponHandler.Aim(aiming);
            other.requireInputForTurn = !aiming;
        }

        weaponHandler.FingerOnTrigger(Input.GetButton(input.fireButton));

        /**
         * if (Input.GetButtonDown(input.dropWeaponButton)) {
         *  weaponHandler.DropCurrentWeapon();
         * } */

        if (Input.GetButtonDown(input.switchWeaponButton))
        {
            weaponHandler.SwitchWeapons();
        }
    }
コード例 #3
0
    private void ZoomInAndOut(WeaponHandler activeWeapon)
    {
        if (activeWeapon.weaponAim == WeaponAim.AIM)
        {
            // Zoom In
            if (Input.GetKeyDown(Keycode.MOUSE_RIGHTCLICK))
            {
                FPCameraAnimator.Play(AnimatorTags.ZOOM_IN);
                crosshair.SetActive(false);
            }

            // Zoom Out
            if (Input.GetKeyUp(Keycode.MOUSE_RIGHTCLICK))
            {
                FPCameraAnimator.Play(AnimatorTags.ZOOM_OUT);
                crosshair.SetActive(true);
            }
        }

        if (activeWeapon.weaponAim == WeaponAim.SELF_AIM)
        {
            // Aim
            if (Input.GetKeyDown(Keycode.MOUSE_RIGHTCLICK))
            {
                activeWeapon.Aim(true);
                isAiming = true;
            }

            // Un Aim
            if (Input.GetKeyUp(Keycode.MOUSE_RIGHTCLICK))
            {
                activeWeapon.Aim(false);
                isAiming = false;
            }
        }
    }
コード例 #4
0
    //Handles all weapon logic
    void WeaponLogic()
    {
        if (!weaponHandler)
        {
            return;
        }

        aiming = Input.GetButton(input.aimButton) || debugAim;

        weaponHandler.Aim(aiming);

        other.requireInputForTurn = !aiming;

        weaponHandler.FingerOnTrigger(Input.GetButton(input.fireButton));

        if (Input.GetButtonDown(input.reloadButton))
        {
            weaponHandler.Reload();
        }

        if (Input.GetButtonDown(input.dropWeaponButton))
        {
            weaponHandler.DropCurWeapon();
        }

        if (Input.GetButtonDown(input.switchWeaponButton))
        {
            weaponHandler.SwitchWeapons();
        }

        if (!weaponHandler.currentWeapon)
        {
            return;
        }

        weaponHandler.currentWeapon.shootRay = new Ray(TPSCamera.transform.position, TPSCamera.transform.forward);
    }
コード例 #5
0
ファイル: Weapon.cs プロジェクト: Hisuich/FPSProject
 public void Aim(bool aim)
 {
     isAiming = aim;
     weaponHandler.Aim(aim);
 }