Beispiel #1
0
    void HandleAnimations()
    {
        playerAnimations.Movement(charController.velocity.magnitude);
        playerAnimations.PlayerJump(charController.velocity.y);
        if (is_crouching && charController.velocity.magnitude > 0f)
        {
            playerAnimations.PlayerCrouchWalk(charController.velocity.magnitude);
        }
        //shooting stuffz
        if (isShooting.value == 1)
        {
            if (Input.GetMouseButtonDown(0) && Time.time > nextTimeToFire)
            {
                nextTimeToFire = Time.time + 1f / fireRate;
                if (is_crouching)
                {
                    playerAnimations.Shoot(false);
                }
                else
                {
                    playerAnimations.Shoot(true);
                }

                if (isLocalPlayer)
                {
                    current_Weapon.Shoot();
                    if (isFpsActive)
                    {
                        current_hands_Weapon.Shoot();
                    }
                }
                else
                {
                    current_Weapon.Shoot();
                    if (isFpsActive)
                    {
                        current_hands_Weapon.Shoot();
                    }
                }
            }
        }



        if (Input.GetKeyDown(KeyCode.R))
        {
            playerAnimations.Reload();
            reloadNoification.transform.localScale = Vector3.zero;
            reloadNoification.GetComponent <Animator>().enabled = false;
            isShooting.value = 1;
            if (isFpsActive)
            {
                current_hands_Weapon.Reload();
            }
            PlayerPrefs.SetInt("DEAGLE", 20);
            PlayerPrefs.SetInt("AK47", 20);
            PlayerPrefs.SetInt("M4A1", 20);
        }
    }
    void HandleAnimation()
    {
        playerAnimation.Movement(charController.velocity.magnitude);
        playerAnimation.PlayerJump(charController.velocity.y);
        if (is_Crouching && charController.velocity.magnitude > 0f)
        {
            playerAnimation.PlayerCrouchWalk(charController.velocity.magnitude);
        }
        //SHotting
        if (Input.GetMouseButtonDown(0) && Time.time > nextTimeToFire)
        {
            nextTimeToFire = Time.time + 1f / fireRate;

            if (is_Crouching)
            {
                playerAnimation.Shoot(false);
            }
            else
            {
                playerAnimation.Shoot(true);
            }

            current_Weapon.Shoot();
            current_Hands_Weapon.Shoot();
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            playerAnimation.ReloadGun();
            current_Hands_Weapon.Reload();
        }
    }
Beispiel #3
0
    void Shooting()
    {
        if (Input.GetMouseButtonDown(0) && Time.time > nextTimeToFire)
        {
            nextTimeToFire = Time.time + 1f / fireRate;

            shooter.Shoot();
            anims.Shoot(!crouching);
            weapon.Shoot();
            handsWeapon.Shoot();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            anims.Reload();
            handsWeapon.Reload();
        }
    }
Beispiel #4
0
    private void HandleAnimation()
    {
        playerAnimation.Movement(charController.velocity.magnitude);
        playerAnimation.PlayerJump(charController.velocity.y);

        if (isCrouching && charController.velocity.magnitude > 0f)
        {
            playerAnimation.PlayerCrouchWalk(charController.velocity.magnitude);
        }

        #region HandleShootingInformation

        if (currentWeapon.name == "deagle")
        {
            if (Input.GetMouseButtonDown(0) && Time.time > nextTimeToFire)
            {
                if (currentWeapon.bulletLeft > 0 && !isReloading)
                {
                    nextTimeToFire = Time.time + 1f / fireRate;
                    playerAnimation.Shoot(!isCrouching);
                    currentWeapon.Shoot();
                    currentHandsWeapon.Shoot();
                }
            }
        }
        else
        {
            if (Input.GetMouseButton(0) && Time.time > nextTimeToFire)
            {
                if (currentWeapon.bulletLeft > 0 && !isReloading)
                {
                    nextTimeToFire = Time.time + 1f / fireRate;
                    playerAnimation.Shoot(!isCrouching);
                    currentWeapon.Shoot();
                    currentHandsWeapon.Shoot();
                }
            }
        }


        if (Input.GetKeyDown(KeyCode.R))
        {
            if (!isReloading)
            {
                isReloading      = true;
                reloadTimeRemain = currentWeapon.reloadTime;
                if (currentWeapon.bulletCapacity >= currentWeapon.cartridge - currentWeapon.bulletLeft)
                {
                    currentWeapon.bulletCapacity -= currentWeapon.cartridge - currentWeapon.bulletLeft;
                    currentWeapon.bulletLeft      = currentWeapon.cartridge;
                }
                else if (currentWeapon.bulletCapacity > 0)
                {
                    currentWeapon.bulletLeft = currentWeapon.bulletCapacity;
                }
                else
                {
                    print("Ammo empty");
                }

                playerAnimation.ReloadGun();
                currentHandsWeapon.Reload();
            }
        }

        #endregion
    }