// Use this for initialization void Start() { gc = FindObjectOfType <GameController>(); Ghost = this.gameObject; // Get a reference to the player object if (Player == null) { GameObject[] t = GameObject.FindGameObjectsWithTag("Player"); target = t[0].transform; } else { target = Player.transform; } agent = GetComponent <NavMeshAgent>(); //setup the nav agent //Get references to the color control on orbs orbControllOne = OrbOne.GetComponent <GhostOrbController>(); orbControllTwo = OrbTwo.GetComponent <GhostOrbController>(); orbControllThree = OrbThree.GetComponent <GhostOrbController>(); handOff = true; warned = false; enragedTime = 10f; enrageTimer = 0f; ghostMood = GhostMood.Idle; }
private void Cower() { if (Player.GetComponent <PlayerController>().flashlight.enabled) { RaycastHit hit; Vector3 f = Player.GetComponent <PlayerController>().mainCamera.transform.forward; if (Physics.SphereCast(Player.transform.position, 2f, f, out hit, 4f)) { if (hit.transform.tag == "Enemy") { ghostMood = GhostMood.Idle; handOff = true; } } } if (distanceToTarget < closeDistance * 1.5) { nearTarget = true; } if (!audioS.isPlaying && !warned && nearTarget) { audioS.PlayOneShot(ghostMusic); warned = true; } if (distanceToTarget < closeDistance) { glitchList.SelectRandomGlitch(); ghostMood = GhostMood.Idle; handOff = true; } }
private void Enraged() { if (distanceToTarget < closeDistance * 4) { nearTarget = true; } if (nearTarget) { enrageTimer += Time.deltaTime; if (!audioS.isPlaying && !warned) { audioS.PlayOneShot(ghostMusic); warned = true; } } if (enrageTimer > enragedTime) { enrageTimer -= enragedTime; ghostMood = GhostMood.Idle; handOff = true; } if (distanceToTarget < closeDistance) { glitchList.SelectRandomGlitch(); ghostMood = GhostMood.Idle; handOff = true; } }
private void Search() { if (distanceToTarget < closeDistance * 2.5 && !nearTarget) { nearTarget = true; lastPostion = target.position; } if (distanceToTarget > closeDistance * 3) { nearTarget = false; } if (!audioS.isPlaying && !warned && nearTarget) { audioS.PlayOneShot(ghostMusic); warned = true; } if (distanceToTarget < closeDistance) { if (Vector3.Distance(target.position, lastPostion) < 0.05f && !Player.GetComponent <PlayerController>().flashlight.enabled) { ghostMood = GhostMood.Idle; handOff = true; } else { glitchList.SelectRandomGlitch(); ghostMood = GhostMood.Idle; handOff = true; } } }
private void Idle() { coolOffTimer += Time.deltaTime; if (coolOffTimer > coolOffTime) { coolOffTimer -= coolOffTime; ghostMood = FindMood(); handOff = true; } }