// Use this for initialization void Start() { _state = ShepardState.IDLE; _currentSearchDelay = 0; _startPosition = new Vector2(transform.position.x, transform.position.y); _player = GameObject.FindGameObjectWithTag("Player"); _alertSounds = Resources.LoadAll <AudioClip>(_alertSoundPath); }
public void setChasing() { if (_state == ShepardState.CHASE) { return; } _state = ShepardState.CHASE; GetComponent <AudioSource>().PlayOneShot(_alertSounds[Random.Range(0, _alertSounds.Length)]); }
private void doSearch() { if (_searchLength < 0) { _state = ShepardState.IDLE; _spriteBobber.deactivate(); return; } if (_currentSearchDelay >= 0) { _currentSearchDelay -= Time.deltaTime; } else { Vector2 point = Random.insideUnitCircle * 4; point.x += transform.position.x; point.y += transform.position.y; _currentSearchAction = Random.Range(0, 2); _target = point; _currentSearchDelay = Random.Range(0.5f, 1.0f); } if (_currentSearchAction == 0) { _visionCone.GetComponent <ShepardVisionCone>().setLookTarget(_target); _spriteBobber.deactivate(); } else if (_currentSearchAction == 1) { moveTowardsPoint(_target); _visionCone.GetComponent <ShepardVisionCone>().setLookTarget(_target); if (Vector2.Distance(transform.position, _target) < 0.1) { _currentSearchDelay = -1; } } _searchLength -= Time.deltaTime; }
public void setSearching(float length) { _state = ShepardState.SEARCH; _searchLength = length; _currentSearchDelay = -1; }
public void setInvestigate(Vector2 targetPos) { _state = ShepardState.INVESTIGATE; _target = new Vector2(targetPos.x, targetPos.y); }
public void setIdle() { _state = ShepardState.IDLE; }