// Update is called once per frame void Update() { TickTimer(); bool resetMouseHearAlertTimer = false; bool resetMouseSmellAlertTimer = false; bool resetCatHearAlertTimer = false; bool resetCatSmellAlertTimer = false; foreach (GameObject cat in cats) { float d = Vector2.Distance(cat.transform.position, mouse.transform.position); // ALERT PLAYER if (d <= mouseHearRadius && cat.GetComponent <CatMovementController>().IsMoving() && mouseHearAlertTimer <= 0) { // alert player of cat sounds Vector2 vaguePosition = RandomOffsetPosition(cat.transform.position, soundOffset); Vector2 onScreenPosition = GetPositionInViewport(vaguePosition); Instantiate <GameObject>(soundAlert, onScreenPosition, Quaternion.identity); resetMouseHearAlertTimer = true; } if (d <= mouseSmellRadius && mouseSmellAlertTimer <= 0) { // alert player of cat smell Vector2 vaguePosition = RandomOffsetPosition(cat.transform.position, smellOffset); Vector2 onScreenPosition = GetPositionInViewport(vaguePosition); Instantiate <GameObject>(smellAlert, onScreenPosition, Quaternion.identity); resetMouseSmellAlertTimer = true; } // ALERT AI if (d <= catHearRadius && mouse.GetComponent <PlayerMovement>().isMoving && catHearAlertTimer <= 0) { // alert cats of mouse sounds Vector2 vaguePosition = RandomOffsetPosition(mouse.transform.position, soundOffset); //cat.GetComponent<SteeringArrive>().SetTarget(vaguePosition); // TODO: adjust to strategy catController.AddAlert(vaguePosition, CatController.HEAR_ALERT); resetCatHearAlertTimer = true; } if (d <= catSmellRadius && catSmellAlertTimer <= 0) { // alert cats of mouse smell Vector2 vaguePosition = RandomOffsetPosition(mouse.transform.position, smellOffset); //cat.GetComponent<SteeringArrive>().SetTarget(vaguePosition); // TODO: adjust to strategy catController.AddAlert(vaguePosition, CatController.SMELL_ALERT); resetCatSmellAlertTimer = true; } } if (resetMouseHearAlertTimer) { ResetMouseHearTimer(); } if (resetMouseSmellAlertTimer) { ResetMouseSmellTimer(); } if (resetCatHearAlertTimer) { ResetCatHearTimer(); } if (resetCatSmellAlertTimer) { ResetCatSmellTimer(); } }