void Awake() { announcerController = GameObject.FindGameObjectWithTag("Announcer").GetComponent <AnnouncerController>(); announcerController.OnUnitExplode += ExplosionResponse; announcerController.OnChumpDied += ChumpDiedResponse; myMaterial = GetComponent <MeshRenderer>().material; normalColor = myMaterial.color; myState = CHUMPSTATE.WANDER; myNav = GetComponent <NavMeshAgent>(); }
//activate panic state, change color to panic color, increase speed to panic speed, choose panic destination directly //opposite from panice cause location void ActivatePanic(Vector3 panicCauseLocation) { myState = CHUMPSTATE.PANIC; myMaterial.color = Color.yellow; myNav.speed = speedMax * 1.5f; Vector3 panicHeading = transform.position - panicCauseLocation; Vector3 panicDestination = (panicHeading.normalized * Constants.mapRadius) + transform.position; panicDestination.y = transform.position.y; //Debug.Log(panicDestination); if (myNav.enabled) { myNav.SetDestination(panicDestination); } }
//turn off panic, return to normal color and activate wander state void DeactivatePanic() { myState = CHUMPSTATE.WANDER; myMaterial.color = normalColor; ChumpWander(); }