예제 #1
0
    private void UpdatePathing()
    {
        if (canMove)
        {
            if (Vector3.Distance(transform.position, currentPoint) > WPRadius)
            {
                transform.position = Vector3.MoveTowards(transform.position, currentPoint, Time.fixedDeltaTime * speed);
                transform.LookAt(currentPoint);
            }
            else
            {
                if (traversedPoints.Count > 0)
                {
                    traversedPoints.RemoveAt(0);
                    if (traversedPoints.Count > 0)
                    {
                        currentPoint = traversedPoints[0];
                    }

                    assignedPathCreator.DisplayPath();
                }
                else
                {
                    bool playersAreMoving = false;

                    foreach (PathMover player in players)
                    {
                        if (player.traversedPoints.Count > 0)
                        {
                            playersAreMoving = true;
                        }
                    }

                    if (!playersAreMoving)
                    {
                        canMove = false;
                        if (!isOnCashRegister)
                        {
                            ResetTransform();
                            ObjectiveTracker.Instance.ResetObjectives();
                        }

                        assignedPathCreator.ClearLineRenderer();
                    }
                }
            }
        }
    }