Example #1
0
        public virtual void DestinationReached()
        {
            if (!IsRoamingState())
            {
                return;
            }

            SetCurrWaypoint(nextWaypoint);

            if (currWaypoint.isFork)
            {
                var nextPoint = currWaypoint.ChooseNextWaypoint();
                SetNextWaypoint(nextPoint);
                SetDestination(nextPoint);
            }
            else if (currWaypoint.isEndpoint)
            {
                EventManager.Units.onEnemyBaseReached?.Invoke(this);
                KillUnit();
            }
            else
            {
                var nextPoint = currWaypoint.nextWaypoint;
                SetNextWaypoint(nextPoint);
                SetDestination(nextPoint);
            }
            //Debug.Log($"{gameObject.name} reached {currWaypoint.gameObject.name}");

            EventManager.Units.onEnemyReachedDestination?.Invoke(this);
        }