Пример #1
0
    void Update()
    {
        timer += flickeringSpeed * Time.deltaTime;
        mat.SetColor(colorProperty, DarkRef.SetAlpha(mat.GetColor(colorProperty), Mathf.Clamp01(Mathf.Lerp(alphaRange.x / 255f, alphaRange.y / 255f, Mathf.PerlinNoise(timer, randomStart)))));

        if (timer > 1200f)
        {
            timer -= 1200f;
        }
    }
Пример #2
0
    void Update()
    {
        if (flickerMethod == FlickerMethod.Sine)
        {
            GetComponent <Light>().intensity = minIntensity + Mathf.Abs(Mathf.Sin(Time.time * frequency) * (maxIntensity - minIntensity));
        }
        else if (flickerMethod == FlickerMethod.Perlin)
        {
            GetComponent <Light>().intensity = minIntensity + Mathf.Abs(Mathf.PerlinNoise(Time.time * frequency, 23.7f) * (maxIntensity - minIntensity));
        }

        if (glowPlane)
        {
            glowPlane.material.SetColor(colorPropName, DarkRef.SetAlpha(glowPlane.material.GetColor(colorPropName), defAlpha * (GetComponent <Light>().intensity / maxIntensity)));
        }
    }
Пример #3
0
    private IEnumerator Destruct()
    {
        isDestroying = true;

        float alpha = tm.color.a;

        while (alpha > 0f)
        {
            tm.color      = DarkRef.SetAlpha(tm.color, alpha);
            tr.localScale = Vector3.Lerp(Vector3.zero, defScale, 0.6f + (alpha * 0.4f));
            alpha        -= Time.deltaTime * fadeOutSpeed;
            yield return(null);
        }

        Destroy(gameObject);
    }
Пример #4
0
    public override void InstantiateStart()
    {
        time = destroyTime + (Random.value * randomness);

        if (isParticle)
        {
            foreach (ParticleEmitter e in emitters)
            {
                e.Emit();
            }
        }

        if (fadeOut)
        {
            if (defAlpha == null)
            {
                defAlpha = new float[renderers.Length];
            }

            for (int i = 0; i < renderers.Length; i++)
            {
                if (renderers[i] == null)
                {
                    continue;
                }

                Color col = renderers[i].material.GetColor(colorName);

                if (defAlpha[i] <= 0f)
                {
                    defAlpha[i] = col.a;
                }

                renderers[i].material.SetColor(colorName, DarkRef.SetAlpha(col, defAlpha[i]));
            }
        }

        timer          = 0f;
        startedDestroy = false;
    }
Пример #5
0
    private IEnumerator StartDestroy()
    {
        startedDestroy = true;

        if (fadeOut)
        {
            float mod = 1f;
            while (mod > 0f)
            {
                mod -= Time.deltaTime * fadeSpeed;
                for (int i = 0; i < renderers.Length; i++)
                {
                    Color col = renderers[i].material.GetColor(colorName);
                    renderers[i].material.SetColor(colorName, DarkRef.SetAlpha(col, defAlpha[i] * Mathf.Clamp01(mod)));
                }
                yield return(null);
            }
        }

        if (transform.parent != null && transform.parent.name == "KeepScale")
        {
            Transform parent = transform.parent;
            transform.parent = null;
            Destroy(parent.gameObject);
        }

        if (poolObject)
        {
            AddToPool();
        }
        else
        {
            Destroy(gameObject);
        }

        timer = 0f;
    }
