Exemplo n.º 1
0
        public new void Move()
        {
            CalculatePath();

            if (CurrentPath.Any() && CurrentPath[0] != null)
            {
                MoveToNeighborPos(CurrentPath[0].X, CurrentPath[0].Y);
            }
            else
            {
                SimplePath();
            }
            base.Move();
        }
Exemplo n.º 2
0
 private void Update()
 {
     if (Next.HasValue)
     {
         var targetPos = Map.GetCellCenter(Next.Value);
         if (Vector2.Distance(transform.position, targetPos) > 0.1f)
         {
             transform.position = Vector3.MoveTowards(transform.position, targetPos, Time.deltaTime * Speed);
         }
         else
         {
             Next = CurrentPath.Any() ? CurrentPath.Dequeue() : (Vector2Int?)null;
         }
     }
     else if (CurrentPath != null && CurrentPath.Any())
     {
         Next = CurrentPath.Dequeue();
     }
     else
     {
         Moving = false;
     }
 }