// Update is called once per frame
    void Update()
    {
        if (localHealth != health)
        {
            SplatterBloodCamera.Play();
            //FrameBloodCamera.Play();
            hitSound.Play();
            bloodRainController.Attack(49);
            localHealth = health;
            StopAllCoroutines();
            StartCoroutine(WaitingForRegen());
        }

        if (health < 0 && !dead)
        {
            dead = true;
            StopAllCoroutines();
            this.GetComponent <Animation>().Play("death");
        }

        if (dead)
        {
            Invoke("EndGame", 4.0f);
        }
    }
 private void LensWetIN()
 {
     waterDown.gameObject.SetActive(true);
     waterUp.gameObject.SetActive(false);
     waterSlpashOut.StopImmidiate();
     waterSlpashIN.Play();
     firstTimeIN  = false;
     firstTimeOut = true;
 }
Beispiel #3
0
    void Start()
    {
        if (BloodCorners != null)
        {
            BloodCorners.Alpha = 0;
            BloodCorners.Play();
        }
        GameObject[] remaining = GameObject.FindGameObjectsWithTag("Player");
        string       myname    = this.gameObject.name + "(Clone)";

        foreach (GameObject clone in remaining)
        {
            if (clone.name == myname)
            {
                GameObject.Destroy(clone);
            }
        }
        SetRagdollState(false);
        if (NPC == false)
        {
            originalCamera    = this.GetComponentInChildren <Camera> ();
            originalCamParent = originalCamera.transform.parent;
        }
        if (deathPosition == null && NPC == false)
        {
            deathPosition = this.transform.GetChild(6).GetChild(1).GetChild(2).gameObject;
        }
        if ((anim.Length < 1 || anim[0] == null) && NPC == false)
        {
            if (this.GetComponentInChildren <Animator> ())
            {
                anim[0] = this.GetComponentInChildren <Animator> ();
            }
        }
        if ((playerCamera == null && guiOnHit != null) && NPC == false)
        {
            if (this.GetComponent <Camera> ())
            {
                playerCamera = this.GetComponent <Camera> ();
            }
            else if (NPC == false)
            {
                playerCamera = this.GetComponentInChildren <Camera> ();
            }
        }
        if (audioSource == null)
        {
            audioSource = this.GetComponent <AudioSource> ();
        }
        originalVolume = audioSource.volume;
        if (NPC == false)
        {
            health       = GameObject.FindGameObjectWithTag("GameManager").GetComponent <PlayerManager> ().currentPlayerHealth;
            regeneration = GameObject.FindGameObjectWithTag("GameManager").GetComponent <PlayerManager> ().currentPlayerRegen;
        }
    }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        RenderSettings.fog      = useFog;
        RenderSettings.fogColor = fogColor;
        float h = Mathf.Max(mainCamera.transform.position.y, 0.1f);

        fogDensity = Mathf.Min(0.05f, Mathf.Pow(h, -1.3f));
        RenderSettings.fogDensity  = fogDensity;
        city.blockVisibilityRadius = Mathf.Clamp(h / 10, 0.3f, 1f) * 1000;// 100 * Mathf.Max(h, 0.3f, 10f) * ();
        mainCamera.backgroundColor = fogColor;

        Color ff = fogColor;

        ff.a = Mathf.Max(0.05f, groundDensity * Mathf.Pow(h, 0.6f));
        foreach (Renderer fog in floorFog)
        {
            fog.material.SetColor("_TintColor", ff);
        }


        for (int i = 0; i < floorFog.Length; i++)
        {
            floorFog[i].transform.position = new Vector3(0, Mathf.Pow(h * (0.5f * i + 0.1f), 0.6f) - 0.1f, 0);
        }

        //this is not the best to get the angle
        Vector3 camPosition    = mainCamera.transform.position;
        Vector3 cameraVelocity = cameraPrevPosition - camPosition;

        cameraPrevPosition = mainCamera.transform.position;
        rain.RainHeight    = mainCamera.transform.position.y + 10;
        if (rainAmount > 0 && rainExposed)
        {
            if (!rainOnCamera.IsPlaying)
            {
                rainOnCamera.Play();
            }

            rainOnCamera.GlobalWind = cameraVelocity;
            rain.RainIntensity      = rainAmount;
        }
        else
        {
            if (rainOnCamera.IsPlaying)
            {
                rainOnCamera.Stop();
            }

            rain.RainIntensity = rainAmount * 0.9f;
        }
        rainOnCamera.Alpha = rainAmount;
    }
