public override void UseAbility(AtackState attack) { if (_coroutine != null) { Reset(); } _state = attack; _coroutine = _state.StartCoroutine(Attack(_state)); _state.CollisionDetcted += OnPlayerAttack; }
private IEnumerable Attack(AtackState state) { float time = _usefulTime; while (time > 0) { state.Rigidbody.velocity = state.Rigidbody.velocity.normalized * _attackForce; time -= Time.deltaTime; yield return(new WaitForEndOfFrame()); } Reset(); AbilityEnded?.Invoke(); }
private void Awake() { //estas lineas son medio conflictivas para mí chaseState = new ChaseState(this); alertState = new AlertState(this); patrolState = new PatrolState(this); atackState = new AtackState(this); lookState = new LookState(this); //obteniendo el componente de navmesh navMeshAgent = GetComponent <NavMeshAgent> (); animator = GetComponent <Animator> (); controladorVision = GetComponent <ControladorVision> (); controladorNavMesh = GetComponent <ControladorNavMesh> (); controladorAnimator = GetComponent <ControladorAnimator> (); hashIDs = GetComponent <HashIDs> (); }
// Update is called once per frame void Update() { if (attackState == AtackState.Chase) { if (avoidanceStage != AvoidanceStage.NotAvoiding) { Avoid(); } else { Chase(GameManager.Instance.Players[0]); if (health.CurrentHealth < 3) { attackState = AtackState.Flee; } } } else if (attackState == AtackState.Flee) { if (avoidanceStage != AvoidanceStage.NotAvoiding) { Avoid(); } else { Flee(GameManager.Instance.Players[0]); if (health.CurrentHealth >= 3) { attackState = AtackState.Chase; } } } else { Debug.LogWarning("[SampleEnemyAI] Unexpected AttackType"); } }
private void Start() { atackstate = GetComponent <AtackState>(); }