Пример #6
0
    private void Die()
    {
        Transform specTarget = null;

        if (Topan.Network.isConnected)
        {
            bool isSuicide = (killerID <= -1);
            builtData = Topan.Network.player.id.ToString() + ((!isSuicide) ? "," : "");

            if (!isSuicide)
            {
                for (int i = 0; i < damageIDs.Count; i++)
                {
                    builtData += damageIDs[i].ToString();

                    if (damageIDs.Count > 1 && damageIDs[i] == killerID)
                    {
                        builtData += "k";
                    }

                    if (damageIDs[i] == headID)
                    {
                        builtData += "!";
                    }

                    if (i < damageIDs.Count - 1)
                    {
                        builtData += ",";
                    }
                }

                builtData += ".";

                if (damageIDs.Count > 1)
                {
                    for (int i = 0; i < damageInflicted.Count; i++)
                    {
                        builtData += damageInflicted[i].ToString();

                        if (i < damageIDs.Count - 1)
                        {
                            builtData += ",";
                        }
                    }
                }

                if (lastWeaponID > -1)
                {
                    grenade = false;
                    if (lastWeaponID >= 1000)
                    {
                        lastWeaponID -= 1000;
                        grenade       = true;
                    }

                    builtData += "." + lastWeaponID.ToString() + ((grenade) ? "*" : "");
                }
            }

            if (wm.currentGC != null)
            {
                string gunName = wm.currentGC.gunName;
                Dictionary <string, object> dropData = new Dictionary <string, object>();
                dropData.Add("chamber", wm.currentGC.bulletInChamber);

                Vector3 playerVelo = Vector3.zero;
                if (pm != null)
                {
                    playerVelo = (pm.controller.velocity * 0.25f);
                }

                dropData.Add("force", wm.transform.forward + playerVelo);
                dropData.Add("curammo", wm.currentGC.currentAmmo);
                dropData.Add("ammoleft", wm.currentGC.ammoLeft);
                Topan.Network.Instantiate(Topan.Network.server, "Weapons/" + gunName, wm.transform.position + (wm.transform.forward * 0.5f), wm.currentGC.transform.rotation, 0, dropData);
            }

            GetComponent <Topan.NetworkView>().Deallocate();

            if (killerID > -1)
            {
                if (killerID >= 64)
                {
                    specTarget = GeneralVariables.Networking.botInstances[killerID - 64];
                }
                else if (killerID >= 0)
                {
                    specTarget = ((Topan.NetworkView)Topan.Network.GetPlayerByID(killerID).GetLocalData("currentView")).transform;
                }

                if (specTarget != null)
                {
                    GeneralVariables.spectatorCamera.playerFollow.startingPosition = transform.position;
                    GeneralVariables.spectatorCamera.playerFollow.offset           = Vector3.up * 0.55f;
                    GeneralVariables.spectatorCamera.target = specTarget.GetChild(1);
                }
            }

            GeneralVariables.spectatorCamera.playerFollow.followRotation = true;
            GeneralVariables.Networking.GetComponent <Topan.NetworkView>().RPC(Topan.RPCMode.Server, "KilledPlayer", builtData);
            GeneralVariables.Networking.StartSpectating();
        }

        uic.gManager.damageBlur         = 0f;
        bloodyScreen.material.color     = DarkRef.SetAlpha(bloodyScreen.material.color, 0f);
        staminaBackground.color         = defStaminaBGCol;
        healthText.text                 = "INACTIVE";
        healthText.transform.localScale = Vector3.one;
        healthBar.value                 = 0f;
        shieldBar.value                 = 0f;
        pe.ClearExplosionEffect();

        for (int i = 0; i < hitIndicators.Count; i++)
        {
            if (hitIndicators[i].instance == null)
            {
                continue;
            }

            Destroy(hitIndicators[i].instance);
        }

        if (deathReplacement != null)
        {
            GameObject go = (GameObject)Instantiate(deathReplacement, transform.position, transform.rotation);
            go.GetComponent <AudioSource>().pitch = Random.Range(0.85f, 0.94f);
            go.GetComponent <AudioSource>().PlayOneShot(deathSound, Random.Range(0.3f, 0.35f));
            go.GetComponentInChildren <SkinnedMeshRenderer>().gameObject.AddComponent <DissolveEffect>().Dissolve(dissolveMat, GameSettings.settingsController.ragdollDestroyTimer, 0.18f, new Color(1f, 0.3f, 0f), DissolveEffect.DissolveDirection.DissolveOut, true);

            if ((Topan.Network.isConnected && killerID == -1) || (Topan.Network.isConnected && specTarget == null))
            {
                GeneralVariables.spectatorCamera.playerFollow.startingPosition = transform.position;
                GeneralVariables.spectatorCamera.playerFollow.offset           = Vector3.up * 0.55f;
                GeneralVariables.spectatorCamera.target = go.transform.GetChild(1);
            }
        }

        dead          = true;
        base.headshot = false;
        Destroy(gameObject);

        if (!Topan.Network.isConnected)
        {
            Application.LoadLevel(Application.loadedLevel);
        }
    }