Beispiel #5
0
 void PlayExitUnderWater()
 {
     if (enteredWater == true)
     {
         exitPool.Play();
         enteredWater              = false;
         RenderSettings.fog        = defaultFog;
         RenderSettings.fogColor   = defaultFogColor;
         RenderSettings.fogDensity = defaultFogDensity;
         RenderSettings.skybox     = defaultSkybox;
         if (!enterWaterSplash)
         {
             return;
         }
         Vector3    waterSpawn = new Vector3(this.transform.position.x, water_height, this.transform.position.z);
         GameObject splash     = Instantiate(enterWaterSplash, waterSpawn, Quaternion.identity) as GameObject;
         Destroy(splash, 1.0f);
         PlayRandomSound(exitUnderWaterSounds);
     }
 }
Beispiel #6
0
 void PlayEnterUnderWater()
 {
     if (enteredWater == false)
     {
         enterPool.Play();
         enteredWater              = true;
         RenderSettings.fog        = true;
         RenderSettings.fogColor   = underwaterColor;
         RenderSettings.fogDensity = fogAmount;
         RenderSettings.skybox     = null;
         if (!enterWaterSplash)
         {
             return;
         }
         Vector3    waterSpawn = new Vector3(this.transform.position.x, water_height, this.transform.position.z);
         GameObject splash     = Instantiate(enterWaterSplash, waterSpawn, Quaternion.identity) as GameObject;
         Destroy(splash, 1.0f);
         PlayRandomSound(enterUnderWaterSounds);
     }
 }
Beispiel #7
0
    void Update()
    {
        currentAlpha = (100 - HP) / 100f;
        if (currentAlpha != oldAlpha)
        {
            lerpTime  = 0f;
            lerpStart = oldAlpha;
            oldAlpha  = currentAlpha;
        }

        FrameBloodCamera.Play();

        timeElapsed += Time.deltaTime;
        if (timeElapsed > FrameEffectInterval)
        {
            timeElapsed = timeElapsed - FrameEffectInterval;
        }

        lerpTime += Smooth * Time.deltaTime;

        if (this.HP == 100)
        {
            FrameBloodCamera.Alpha = 0f;
        }
        else if (this.HP >= 70)
        {
            FrameBloodCamera.Alpha = currentAlpha * LerpTime(lerpTime) * hpHigh.Evaluate(timeElapsed);
        }
        else if (this.HP >= 20)
        {
            FrameBloodCamera.Alpha = currentAlpha * LerpTime(lerpTime) * hpMid.Evaluate(timeElapsed);
        }
        else
        {
            FrameBloodCamera.Alpha = currentAlpha * LerpTime(lerpTime) * hpLow.Evaluate(timeElapsed);
        }
    }
Beispiel #8
0
        private IEnumerator FadeInProgram()
        {
            StartCoroutine(AudioFader.FadeIn(_rainAudio, FadeTime, 0.2f));
            var rain     = 0.1f;
            var duration = 0f;

            while (duration < FadeTime)
            {
                rain += MaxRain / (FadeTime * FadeSteps);
                _rainEmission.rateOverTime = rain;
                yield return(new WaitForSeconds(1f / FadeSteps));

                duration += 1f / FadeSteps;
            }
            if (!_rainVision.enabled)
            {
                _rainVision.enabled = true;
            }
            else
            {
                _rainVision.Play();
            }
            StartCoroutine(ThunderProgram());
        }
Beispiel #9
0
    private void OnGUI()
    {
        if (playMode != PlayMode.None)
        {
            if (GuiButton("GoBack"))
            {
                StopAll();
                playMode = PlayMode.None;
            }
        }
        else
        {
            if (GuiButton("Blood"))
            {
                playMode = PlayMode.Blood;
            }

            if (GuiButton("Splash (in)"))
            {
                playMode = PlayMode.SplashIn;
            }

            if (GuiButton("Splash (out)"))
            {
                playMode = PlayMode.SplashOut;
            }

            if (GuiButton("Frozen"))
            {
                frozenValue = 0f;
                frozenRain.Play();
                windAudio.Play();
                playMode = PlayMode.Frozen;
            }
        }


        if (playMode == PlayMode.Blood)
        {
            if (GuiButton("Hit Damage"))
            {
                if (bloodRainController.HP <= 30)
                {
                    bloodRainController.Reset();
                    bloodRainController.HP = 100;
                }
                else
                {
                    damageAudio.Play();
                    bloodRainController.Attack(30);
                }
            }
            if (GuiButton("Reset"))
            {
                bloodRainController.Reset();
            }
            GUILayout.Label("Current HP = " + bloodRainController.HP.ToString());
            return;
        }

        if (playMode == PlayMode.SplashIn)
        {
            if (GuiButton("Play Effect"))
            {
                splashInAudio.Play();
                splashInRain.Refresh();
                splashInRain.Play();
            }
        }

        if (playMode == PlayMode.SplashOut)
        {
            if (GuiButton("Play Effect"))
            {
                splashOutAudio.Play();
                splashOutRain.Refresh();
                splashOutRain.Play();
            }
        }

        if (playMode == PlayMode.Frozen)
        {
            frozenRain.Alpha = frozenValue;
            GUILayout.Label("Frozen Value (Sliding right to freeze)");
            frozenValue      = GUILayout.HorizontalSlider(frozenValue, 0f, 1f, GUILayout.Height(40));
            windAudio.volume = frozenValue;
        }
    }
