예제 #1
0
    private void DrawGrenade(int grenadeID)
    {
        meleeObject.SetActive(false);

        GrenadeController toInstantiate = GrenadeDatabase.GetGrenadeByID(grenadeID);
        GrenadeController grenInstance  = (GrenadeController)Instantiate(toInstantiate);

        grenInstance.transform.parent        = weaponsParent;
        grenInstance.transform.localPosition = toInstantiate.thirdPersonPosition;
        grenInstance.transform.localRotation = toInstantiate.thirdPersonRotation;
        grenInstance.PrepareForMultiplayer();
        GetComponent <AudioSource>().PlayOneShot(drawSound, 0.7f);

        pullPinSound               = toInstantiate.pullPinSound;
        throwSound                 = toInstantiate.throwSound;
        currentGHP                 = grenInstance.GetComponent <GrenadeHandler_Proxy>();
        currentGHP.whp             = this;
        currentGHP.grenadePrefab   = grenInstance.grenadePrefab;
        currentGHP.displayMesh     = grenInstance.displayMesh;
        currentGHP.throwStr        = grenInstance.throwStrength;
        currentGHP.tossStr         = grenInstance.tossStrength;
        currentGHP.ignoreColliders = ignoreGrenades;
        baseDelay       = grenInstance.baseDelay;
        detonationDelay = grenInstance.detonationDelay;
        Destroy(grenInstance);

        currentGC      = null;
        currentVisuals = null;
    }
예제 #2
0
    private void DrawWeapon(int weaponID)
    {
        meleeObject.SetActive(false);

        GunController toInstantiate = WeaponDatabase.GetWeaponByID(weaponID);

        currentGC = (GunController)Instantiate(toInstantiate);
        currentGC.transform.parent        = weaponsParent;
        currentGC.transform.localPosition = toInstantiate.thirdPersonPosition;
        currentGC.transform.localRotation = toInstantiate.thirdPersonRotation;
        currentGC.StripFunctions(true);
        currentVisuals   = currentGC.GetComponent <GunVisuals>();
        muzzleBrightness = currentGC.muzzleLight.intensity;
        GetComponent <AudioSource>().PlayOneShot(drawSound, 0.7f);

        targetFireRate = 60f / Mathf.Max(currentGC.firstRPM, (currentGC.secondMode != GunController.FireMode.None) ? currentGC.secondRPM : 0f, (currentGC.thirdMode != GunController.FireMode.None) ? currentGC.thirdRPM : 0f);
        currentGHP     = null;
        pullPinSound   = null;
        throwSound     = null;

        if (currentVisuals)
        {
            foreach (GameObject go in currentVisuals.activateOnUse)
            {
                go.SetActive(false);
            }

            currentGC.firePos.GetComponent <AudioSource>().volume = 1f;
        }
    }