Пример #7
0
    void Update()
    {
        int retrievedMaxHealth = AntiHackSystem.RetrieveInt("maxHealth");
        int retrievedMaxShield = AntiHackSystem.RetrieveInt("maxShield");

        if (GameManager.boundarySettings != null)
        {
            bool inMapBounds = GameManager.boundarySettings.mapBounds.Contains(transform.position);
            if (!inMapBounds)
            {
                ApplyDamageMain((curHealth + curShield) * 2, false);
            }
        }

        if (Input.GetKey(KeyCode.X))
        {
            if (Input.GetKeyDown(KeyCode.B))
            {
                ApplyDamageMain(Random.Range(10, 15), true);
                HitIndicator(transform.position + DarkRef.RandomVector3(Vector3.one * -5f, Vector3.one * 5f));
            }
            else if (Input.GetKeyDown(KeyCode.K))
            {
                ApplyDamageMain(retrievedMaxHealth + retrievedMaxShield + 1, false);
            }
        }

        AdjustGUISize();
        ManageIndicatorGUI();

        if (recovering && curHealth < retrievedMaxHealth)
        {
            timer += Time.deltaTime;
        }

        if (shRecovering)
        {
            if (curShield < retrievedMaxShield)
            {
                shTimer += Time.deltaTime;
            }

            shieldAlarmSource.volume = 0f;

            if (!shGlowRecover)
            {
                shieldTexture.color = shieldTexture.defaultColor;
                shieldAlpha         = 0.21f;
                shGlowRecover       = true;
            }
        }
        else
        {
            shGlowRecover = false;
            if (retrievedMaxShield > 0f)
            {
                if (pe.hasEMP)
                {
                    shieldAlarmSource.volume = 0f;
                }
                else
                {
                    shieldAlarmSource.volume = Mathf.Clamp01(0.5f - shPercent) * 0.12f;
                }
            }
        }

        if (Time.time - lastDamage > 0.3f)
        {
            Color lerpHurtColor = Color.Lerp(hurtColor, Color.white, Mathf.Clamp01((percent - 0.2f) * 3.5f));
            healthText.color = Color.Lerp(healthText.color, lerpHurtColor, Time.unscaledDeltaTime * 5f);
            Color lerpShieldColor = Color.Lerp(new Color(0.8f, 0.8f, 0.8f, 1f), Color.white, Mathf.Clamp01(shPercent * 5f));
            shieldText.color = Color.Lerp(shieldText.color, lerpShieldColor, Time.unscaledDeltaTime * 5f);
        }

        curShield = Mathf.Clamp(curShield, 0, retrievedMaxShield);
        float fallDmgMod = (fallDamageTotal > 0) ? 0.8f : 1f;

        if (retrievedMaxShield > 0)
        {
            shPercent = (float)curShield / (float)retrievedMaxShield;

            float shRecoverRate = (shieldRecoverySpeed * fallDmgMod);
            if (shTimer >= shRecoverRate && (curShield < retrievedMaxShield))
            {
                curShield += shieldRecoverAmount;

                if (fallDamageTotal > 0)
                {
                    fallDamageTotal--;
                }

                shTimer -= shRecoverRate;
            }
        }
        else
        {
            shPercent = 0f;
        }

        curHealth  = Mathf.Clamp(curHealth, 0, retrievedMaxHealth);
        maxHealth  = retrievedMaxHealth;
        maxShield  = retrievedMaxShield;
        curStamina = Mathf.Clamp(curStamina, 0, 100);

        float recoverRate = (healthRecoverySpeed * (1f + (percent * healthRecoverInfluence)) * fallDmgMod);

        if (timer >= recoverRate && (curHealth < retrievedMaxHealth))
        {
            curHealth += healthRecoverAmount;

            if (fallDamageTotal > 0)
            {
                fallDamageTotal--;
            }

            timer -= recoverRate;
        }

        if (!dead)
        {
            if (startRecoveryTimer)
            {
                rTimer += Time.deltaTime;
            }

            if (startShRecoveryTimer)
            {
                shrTimer += Time.deltaTime;
            }
        }

        if (rTimer >= healthRecoverDelay && !dead)
        {
            startRecoveryTimer = false;
            rTimer             = 0f;
            recovering         = true;
        }

        if (maxShield > 0 && shrTimer >= shieldRecoverDelay && !dead)
        {
            startShRecoveryTimer = false;
            shrTimer             = 0f;
            shRecovering         = true;

            fallDamageSource.GetComponent <TimeScaleSound>().pitchMod = 1f;
            fallDamageSource.PlayOneShot(shieldRegen, 0.1f);
        }

        float steepSlopeFactor = (pm.grounded) ? Mathf.Clamp01(pm.controller.velocity.normalized.y) : 0f;

        if (pm.grounded && (pm.sprinting || pm.sprintReloadBoost > 1f) && pm.xyVelocity >= 0.75f)
        {
            rattleTSS.pitchMod           = 1f;
            equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, rattleVolumeSprint, Time.deltaTime * 9f);
            dTimer += Time.deltaTime * (pm.controllerVeloMagn / pm.movement.sprintSpeed);

            float requirement = staminaDepletionRate * (1f - (wc.weightPercentage * 0.8f)) * (1f - (steepSlopeFactor * 0.22f));
            if (dTimer >= requirement && curStamina > 0f)
            {
                curStamina -= 1 + Mathf.RoundToInt((1f / requirement) * Time.deltaTime);
                dTimer      = 0f;
            }
        }
        else
        {
            float velocityFactor = Mathf.Clamp01(pm.xyVelocity / pm.movement.runSpeed);
            if (jumpRattleEquip)
            {
                rattleTimer += Time.deltaTime;

                if (pm.xyVelocity < 0.75f)
                {
                    rattleTSS.pitchMod           = 1f;
                    equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, Mathf.Lerp(rattleVolumeNormal, rattleVolumeSprint, 0.5f), Time.deltaTime * 11f);
                }

                if (rattleTimer >= 0.4f)
                {
                    rattleTimer     = 0f;
                    jumpRattleEquip = false;
                }
            }
            else
            {
                if (pm.grounded)
                {
                    if (pm.xyVelocity >= 0.75f)
                    {
                        rattleTSS.pitchMod           = (pm.crouching) ? 0.8f : 0.96f;
                        equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, rattleVolumeNormal * velocityFactor, Time.deltaTime * 9f);
                    }
                    else
                    {
                        equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, 0f, Time.deltaTime * 9f);
                    }
                }
                else
                {
                    equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, 0f, Time.deltaTime * 9f);
                }
            }

            sTimer += Time.deltaTime;

            float requirement = (staminaRecoverySpeed * (2f - Mathf.Clamp(Time.time - lastDe, 0f, 1f)) * (1f + Mathf.Clamp01((pm.xyVelocity * 0.17f) / pm.movement.runSpeed)) + (steepSlopeFactor * 0.16f));
            if (sTimer >= requirement && curStamina < 100 && !staminaCooldown)
            {
                curStamina += 1 + Mathf.RoundToInt((1f / requirement) * Time.deltaTime);
                sTimer      = 0f;
            }
        }

        curStamina = Mathf.Clamp(curStamina, 0, 100);

        if (curStamina <= 1f && canSprint)
        {
            StartCoroutine(CalmingStage());
        }

        shieldAlpha  = Mathf.Clamp(shieldAlpha, 0f, 0.35f);
        shieldAlpha  = Mathf.MoveTowards(shieldAlpha, 0f, Time.deltaTime * 0.6f);
        finalShAlpha = Mathf.Lerp(finalShAlpha, shieldAlpha, Time.deltaTime * 8.5f);

        shieldTexture.alpha = finalShAlpha * ((shGlowRecover) ? 1f : (0.3f + (Mathf.PerlinNoise(Mathf.PingPong(Time.time * 22f, 250f), 0f) * 0.7f)));
        damageEffect        = Mathf.Lerp(damageEffect, 0f, (Time.time - lastDe) * 5f);
        chromAbb            = Mathf.Lerp(chromAbb, Mathf.Clamp(damageEffect, 0f, 30f) + ((0.3f - Mathf.Min(percent, 0.3f)) * 25f), Time.deltaTime * 5f);

        bloodEffect             = Mathf.Clamp01(Mathf.Lerp(bloodEffect, 0f, Time.deltaTime * 0.068f));
        uic.gManager.damageBlur = Mathf.Clamp(Mathf.Lerp(uic.gManager.damageBlur, 0f, Time.deltaTime * dmgBlurRestore) + ((percent <= 0.2f) ? 0.001f : 0f), 0f, 0.85f);

        foreach (FlickeringGUI fg in flickeringGUI)
        {
            if (pe.hasEMP)
            {
                fg.dimAlpha         = Random.Range(0.1f, 1f);
                fg.updateFrequency  = 0.03f;
                fg.flickerFrequency = 0.8f;
            }
            else
            {
                fg.dimAlpha         = Mathf.Clamp01(0.3f + flickerIntensity * 2f);
                fg.updateFrequency  = 0.05f;
                fg.flickerFrequency = 0.85f;
            }
        }

        float stPercent = Mathf.Clamp01((float)curStamina / 100f);
        float hbVolume  = Mathf.Clamp(0.5f - percent, 0f, 0.5f) * 0.3f;

        heartbeatSound.volume = hbVolume + ((1f - stPercent) * 0.05f);

        float nVolume = Mathf.Clamp(0.25f - percent, 0f, 0.25f) / 0.25f;

        noiseSource.volume = nVolume * 0.2f;

        if (Time.time - lastHeartTime >= 1f)
        {
            hbEffectTarget = 3.1f;
            lastHeartTime  = Time.time;
        }

        if (pe.hasEMP)
        {
            grainEMP   = Mathf.Lerp(grainEMP, 0.035f, Time.deltaTime * 1.3f);
            distortEMP = Mathf.Lerp(distortEMP, 0.15f, Time.deltaTime * 1.3f);
        }
        else
        {
            grainEMP   = Mathf.Lerp(grainEMP, 0f, Time.deltaTime * 3f);
            distortEMP = Mathf.Lerp(distortEMP, 0f, Time.deltaTime * 3f);
        }

        vignetteEMP  = Mathf.Lerp(vignetteEMP, 0f, Time.deltaTime * 4f);
        ne.empEffect = grainEMP;

        hbEffectTarget  = Mathf.MoveTowards(hbEffectTarget, 0f, Time.deltaTime * 4.3f);
        heartbeatEffect = Mathf.Lerp(heartbeatEffect, hbEffectTarget + 0.05f, Time.deltaTime * 11f);

        percent          = curHealth / (float)retrievedMaxHealth;
        flickerIntensity = Mathf.Lerp(flickerIntensity, percent, Time.deltaTime * 0.5f * Mathf.Clamp((Time.time - initTime) * 0.5f, 0f, 4f));
        hearingPenalty   = Mathf.Lerp(hearingPenalty, 1f, Time.deltaTime * 0.2f);

        if (percent <= 0.25f)
        {
            standardFreq      = Mathf.Lerp(standardFreq, (pe.hasEMP) ? empMuffle : Mathf.Lerp(muffleRange.x, muffleRange.y, Mathf.Clamp01(percent * 4f)), Time.deltaTime * 9f);
            ne.grainIntensity = Mathf.Lerp(0f, 0.0075f, 1f - Mathf.Clamp01(percent * 4f));
        }
        else
        {
            standardFreq      = Mathf.Lerp(standardFreq, (pe.hasEMP) ? empMuffle : 20000f, Time.deltaTime * ((pe.hasEMP) ? 3.5f : 0.7f));
            ne.grainIntensity = Mathf.Lerp(ne.grainIntensity, 0f, Time.deltaTime * 5f);
        }

        healthLowPass.cutoffFrequency = standardFreq * hearingPenalty;

        ne.enabled         = (ne.grainIntensity + grainEMP > 0f);
        disE.enabled       = (ne.enabled || distortEMP > 0f);
        disE.baseIntensity = (ne.grainIntensity * 4f) + distortEMP;
        disE.splitOffset   = (pe.hasEMP) ? 0.05f : 0f;

        if (staminaBlinking)
        {
            sBlinkTimer += Time.deltaTime * 6.75f;
            sBlinkValue  = Mathf.Sin(sBlinkTimer);

            Color redCol = defStaminaBGCol;
            redCol.r *= 3f;
            staminaBackground.color = Color.Lerp(defStaminaBGCol, redCol, sBlinkValue);
        }
        else
        {
            sBlinkTimer = 0f;
            sBlinkValue = 0f;

            staminaBackground.color = defStaminaBGCol;
        }

        damageBreathBoost     = Mathf.Clamp(Mathf.MoveTowards(damageBreathBoost, 0f, Time.deltaTime * 0.05f), 0f, 0.42f);
        dBreath               = Mathf.Lerp(dBreath, damageBreathBoost, Time.deltaTime * 7f);
        breathingSound.volume = (0.05f + (hbVolume * 0.11f) + (0.148f * (1f - stPercent)) + dBreath) * breathFactor;
        breathingSound.GetComponent <TimeScaleSound>().pitchMod = 1f + (hbVolume * 0.03f) + (0.145f * (1f - stPercent));

        imageEffect                    = Mathf.Lerp(imageEffect, Mathf.Clamp01(1f - (percent + 0.45f)) * effectIntensity, Time.deltaTime * 3f);
        vignetting.intensity           = imageEffect + vignetteEMP + (heartbeatEffect * Mathf.Clamp01(1f - (percent * 2f)));
        vignetting.blur                = (imageEffect * 0.2f) + aimEffect;
        vignetting.blurSpread          = aimEffect * 0.5f;
        vignetting.heartbeatBlur       = heartbeatEffect * Mathf.Clamp01(1f - (percent * 2f)) * 0.45f;
        vignetting.chromaticAberration = chromAbb * (1f + ((1 - percent) * 0.3f));

        float saturation = Mathf.Clamp01(0.45f + (percent * 0.88f));

        sa.saturationAmount = Mathf.Lerp(sa.saturationAmount, (pe.hasEMP) ? Random.value * Random.value : saturation, Time.deltaTime * 4f);
        sa.colorTint        = Vector4.Lerp(new Vector4(1.1f, 0.95f, 0.95f, 1f), Vector4.one, Mathf.Clamp01(percent * 2.5f));

        if (!dead)
        {
            alpha = Mathf.Lerp(alpha, bloodEffect + ((1 - percent) * 0.15f), Time.deltaTime * 8f);
            bloodyScreen.material.color = DarkRef.SetAlpha(bloodyScreen.material.color, alpha * 0.82f);
        }

        healthBar.value = Mathf.Lerp(healthBar.value, (pe.hasEMP) ? Random.value : percent, Time.unscaledDeltaTime * 7.5f);
        shieldBar.value = Mathf.Lerp(shieldBar.value, (pe.hasEMP) ? Random.value : shPercent, Time.unscaledDeltaTime * 7.5f);

        if (pe.hasEMP)
        {
            if (Time.time - lastUpdateTime >= 0.1f)
            {
                healthText.text = (dead) ? "INACTIVE" : (Random.Range(0, 999) + "/" + Random.Range(0, 999));
                lastUpdateTime  = Time.time;
            }
        }
        else
        {
            healthText.text = (dead) ? "INACTIVE" : (curHealth + "/" + retrievedMaxHealth);
        }

        if (shrTimer < 0f || maxShield <= 0)
        {
            shieldText.color = new Color(1f, 0.4f, 0.2f);
            shieldText.text  = "DISABLED";
        }
        else
        {
            shieldText.color = shieldText.defaultColor;
            shieldText.text  = curShield + "/" + retrievedMaxShield;
        }

        staminaBar.value = Mathf.Lerp(staminaBar.value, (pe.hasEMP) ? Random.value : stPercent, Time.deltaTime * 8f);
    }