Beispiel #10
0
    public void ApplyDamage(float damage, GameObject sender = null, bool stagger = false, bool isPunch = false)
    {
        if (isDead == false)
        {
            bool isDamaged = true;
            if (isPunch == true && useCombatController == true && GetComponent <CombatController> ().isBlocking == true)
            {
                if (NPC == true && anim [0].GetCurrentAnimatorStateInfo(0).IsTag("defend"))
                {
                    isDamaged = false;
                }
                else if (NPC == false)
                {
                    isDamaged = false;
                }
            }
            if (isDamaged == true)
            {
                health  -= damage;
                guiAlpha = 1.0f;
                gotHit   = true;

                if (BloodCorners != null)
                {
                    BloodCorners.Alpha = 1;
                }
                if (SplatterEffects != null)
                {
                    SplatterEffects.Play();
                }
                //if was falling play ragdoll
                if (NPC == false)
                {
                    if (anim [0].GetCurrentAnimatorStateInfo(0).IsName("Falling"))
                    {
                        SetRagdollState(true);
                    }
                }
                else
                {
                    this.GetComponentInChildren <AIRig> ().AI.WorkingMemory.SetItem <bool>("damaged", true);
                    if (sender != null)
                    {
                        this.GetComponentInChildren <AIRig> ().AI.WorkingMemory.SetItem <GameObject>("damage_giver", sender);
                    }
                }
                if (hitSounds.Length > 0)
                {
                    StartCoroutine(PlayHitSound());
                }
                if ((staggerOnEveryHit == true || stagger == true) && anim [0] != null)
                {
                    foreach (Animator animator in anim)
                    {
                        animator.SetTrigger("damaged");
                    }
                    if (sender == null)
                    {
                        damageNumber = 0.0f;
                        foreach (Animator animator in anim)
                        {
                            animator.SetFloat("damagedNumber", damageNumber);
                            animator.SetTrigger("damaged");
                        }
                    }
                    else
                    {
                        Vector3 direction = (sender.transform.position - this.transform.position).normalized;
                        float   angle     = Vector3.Angle(direction, this.transform.forward);
                        if (angle > 50 && angle < 130)                          //side hit
                        {
                            Vector3 pos = transform.TransformPoint(sender.transform.position);
                            if (pos.x < 0)
                            {
                                if (debugDirHit == true)
                                {
                                    Debug.Log("Left");
                                }
                                damageNumber = 0.6f;
                                foreach (Animator animator in anim)
                                {
                                    animator.SetFloat("damagedNumber", damageNumber);
                                }
                            }
                            else
                            {
                                if (debugDirHit == true)
                                {
                                    Debug.Log("Right");
                                }
                                damageNumber = 1.0f;
                                foreach (Animator animator in anim)
                                {
                                    animator.SetFloat("damagedNumber", damageNumber);
                                }
                            }
                        }
                        else if (angle < 50 && angle > -1)
                        {
                            if (debugDirHit == true)
                            {
                                Debug.Log("Front Hit");
                            }
                            damageNumber = 0.0f;
                            foreach (Animator animator in anim)
                            {
                                animator.SetFloat("damagedNumber", damageNumber);
                            }
                        }
                        else if (angle > 130 && angle < 270)
                        {
                            if (debugDirHit == true)
                            {
                                Debug.Log("Back Hit");
                            }
                            damageNumber = 0.3f;
                            foreach (Animator animator in anim)
                            {
                                animator.SetFloat("damagedNumber", damageNumber);
                            }
                        }
                        foreach (Animator animator in anim)
                        {
                            animator.SetTrigger("damaged");
                        }
                    }
                }
                if (this.GetComponent <AIBehavior> ())
                {
                    this.GetComponent <AIBehavior> ().memory.currentState = "Hostile";
                }
                if (this.GetComponent <AnimController> ())
                {
                    this.GetComponent <AnimController> ().updateState("Hostile");
                }
            }
        }
    }
 //初期化処理
 private void Start()
 {
     AmehurashiCont = -1;
     rainCamera.Play();
 }
Beispiel #12
0
 public void Attack(int damage)
 {
     HP = Mathf.Max(0, HP - damage);
     SplatterBloodCamera.Refresh();
     SplatterBloodCamera.Play();
 }
Beispiel #13
0
 void STARTRAIN()
 {
     RC.Play();
 }