protected override void Step(float deltaTime) { if (_attackerable.HasTarget()) { _movable.StopMovement(); _movable.Anchor(); if (!_attackerable.OnCooldown) { var target = _attackerable.Targets[0]; _attackerable.Attack(target); } } //Aggroable is optional so we check for null else if (_aggroable != null && _aggroable.HasTarget()) { _movable.UnAnchor(); var target = _aggroable.Targets[0]; var position = target.transform.position; _movable.MoveTo(position); _movable.StartMovement(); } else { _movable.UnAnchor(); _movable.StartMovement(); _movable.MoveTo(_destenation); } }
// Update is called once per frame void Update() { if (_attackerable.HasTarget() && !_attackerable.OnCooldown) { _attackerable.Attack(_attackerable.Targets[0]); } }
public override void PreStep(float deltaStep) { var enemies = ScanForEnemies(); if (enemies.Length == 0) { _movable.MoveTo(_destenation); } else { _movable.Stop(); _attackerable.Attack(enemies[0]); } }