private void Start() { _transform = transform; _target = null; _currentAction = AgentBehaviourAction.Idle; _targetLocator = GetComponent <AgentTargetLocator>(); }
private void SelectBehaviour() { AgentBehaviourAction selectedAction = AgentBehaviourAction.Idle; if (CurrentTargetIsValid()) { float distanceToTarget = Vector3.Distance(_target.Position, _transform.position); if (BehaviourShouldBeMoveToTarget(distanceToTarget)) { selectedAction = AgentBehaviourAction.MoveToTarget; } else if (BehaviourShouldBeMovingBasicAction(distanceToTarget)) { selectedAction = AgentBehaviourAction.MovingBasicAction; } else { selectedAction = AgentBehaviourAction.BasicAction; } } if (selectedAction != _currentAction) { _currentAction = selectedAction; if (SetActionEvent != null) { SetActionEvent.Invoke(_currentAction); } } }
private void HandleSetActionEvent(AgentBehaviourAction action) { Moving = false; Attacking = false; switch (action) { case AgentBehaviourAction.MoveToTarget: Moving = true; break; case AgentBehaviourAction.BasicAction: Attacking = true; break; case AgentBehaviourAction.MovingBasicAction: Moving = true; Attacking = true; break; } }