protected override void Update() { bool reachedDest = agent.remainingDistance <= agent.stoppingDistance; switch (status) { case Status.IsAttackingTower: base.Update(); if (currentAttackedEnemy == null) { agent.SetDestination(currentPointOfDestination); status = Status.IsOnNormalPath; } if (currentAttackedEnemy.gameObject.GetComponent <HomeBase>() != null) { status = Status.IsAttackingHomeBase; } break; case Status.IsOnNormalPath: if (reachedDest) { status = Status.IsSearchingForNextNode; } break; case Status.IsSearchingForNextNode: currentDestinationNode = currentDestinationNode.GetRandomNextNode(); if (currentDestinationNode != null) { currentPointOfDestination = currentDestinationNode.GetRandomDestination(); agent.SetDestination(currentPointOfDestination); status = Status.IsOnNormalPath; } else { status = Status.ReachedHomeBase; } break; case Status.IsAttackingHomeBase: base.Update(); break; } }