Esempio n. 1
0
 public void OnWeaponDraw()
 {
     AntiHackSystem.ProtectInt("currentAmmo", currentAmmo);
     AntiHackSystem.ProtectInt("clipSize", clipSize);
     AntiHackSystem.ProtectInt("ammoLeft", ammoLeft);
     AntiHackSystem.ProtectInt("ammoLeftCap", ammoLeftCap);
 }
Esempio n. 2
0
    void Start()
    {
        slotOneLabel = GeneralVariables.uiController.grenadeOneLabel;
        slotTwoLabel = GeneralVariables.uiController.grenadeTwoLabel;

        AntiHackSystem.ProtectInt("t1Grenade", typeOneGrenades);
        AntiHackSystem.ProtectInt("t1GrenadeMax", typeOneMaxGrenades);
        AntiHackSystem.ProtectInt("t2Grenade", typeTwoGrenades);
        AntiHackSystem.ProtectInt("t2GrenadeMax", typeTwoMaxGrenades);
        pe = GeneralVariables.player.GetComponent <PlayerEffects>();
    }
Esempio n. 3
0
    public void ChangeGrenadeAmount(int id, int amount)
    {
        if (id == grenadeTypeOne)
        {
            AntiHackSystem.ProtectInt("t1Grenade", typeOneGrenades + amount);
        }
        else if (id == grenadeTypeTwo)
        {
            AntiHackSystem.ProtectInt("t2Grenade", typeTwoGrenades + amount);
        }

        ClampGrenadeAmount();
    }
Esempio n. 4
0
    private void InsertBullet()
    {
        int retrievedAmmo     = AntiHackSystem.RetrieveInt("currentAmmo");
        int retrievedAmmoLeft = AntiHackSystem.RetrieveInt("ammoLeft");
        int retrievedClipSize = AntiHackSystem.RetrieveInt("clipSize");

        if (retrievedAmmo >= retrievedClipSize || retrievedAmmoLeft <= 0 || queueStopReload)
        {
            if (!doneReloading)
            {
                StartCoroutine(StopSingularReload());
            }

            return;
        }

        if (retrievedAmmo < retrievedClipSize && retrievedAmmoLeft > 0)
        {
            if (ammoDif < reloadAmount)
            {
                AntiHackSystem.ProtectInt("currentAmmo", currentAmmo + ammoDif);
                AntiHackSystem.ProtectInt("ammoLeft", ammoLeft - ammoDif);
            }
            else if (reloadAmount >= retrievedAmmoLeft)
            {
                AntiHackSystem.ProtectInt("currentAmmo", currentAmmo + ammoLeft);
                AntiHackSystem.ProtectInt("ammoLeft", 0);
            }
            else
            {
                AntiHackSystem.ProtectInt("currentAmmo", currentAmmo + reloadAmount);
                AntiHackSystem.ProtectInt("ammoLeft", ammoLeft - reloadAmount);
            }

            tss.pitchMod = Random.Range(0.95f, 1f);
            tss.GetComponent <AudioSource>().PlayOneShot(reloadSound, 0.5f);
            queueStopReload = forceStopReload;
            //Reload insert shell animation play.
        }

        reloadImpulseGUI += 0.1f;
    }
Esempio n. 5
0
    private void Reload()
    {
        int retrievedAmmoLeft = AntiHackSystem.RetrieveInt("ammoLeft");

        bulletInChamber = (AntiHackSystem.RetrieveInt("currentAmmo") > 0 && includeChamberRound);
        CheckAmmo();

        AntiHackSystem.ProtectInt("currentAmmo", currentAmmo + ((ammoDif > retrievedAmmoLeft) ? retrievedAmmoLeft : (ammoDif + ((bulletInChamber) ? 1 : 0))));

        if (ammoDif > retrievedAmmoLeft)
        {
            AntiHackSystem.ProtectInt("ammoLeft", 0);
        }
        else
        {
            AntiHackSystem.ProtectInt("ammoLeft", ammoLeft - ammoDif);
        }

        reloadImpulseGUI += 0.1f;
        bsna              = baseSpreadAmount;
        endReload         = Time.time;
        reloading         = false;
    }