Пример #8
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;
    }
Пример #9
0
    void Update()
    {
        CheckText();

        grenadeSelection.transform.localPosition = Vector3.Lerp(grenadeSelection.transform.localPosition, (grenadeManager.grenadeIndex == 0) ? grenOnePos : grenTwoPos, Time.deltaTime * 18f);
        grenadeSelection.alpha     = Mathf.Lerp(grenadeSelection.alpha, (currentWeaponTransform == grenadeManager.transform) ? grenadeSelection.defaultAlpha : grenadeSelection.defaultAlpha * 0.35f, Time.deltaTime * 16f);
        grenadeSelectionLabel.text = grenadeManager.grenadeInventory[grenadeManager.grenadeIndex].grenadeName;

        if (currentWeaponTransform == grenadeManager.transform || !grenadeManager.canSwitchToGrenade)
        {
            grenadeSelectionLabel.alpha = Mathf.Lerp(grenadeSelectionLabel.alpha, 0f, Time.deltaTime * 15f);
        }
        else if (!dm.animationIsPlaying)
        {
            grenadeSelectionLabel.alpha = Mathf.Lerp(grenadeSelectionLabel.alpha, grenadeSelection.defaultAlpha * 0.4f, Time.deltaTime * 15f);
        }

        if (pe.hasEMP)
        {
            if (PlayerEffects.onFinishEMP == null)
            {
                PlayerEffects.onFinishEMP = FinishedEMP;
            }

            ammoBar.value = Mathf.Lerp(ammoBar.value, Random.value, Time.deltaTime * 10f);
        }

        if (currentGC != null)
        {
            dca = Mathf.Lerp(dca, currentGC.currentAmmo, Time.deltaTime * 14f * Mathf.Clamp01(Time.time - initTime));
            dal = Mathf.Lerp(dal, currentGC.ammoLeft, Time.deltaTime * 15f * Mathf.Clamp01(Time.time - initTime));

            muzGlow.enabled = currentGC.muzzlePercent > 0f;
            muzGlow.material.SetColor("_TintColor", DarkRef.SetAlpha(muzGlow.material.GetColor("_TintColor"), currentGC.muzzlePercent * muzzleGlowBright));
        }

        if (!pe.hasEMP)
        {
            displayCurAmmo  = Mathf.RoundToInt(dca);
            displayAmmoLeft = Mathf.RoundToInt(dal);
        }

        if (Time.timeScale <= 0f || RestrictionManager.restricted)
        {
            return;
        }

        if (!dm.animationIsPlaying)
        {
            if (currentGC != null)
            {
                if (cInput.GetButtonDown("Flashlight") && (Time.time - lastClick) >= 0.3f)
                {
                    currentGC.ToggleFlashlight();
                    lastClick = Time.time;
                }

                if (!RestrictionManager.restricted && !acs.clipping && !ac.isAiming && !pm.sprinting && cInput.GetButtonDown("Melee") && Time.time - lastQuickMeleeTime >= 0.6f)
                {
                    QuickMeleeWithWeapon();
                    lastQuickMeleeTime = Time.time;
                }

                if (currentGC.percent < 0.33f && !pe.hasEMP)
                {
                    reloadIndImpulse.curColor  = new Color(1f, 0.2f, 0f);
                    reloadIndImpulse.baseAlpha = 0.5f;
                    reloadIndImpulse.enabled   = true;
                }
                else
                {
                    reloadIndImpulse.curColor  = new Color(0.25f, 0.25f, 0.25f);
                    reloadIndImpulse.baseAlpha = 0.5f;
                    reloadIndImpulse.enabled   = false;
                }
            }
            else
            {
                reloadIndImpulse.curColor  = new Color(0.25f, 0.25f, 0.25f);
                reloadIndImpulse.baseAlpha = 0.5f;
                reloadIndImpulse.enabled   = false;
            }

            bool grenCanSwitch = true;
            if (grenadeManager != null && grenadeManager.curGrenade != null && grenadeManager.curGrenade.cannotSwitch)
            {
                grenCanSwitch = false;
            }

            if (grenCanSwitch && !dm.terminalVelocity && !pm.onLadder)
            {
                if (!ac.isAiming && !acs.clipping)
                {
                    int scrollSelect = curWeaponNum;
                    if (Mathf.Abs(Input.GetAxis("Mouse ScrollWheel")) > 0.08f)
                    {
                        scrollSelect -= (int)Mathf.Sign(Input.GetAxis("Mouse ScrollWheel"));
                        if (scrollSelect > 1)
                        {
                            scrollSelect = 0;
                        }
                        else if (scrollSelect < 0)
                        {
                            scrollSelect = 1;
                        }

                        SelectWeapon(scrollSelect);
                        return;
                    }
                }

                if (Input.GetKeyDown(KeyCode.Alpha0) && hands != null && currentWeaponTransform != hands.transform && !switching)
                {
                    SelectWeapon(-1);
                }
                if (Input.GetKeyDown(KeyCode.Alpha1) && heldWeapons[0] != null && currentGC != heldWeapons[0] && !switching)
                {
                    SelectWeapon(0);
                }
                if (Input.GetKeyDown(KeyCode.Alpha2) && heldWeapons[1] != null && currentGC != heldWeapons[1] && !switching)
                {
                    SelectWeapon(1);
                }
                if (Input.GetKeyDown(KeyCode.Alpha3) && meleeController != null && currentWeaponTransform != meleeController.transform && !switching)
                {
                    SelectWeapon(2);
                }
                if (grenadeManager != null && currentWeaponTransform != grenadeManager.transform && !switching && grenadeManager.canSwitchToGrenade)
                {
                    if (Input.GetKeyDown(KeyCode.Alpha4))
                    {
                        SelectWeapon(3);
                    }
                    else if (cInput.GetButtonDown("Throw Grenade"))
                    {
                        SelectWeapon(3);
                        pressedQuickThrow = true;
                        isQuickThrowState = true;
                    }
                }

                if (currentGC != null)
                {
                    if (cInput.GetButtonDown("Drop Weapon"))
                    {
                        startDropKeyTime = Time.time;
                    }

                    if (cInput.GetButtonUp("Drop Weapon"))
                    {
                        if (Time.time - startDropKeyTime < 0.2f)
                        {
                            DropWeapon(curWeaponNum);
                            FindWeaponToUse(false);
                        }
                    }
                }
            }
        }
    }