public override void Enter() { base.Enter(); _hit = false; Collider[] player = Physics.OverlapSphere(_halja.transform.position, _halja.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 bool chainAnimation(Vector3 hitPoint){ * if(_counter <= _dist){ //just a simple animation * _counter += .1f * _lineDrawSpeed; * float x = Mathf.Lerp(0,_dist,_counter); * Vector3 pointA = _halja.getThrowChainPosition().position; * Vector3 pointB = hitPoint;//_halja.lr.GetPosition(1); //hitPoint; * Vector3 pointAngleLine = x * Vector3.Normalize(pointB-pointA) + pointA; * _halja.lr.SetPosition(1,pointAngleLine); * return false; // animation not end * } * else { * return true; * } * }*/ public override void Update() { base.Update(); if (_projectile == null) { _stateMachine.ChangeState(_halja._whipLashes); } else { _halja.lr.SetPosition(1, _projectile.transform.position); if (Vector3.Distance(_player.transform.position, _halja.transform.position) <= _halja.getPunishmentMaxDistance()) { _stateMachine.ChangeState(_halja._punishment); } } }
public override void Update() { if (_entityData.isStun) { return; } if (_entityData.health <= 0) { _stateMachine.ChangeState(_halja._deathState); } base.Update(); // if(_halja.getHealth() < (50f * _halja.GetComponent<Enemy>().getMaxHealth())/100f){ //se ha meno della metà della vita /* * if() * _halja.GetIceCrow().setVulnerability(true); * _halja.GetWaterCrow().setVulnerability(true); */ // } // else{ if (_isDetectingPlayer) { _halja.setDirection((_playerPosition.position - _halja.transform.position).normalized); float dist = Vector3.Distance(_halja.transform.position, _playerPosition.position); //Debug.Log("still detecting, DIST = "+ dist+ " and min = "+_halja.getPunishmentMinDistance()+" and max= "+_halja.getPunishmentMaxDistance() ); if (_halja.getChainOfDestinyMinDistance() <= dist && dist <= _halja.getChainOfDestinyMaxDistance() && Time.time >= (_halja.getChainOfDestinyClock() + _halja.getChainOfDestinyCountdown())) { usableMoveSet.Add(new Halja_ChainOfDestiny(_entity, _stateMachine, "chainOfDestiny", _entityData, _halja, _playerPosition.position)); } if (_halja.getPunishmentMinDistance() <= dist && dist <= _halja.getPunishmentMaxDistance() && Time.time >= (_halja.getPunishmentClock() + _halja.getPunishmentCountdown())) { /* * Vector3 characterToCollider = (_playerPosition.position-_halja.transform.position).normalized; * float dot = Vector3.Dot(characterToCollider, _halja.transform.forward*-1f); * if(dot > 0.5)*/ usableMoveSet.Add(_halja._punishment); } if (_halja.getWhipLashesMinDistance() <= dist && dist <= _halja.getWhiplashesMaxDistance() && Time.time >= (_halja.getWhipLashesClock() + _halja.getWhiplashesCountdown())) { usableMoveSet.Add(_halja._whipLashes); } 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(_halja.transform.position, _playerPosition.transform.position) >= 5f) { if (_entity._entityData.isSlowed) { _entity.Move(_entity._entityData.speedWhenSlowedArea); } else { _entity.Move(_entity._entityData.movementSpeed); } } } } else { _playerPosition = _halja.GetIceCrow().getPlayerPosition(); if (_playerPosition != null) { _stateMachine.ChangeState(new Halja_ChaseState(_entity, _stateMachine, "chase", _entityData, _halja, _playerPosition.position)); } _playerPosition = _halja.GetWaterCrow().getPlayerPosition(); if (_playerPosition != null) { _stateMachine.ChangeState(new Halja_ChaseState(_entity, _stateMachine, "chase", _entityData, _halja, _playerPosition.position)); } else { _stateMachine.ChangeState(_halja._moveState); } } //} //else _stateMachine.ChangeState(_halja._moveState); //} }