public override void Enter() { base.Enter(); _hit = false; Collider[] player = Physics.OverlapSphere(_crow.transform.position, _crow.getPunishmentMaxDistance(), LayerMask.GetMask("Player")); _player = player.Length == 0 ? null : player[0]; if (_player == null) { _hit = false; } else { _hit = true; // leftLine = Quaternion.Euler(0,45,0) * _halja.getDirection();; //rightLine = Quaternion.Euler(0,-45,0) * _halja.getDirection(); // Debug.Log("the angle is 90? : " + Vector3.Angle(rightLine, leftLine)); // Debug.Log("i've got the player: "+_player); /* * Vector3 characterToCollider = (_player.transform.position-_halja.transform.position).normalized; * float dot = Vector3.Dot(characterToCollider, _halja.transform.forward*-1f); * if(dot < 0.5) * _hit = false; * if (dot >= Mathf.Cos(55)) * _hit = true; * else _hit = false;*/ } _animWaiter.StartCoroutine(_animWaiter.waitSomeSeconds(this, 0.4f)); //wait the end of teh aniamtion! }
public override void Update() { if (_entityData.health <= 0) { _stateMachine.ChangeState(_crow._death); } base.Update(); if (_isDetectingPlayer) { _crow.setDirection((_playerPosition.position - _crow.transform.position).normalized); float dist = Vector3.Distance(_crow.transform.position, _playerPosition.position); //Debug.Log("still detecting, DIST = "+ dist+ " and min = "+_halja.getPunishmentMinDistance()+" and max= "+_halja.getPunishmentMaxDistance() ); if (_crow.getChainOfDestinyMinDistance() <= dist && dist <= _crow.getChainOfDestinyMaxDistance() && Time.time >= (_crow.getChainOfDestinyClock() + _crow.getChainOfDestinyCountdown())) { usableMoveSet.Add(new Water_ChainOfDestiny(_entity, _stateMachine, "chainOfDestiny", _entityData, _crow, _playerPosition.position)); } if (_crow.getPunishmentMinDistance() <= dist && dist <= _crow.getPunishmentMaxDistance() && Time.time >= (_crow.getPunishmentClock() + _crow.getPunishmentCountdown())) { /* * Vector3 characterToCollider = (_playerPosition.position-_halja.transform.position).normalized; * float dot = Vector3.Dot(characterToCollider, _halja.transform.forward*-1f); * if(dot > 0.5)*/ usableMoveSet.Add(_crow._punishment); } if (usableMoveSet.Count > 0) { _stateMachine.ChangeState(usableMoveSet[UnityEngine.Random.Range(0, usableMoveSet.Count)]); } else { _entity.setDirection((_playerPosition.position - _entity.transform.position).normalized); if (Vector3.Distance(_crow.transform.position, _playerPosition.transform.position) >= 5f) { _entity.Move(_entity._entityData.movementSpeed); } } } else { _stateMachine.ChangeState(_crow._MoveState); } }
public override void Update() { base.Update(); if (_entityData.health <= 0) { _stateMachine.ChangeState(_crow._death); } if (_projectile == null) { _stateMachine.ChangeState(_crow._punishment); } else { _crow.lr.SetPosition(1, _projectile.transform.position); if (Vector3.Distance(_player.transform.position, _crow.transform.position) <= _crow.getPunishmentMaxDistance()) { _stateMachine.ChangeState(_crow._punishment); } } }