Exemplo n.º 1
0
 void OnTriggerStay(Collider other)
 {
     if (other.gameObject.CompareTag("Bug"))
     {
         SmallAI bugScript = other.gameObject.GetComponent <SmallAI>();
         if (flashLightScript.is_enabled == true && bugScript.getState() != "shouting" && bugScript.getState() != "shout" && flashLightScript.currentEnergy > 0 && bugScript.getState() != "runAway2" && bugScript.getState() != "kill")
         {
             //Debug.Log("hit Bug!");
             // bugScript.playHiss();
             bugScript.setState("runAway");
             bugScript.inFlashlightZone = true;
         }
     }
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (SceneManager.GetActiveScene().buildIndex == 2)
        {
            return;
        }

        if (GameManager.Instance.playerDead || GameManager.Instance.isEnd)
        {
            Destroy(gameObject);
        }

        if (!GameManager.Instance.playerDead)
        {
            int num = Physics.OverlapSphereNonAlloc(transform.position, 20, overlapResults);
            int i   = 0;

            while (i < num)
            {
                if (overlapResults[i].gameObject.CompareTag("Bug") && overlapResults[i].gameObject != null)
                {
                    GameObject bug   = overlapResults[i].gameObject;
                    SmallAI    bugAI = bug.GetComponent <SmallAI>();
                    if (bugAI.getState() != "kill" && bugAI.getState() != "shouting" && bugAI.getState() != "shout" && bugAI.getState() != "runAway" && bugAI.getState() != "runAway2")
                    {
                        bugAI.setState("runAway2");
                        bugAI.FlareBullet = gameObject;
                    }
                }
                i++;
            }
        }

        if (myCoroutine == true)

        {
            flarelight.intensity = Random.Range(2f, 6.0f);
        }
        else

        {
            flarelight.intensity            = Mathf.Lerp(flarelight.intensity, 0f, Time.deltaTime * smooth);
            flarelight.range                = Mathf.Lerp(flarelight.range, 0f, Time.deltaTime * smooth);
            flaresound.volume               = Mathf.Lerp(flaresound.volume, 0f, Time.deltaTime * smooth);
            smokepParSystem.maxParticleSize = Mathf.Lerp(smokepParSystem.maxParticleSize, 0f, Time.deltaTime * 5);
        }
    }