Esempio n. 6
0
    void Start()
    {
        base.isLocalPlayer = true;
        GeneralVariables.cachedSpectCam = cachedSpectCam;
        uic       = GeneralVariables.uiController;
        rattleTSS = equipmentRattleSource.GetComponent <TimeScaleSound>();

        healthBar         = uic.healthBar;
        healthText        = uic.healthText;
        shieldBar         = uic.shieldBar;
        shieldText        = uic.shieldText;
        staminaBar        = uic.staminaBar;
        shieldTexture     = uic.shieldTexture;
        ne                = uic.guiCamera.GetComponent <NoiseEffect>();
        disE              = uic.guiCamera.GetComponent <DistortionEffect>();
        staminaBackground = staminaBar.backgroundWidget;
        defStaminaBGCol   = staminaBackground.color;
        bloodyScreen      = uic.bloodyScreen;
        flickeringGUI     = uic.flickeringPanels;
        sa                = uic.screenAdjustment;

        bloodyScreen.material.color = DarkRef.SetAlpha(bloodyScreen.material.color, 0f);

        PlayerReference pr = GeneralVariables.playerRef;

        pm         = GetComponent <PlayerMovement>();
        playerLook = GetComponent <PlayerLook>();
        vignetting = cam.GetComponent <VignettingC>();

        damageBreathBoost  = 0f;
        ne.grainIntensity  = 0f;
        disE.baseIntensity = 0f;
        guiSizeModH        = guiSizeModS = 1f;
        healthBar.value    = 0f;
        shieldBar.value    = 0f;
        breathFactor       = 1f;
        hearingPenalty     = 1f;
        standardFreq       = 5000f;

        wm = pr.wm;
        wc = pr.wc;

        shieldAlpha      = 0f;
        finalShAlpha     = 0f;
        flickerIntensity = 0.5f;
        percent          = 1f;
        shPercent        = 1f;
        recovering       = true;
        canSprint        = true;
        initTime         = Time.time;

        damageIDs       = new List <byte>();
        damageInflicted = new List <int>();
        killerID        = -1;
        headID          = -1;
        lastWeaponID    = -1;
        builtData       = "";

        //Initialize values.
        curHealth = maxHealth;
        curShield = maxShield;
        AntiHackSystem.ProtectInt("maxHealth", maxHealth);
        AntiHackSystem.ProtectInt("maxShield", maxShield);

        oldHealth = curHealth;
        oldShield = curShield;
    }
