Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            if (Time.time > ReloadTime3P)
            {
                Reloading3P = false;
            }

            return;
        }

        if (CurrentTeam == 0)
        {
            if (SemiGunPrefabTeam2.activeSelf)
            {
                SemiGunPrefabTeam1.SetActive(true);
                SemiGunPrefabTeam2.SetActive(false);
            }

            if (AutoGunPrefabTeam2.activeSelf)
            {
                // AutoGunPrefabTeam1.SetActive(true);
                //   AutoGunPrefabTeam2.SetActive(false);
            }
            if (ShotgunPrefabTeam2.activeSelf)
            {
                ShotgunPrefabTeam1.SetActive(true);
                ShotgunPrefabTeam2.SetActive(false);
            }
        }

        if (CurrentTeam == 1)
        {
            if (SemiGunPrefabTeam1.activeSelf)
            {
                SemiGunPrefabTeam2.SetActive(true);
                SemiGunPrefabTeam1.SetActive(false);
            }

            if (AutoGunPrefabTeam1.activeSelf)
            {
                // AutoGunPrefabTeam2.SetActive(true);
                //   AutoGunPrefabTeam1.SetActive(false);
            }
            if (ShotgunPrefabTeam1.activeSelf)
            {
                ShotgunPrefabTeam2.SetActive(true);
                ShotgunPrefabTeam1.SetActive(false);
            }
        }


        if (isThrowingGrenade == true)
        {
            return;
        }
        else if (input.GetGrenadeKey() == true && grenadesLeft > 0)
        {
            ThrowGrenade(GetComponent <CharacterController3D>().movement);
        }
        else
        {
            if (((input.GetReloadKey() == true) || (GetActiveGun().roundsInMag < 1)) && GetActiveGun().roundsInMag < GetActiveGun().magSize&& GetActiveGun().reloading == false && GetActiveGun().AmmoLeft > 0)
            {
                float reloadTime = reloadTime = GetActiveGun().reloadTime *reloadFactor;
                GetActiveGun().reloading = true;


                if (isServer)
                {
                    RpcReload3P();
                }
                else
                {
                    CmdReload3P();
                }

                StartCoroutine(ReloadEffect(reloadTime));
                if (firstReload)
                {
                    firstReload = false;
                }
                else
                {
                    va.Reloading();
                }
            }
            else if (GetActiveGun().roundsInMag > 0 && !GetActiveGun().reloading)
            {
                GunHandler();
            }
            if (GetActiveGun().roundsInMag == 0 && GetActiveGun().AmmoLeft == 0 && input.GetMouse0())
            {
                va.OutOfAmmo();
            }
        }

        if (isRecoiling == true)
        {
            Recoil(GetActiveGun().RecoilY, GetActiveGun().RecoilX);
        }


        GetActiveGun().UpdateGun();
        aim.SetAutoAimSize(GetActiveGun().aimSize);


        ammoText.text    = GetActiveGun().GetAmmoState();
        grenadeText.text = grenadesLeft.ToString();
    }