コード例 #1
0
    public void Awake()
    {
        equippedGun = GetComponent <EquippedGun>();
        if (typeIndex == 1)
        {
            currentGun = allGuns.primaryGuns[gunIndex];
        }
        else
        {
            currentGun = allGuns.secondaryGuns[gunIndex];
        }

        equippedGun.UpdateGun(currentGun);
    }
コード例 #2
0
 public void UpdateGun(BaseGunDefinition newGun)
 {
     if (newGun == null)
     {
         throw new Exception("Gun is null. Good luck you f*****g idiot");
     }
     currentGun       = newGun;
     usingAds         = false;
     continuousFire   = 0;
     rateOfFire       = 1.0f / currentGun.firingRate;
     doingAction      = false;
     currentShootMode = currentGun.defaultShootMode;
     currentSightMode = SightType.Normal;
     currentAcc       = currentGun.maxAccuracy;
 }
コード例 #3
0
    public IEnumerator GunChange(BaseGunDefinition newGunDef, float timer)
    {
        if (isReloading)
        {
            StopCoroutine(reloadCoroutine);
        }

        if (isScoping)
        {
            StopCoroutine(scopeCoroutine);
        }

        isReloading = false;
        actionTime  = 0;

        doingAction = true;
        actionTime  = timer;
        SetSlider(timer);

        yield return(new WaitForSeconds(timer));

        UpdateGun(newGunDef);
        doingAction = false;
    }
コード例 #4
0
    private void ChangeWeapon(bool next, float n)
    {
        if (n == 1)
        {
            if (x != null)
            {
                StopCoroutine(x);
                equippedGun.doingAction = false;
            }
            float time = 1f;
            if (currentGun.weaponType == WeaponType.Primary)
            {
                time = 2f;
                if (allGuns.primaryGuns.Count > gunIndex)
                {
                    gunIndex++;
                }
                else
                {
                    gunIndex = 0;
                }

                currentGun = allGuns.primaryGuns[gunIndex];
                x          = StartCoroutine(equippedGun.GunChange(currentGun, time));
            }
            else if (currentGun.weaponType == WeaponType.Secondary)
            {
                if (allGuns.secondaryGuns.Count > gunIndex)
                {
                    gunIndex++;
                }
                else
                {
                    gunIndex = 0;
                }

                currentGun = allGuns.secondaryGuns[gunIndex];
                x          = StartCoroutine(equippedGun.GunChange(currentGun, time));
            }
            return;
        }

        if (x != null)
        {
            StopCoroutine(x);
            equippedGun.doingAction = false;
        }
        if (next)
        {
            typeIndex++;
        }
        else
        {
            typeIndex--;
        }

        if (typeIndex > 2)
        {
            typeIndex = 1;
        }
        else if (typeIndex <= 0)
        {
            typeIndex = 2;
        }

        if (typeIndex == 1)
        {
            currentGun = allGuns.primaryGuns[gunIndex];
        }
        else
        {
            currentGun = allGuns.secondaryGuns[gunIndex];
        }

        var timer = typeIndex == 1 ? 2 : 1;

        x = StartCoroutine(equippedGun.GunChange(currentGun, timer));
    }