Esempio n. 7
0
    private IEnumerator SelectWeaponCoroutine(int weaponIndex, bool immediate)
    {
        prepareToSwitch = true;

        while (ac.aimTransition > 0.05f)
        {
            yield return(0);
        }

        prepareToSwitch = false;

        if (currentGC != null && currentGC.reloading)
        {
            currentGC.CancelReload();
        }

        int prevWeaponNum = curWeaponNum;

        if (Topan.Network.isConnected && rootNetView != null)
        {
            if (weaponIndex == 0 || weaponIndex == 1)
            {
                rootNetView.RPC(Topan.RPCMode.OthersBuffered, "RefreshWeapon", (byte)heldWeapons[weaponIndex].weaponID);

                if (heldWeapons[weaponIndex].gunVisuals != null && heldWeapons[weaponIndex].gunVisuals.flashlight != null)
                {
                    rootNetView.RPC(Topan.RPCMode.OthersBuffered, "SetFlashlight", heldWeapons[weaponIndex].flashlightOn);
                }
            }
            else
            {
                if (weaponIndex <= -1)
                {
                    rootNetView.RPC(Topan.RPCMode.OthersBuffered, "SetSpecialActive", (byte)0); //Hands
                }
                else if (weaponIndex == 2)
                {
                    rootNetView.RPC(Topan.RPCMode.OthersBuffered, "SetSpecialActive", (byte)1); //Melee
                }
                else if (weaponIndex == 3)
                {
                    grenadeManager.OnSelect(true);
                }
            }
        }

        if (!immediate)
        {
            if (!isQuickThrowState)
            {
                curAmmoDisplay.text  = "--";
                ammoLeftDisplay.text = "---";
            }

            float weightFactorTime = 0f;
            if (weaponIndex == 0 || weaponIndex == 1)
            {
                if (ignoreWeightDelayOnce)
                {
                    ignoreWeightDelayOnce = false;
                }
                else
                {
                    weightFactorTime = (heldWeapons[weaponIndex].weaponWeight * 0.05f);
                }
            }

            dm.Draw(drawTime + weightFactorTime);
            switching          = true;
            pv.jumpRattleEquip = true;

            float waitPeriod       = 0f;
            bool  cyclingGrenades  = false;
            bool  ignoreFirstPress = true;
            while (waitPeriod < drawTime + weightFactorTime)
            {
                if (weaponIndex == 3 && Input.GetKeyDown(KeyCode.Alpha4) && grenadeManager.availableGrenades.Count > 1)
                {
                    if (!ignoreFirstPress)
                    {
                        cyclingGrenades = true;

                        if (grenadeManager.grenadeIndex == 0 && gam.typeTwoGrenades > 0)
                        {
                            grenadeManager.grenadeIndex = 1;
                        }
                        else if (grenadeManager.grenadeIndex == 1 && gam.typeOneGrenades > 0)
                        {
                            grenadeManager.grenadeIndex = 0;
                        }

                        grenadeSelection.alpha     = grenadeSelection.defaultAlpha;
                        grenadeSelectionLabel.text = grenadeManager.grenadeInventory[grenadeManager.grenadeIndex].grenadeName;

                        dm.ExtendDrawTime(waitPeriod);
                        waitPeriod = 0f;
                    }
                    else
                    {
                        grenadeSelectionLabel.alpha = 0.4f;
                    }

                    ignoreFirstPress = false;
                }

                if (cyclingGrenades)
                {
                    grenadeSelectionLabel.alpha = Mathf.Lerp(grenadeSelectionLabel.alpha, 0.8f, Time.deltaTime * 18f);
                }

                waitPeriod += Time.deltaTime;
                yield return(null);
            }

            switching = false;
        }

        bool          sameWeapon = false;
        GunController gc1        = null;
        GunController gc2        = null;

        if (prevWeaponNum > -1 && prevWeaponNum >= 0 && prevWeaponNum <= 1 && weaponIndex >= 0 && weaponIndex <= 1)
        {
            gc1 = heldWeapons[prevWeaponNum];
            gc2 = heldWeapons[weaponIndex];

            if (gc1 != null && gc2 != null && gc1.weaponID == gc2.weaponID)
            {
                sameWeapon = true;
            }
        }

        if (weaponIndex > -2)
        {
            pv.jumpRattleEquip = true;
            GetComponent <AudioSource>().PlayOneShot(drawSound, 0.2f);
        }

        if (currentWeaponTransform == grenadeManager.transform)
        {
            grenadeManager.OnDeselect();
        }

        DeselectAll();

        curWeaponNum  = weaponIndex;
        curWeaponMode = (curWeaponNum == 0 || curWeaponNum == 1) ? CurrentWeaponMode.GenericWeapon : CurrentWeaponMode.AlternateWeapon;

        if (curWeaponMode == CurrentWeaponMode.GenericWeapon)
        {
            currentGC.gameObject.SetActive(true);
            currentGC.OnWeaponDraw();
            currentWeaponTransform = currentGC.transform;

            if (queuedAmmo > -1)
            {
                AntiHackSystem.ProtectInt("currentAmmo", queuedAmmo);
                queuedAmmo = -1;
            }

            if (queuedReserve > -1)
            {
                AntiHackSystem.ProtectInt("ammoLeft", queuedReserve);
                queuedReserve = -1;
            }

            currentGC.bulletInChamber = queuedChamber;
            queuedChamber             = false;

            curWepName = currentGC.gunName;

            if (!pe.hasEMP)
            {
                weaponIcon.mainTexture             = currentGC.iconTexture;
                weaponIcon.transform.localPosition = defaultIconPos + new Vector3(currentGC.iconOffset.x, currentGC.iconOffset.y, 0f);
                weaponIcon.SetDimensions((int)currentGC.iconScale.x, (int)currentGC.iconScale.y);
            }
        }
        else
        {
            if (curWeaponNum == 3)
            {
                grenadeManager.gameObject.SetActive(true);
                grenadeManager.OnSelect(false);

                if (pressedQuickThrow)
                {
                    grenadeManager.QuickThrow(prevWeaponNum);
                }

                currentWeaponTransform = grenadeManager.transform;
                pressedQuickThrow      = false;
            }
            else if (curWeaponNum == 2)
            {
                meleeController.gameObject.SetActive(true);
                currentWeaponTransform = meleeController.transform;

                weaponIcon.mainTexture             = meleeController.iconTexture;
                weaponIcon.transform.localPosition = defaultIconPos + new Vector3(meleeController.iconOffset.x, meleeController.iconOffset.y, 0f);
                weaponIcon.SetDimensions((int)meleeController.iconSize.x, (int)meleeController.iconSize.y);
            }
            else if (curWeaponNum <= -1)
            {
                if (curWeaponNum == -1)
                {
                    hands.SetActive(true);
                    currentWeaponTransform = hands.transform;
                }
                else
                {
                    currentWeaponTransform = null;
                }

                curWepName             = "Hands";
                weaponIcon.mainTexture = null;
                weaponIcon.SetDimensions(100, 50);

                curAmmoDisplay.color = Color.white;
                curAmmoDisplay.text  = "---";
                ammoLeftDisplay.text = "---";

                ammoBar.value = 1f;
            }
        }

        StartCoroutine(WeaponNameTransition());

        ReflectionUpdateGroup foundRUG = currentWeaponTransform.GetComponent <ReflectionUpdateGroup>();

        if (foundRUG != null)
        {
            foreach (Renderer r in foundRUG.allRenderers)
            {
                UpdateReflection(r);
            }
        }

        if (sameWeapon)
        {
            gc2.ammoLeft = gc1.ammoLeft;
            AntiHackSystem.ProtectInt("ammoLeft", gc1.ammoLeft);
        }

        if (curWeaponNum < 3 && curWeaponNum != -2)
        {
            dm.sao = currentWeaponTransform.GetComponent <SprintAnimOverride>();
        }

        grenadeSelectionLabel.alpha = 0.2f;
    }
