private void onSoundHeard(Vector3 soundPosition) { Debug.Log("GuardAI::SoundHeard"); _lastSoundPosition = soundPosition; if (_guardFlow == GUARD_AI.SLEEP) { _guardFlow = GUARD_AI.NOTICED; anim.SetTrigger("wakeUp"); } else if (_guardFlow == GUARD_AI.NOTICED) { _guardFlow = GUARD_AI.ON_ALERT; anim.SetTrigger("walk"); } }
void OnTriggerEnter2D(Collider2D col) { if (_guardFlow != GUARD_AI.SLEEP && _isSlothOutOfHisCage && col.tag == "Player") { col.gameObject.transform.position = _slothInitialPosition; _isSlothOutOfHisCage = false; _guardFlow = GUARD_AI.BACK_TO_DESK; GameObject doorGO = GameObject.FindGameObjectWithTag("Door"); Door door = doorGO.GetComponent <Door>(); door.Close(); Camera.main.gameObject.GetComponent <CameraControl>().checkPointReached = true; foreach (GameObject go in DiggingAreas) { go.SetActive(true); } } }
private void Noticed() { gameObject.GetComponent <SpriteRenderer>().sprite = IdleGuard; Debug.Log("GuardAI::Noticed"); _noticedTimeCounter += Time.deltaTime; if (_isSlothOutOfHisCage) { _guardFlow = GUARD_AI.ON_ALERT; _noticedTimeCounter = 0; anim.SetTrigger("walk"); } else if (_noticedTimeCounter >= 5.0f) { goToSleep(); _noticedTimeCounter = 0; anim.SetTrigger("sleep"); } }
private void onAlert() { Debug.Log("GuardAI::onAlert"); if (_isSlothOutOfHisCage) { Debug.Log("GuardAI::_isSlothOutOfHisCage::true"); MoveTo(_sloth.transform.position); } else { Debug.Log("GuardAI::_isSlothOutOfHisCage::false"); if (_moveToTargetReached) { Debug.Log("GuardAI::_moveToTargetReached::true"); _moveToTargetReached = false; _guardFlow = GUARD_AI.BACK_TO_DESK; } else { Debug.Log("GuardAI::_moveToTargetReached::false"); MoveTo(_lastSoundPosition); } } }
private void goToSleep() { _noticedTimeCounter = 0; _guardFlow = GUARD_AI.SLEEP; gameObject.GetComponent <SpriteRenderer>().sprite = SleepingGuard; }
private void Noticed(){ gameObject.GetComponent<SpriteRenderer>().sprite = IdleGuard; Debug.Log("GuardAI::Noticed"); _noticedTimeCounter += Time.deltaTime; if(_isSlothOutOfHisCage){ _guardFlow = GUARD_AI.ON_ALERT; _noticedTimeCounter = 0; anim.SetTrigger("walk"); } else if(_noticedTimeCounter >= 5.0f){ goToSleep(); _noticedTimeCounter = 0; anim.SetTrigger("sleep"); } }
private void onAlert(){ Debug.Log("GuardAI::onAlert"); if(_isSlothOutOfHisCage){ Debug.Log("GuardAI::_isSlothOutOfHisCage::true"); MoveTo(_sloth.transform.position); }else{ Debug.Log("GuardAI::_isSlothOutOfHisCage::false"); if(_moveToTargetReached){ Debug.Log("GuardAI::_moveToTargetReached::true"); _moveToTargetReached = false; _guardFlow = GUARD_AI.BACK_TO_DESK; }else{ Debug.Log("GuardAI::_moveToTargetReached::false"); MoveTo(_lastSoundPosition); } } }
void OnTriggerEnter2D(Collider2D col){ if(_guardFlow != GUARD_AI.SLEEP && _isSlothOutOfHisCage &&col.tag == "Player"){ col.gameObject.transform.position = _slothInitialPosition; _isSlothOutOfHisCage = false; _guardFlow = GUARD_AI.BACK_TO_DESK; GameObject doorGO = GameObject.FindGameObjectWithTag("Door"); Door door = doorGO.GetComponent<Door>(); door.Close(); Camera.main.gameObject.GetComponent<CameraControl>().checkPointReached = true; foreach(GameObject go in DiggingAreas){ go.SetActive(true); } } }
private void goToSleep(){ _noticedTimeCounter = 0; _guardFlow = GUARD_AI.SLEEP; gameObject.GetComponent<SpriteRenderer>().sprite = SleepingGuard; }
private void onSoundHeard(Vector3 soundPosition){ Debug.Log("GuardAI::SoundHeard"); _lastSoundPosition = soundPosition; if(_guardFlow == GUARD_AI.SLEEP){_guardFlow = GUARD_AI.NOTICED;anim.SetTrigger("wakeUp");} else if(_guardFlow == GUARD_AI.NOTICED){_guardFlow = GUARD_AI.ON_ALERT;anim.SetTrigger("walk");} }