Esempio n. 8
0
    private void Shoot(float cwm, float vf, float af)
    {
        for (int i = 0; i < bulletsPerShot; i++)
        {
            Vector2    randomTargetPoint = Random.insideUnitCircle * ((bsna * cwm * asm * af) + vf);
            Vector3    randomDir         = new Vector3(randomTargetPoint.x, randomTargetPoint.y, 0f);
            Quaternion randomRot         = Quaternion.Euler(firePos.eulerAngles) * Quaternion.Euler(randomDir);
            GameObject proj = PoolManager.Instance.RequestInstantiate(bulletInfo.poolIndex, firePos.position, randomRot, false);

            if (bulletInfo.bulletType == BulletInfo.BulletType.Bullet)
            {
                Bullet projBul = proj.GetComponent <Bullet>();
                projBul.BulletInfo(bulletInfo, weaponID, false, true, -1);
                projBul.noWhizSound = true;
                projBul.InstantiateStart();
            }
            else if (bulletInfo.bulletType == BulletInfo.BulletType.Rocket)
            {
                Rocket projRoc = proj.GetComponent <Rocket>();
                projRoc.RocketInfo(bulletInfo, weaponID, false, true, -1);
                projRoc.InstantiateStart();
            }

            if (Topan.Network.isConnected && wm.rootNetView)
            {
                Vector3 fwdRot = Quaternion.LookRotation(randomRot * Vector3.forward).eulerAngles;
                wm.rootNetView.UnreliableRPC(Topan.RPCMode.Others, "NetworkShoot", (TopanFloat)(fwdRot.x / 360f), (TopanFloat)(fwdRot.y / 360f), firePos.position);
            }
        }

        bsna += spreadSpeed * spreadAimFactor;

        if (countsAsOneBullet)
        {
            AntiHackSystem.ProtectInt("currentAmmo", currentAmmo - 1);
        }
        else
        {
            AntiHackSystem.ProtectInt("currentAmmo", currentAmmo - bulletsPerShot);
        }

        fireCount++;

        StopCoroutine("MuzzleControl");
        StartCoroutine(MuzzleControl());

        if (ejectionEnabled)
        {
            if (ejectionDelay > 0f)
            {
                StartCoroutine(EjectShell());
            }
            else
            {
                Rigidbody shell = PoolManager.Instance.RequestInstantiate(bulletShellIndex, ejectionPos.position, ejectionPos.rotation).GetComponent <Rigidbody>();
                shell.velocity        = (pm.controller.velocity * 0.7f) + pm.transform.TransformDirection(DarkRef.RandomVector3(ejectionMinForce, ejectionMaxForce));
                shell.angularVelocity = Random.rotation.eulerAngles * ejectionRotation;
            }
        }

        tss.pitchMod = Random.Range(0.95f, 1f);
        tss.GetComponent <AudioSource>().PlayOneShot(fireSound);

        if (pa != null)
        {
            pa.startAnimation = true;
        }

        float aimMod    = (ac.isAiming) ? aimUpkickModifier : 1f;
        float crouchMod = (pm.crouching) ? crouchUpkickModifier : 1f;
        float extraMod  = (fireCount > extraRecoilThreshold) ? 1f + Mathf.Clamp((fireCount - extraRecoilThreshold) * extraRecoilAmount, 0f, maxExtraRecoil) : 1f;

        pl.Recoil(recoilAmount * ((ac.isAiming) ? 0.56f : 1.0f), upKickAmount * aimMod * crouchMod * extraMod, sideKickAmount * aimMod * crouchMod * extraMod, kickInfluence, kickCameraTilt, camShakeAnim, autoReturn);
        dm.Kickback(kickBackAmount * 0.04f, kickSpeedFactor, kickGunTilt);

        shootImpulseGUI += 0.1f;
        ammoBar.value   += 0.01f;
        crosshair.JoltAnimation(spreadSpeed);

        timeSinceLastFire = Time.time;

        if (currentFireMode != FireMode.BurstFire)
        {
            timer += 1f;
        }
    }