Exemple #1
0
 public void OnUpdate(float deltaTime)
 {
     toPosition.Do(target =>
     {
         var speed             = gunDefinition.Speed * SpeedMultiplier * deltaTime;
         var currentPosition   = view.GetScreenPosition();
         var transformPosition = Vector2.MoveTowards(currentPosition, target, speed);
         view.SetAnchoredPosition(transformPosition);
         var distance = Vector2.Distance(currentPosition, target);
         if (distance <= 0.01f)
         {
             removeCollision.Execute(view);
             view.DestroyView();
         }
     });
 }
Exemple #2
0
        private void NextWayPoint()
        {
            var next = currentWayPointIndex.SelectOrElse(index => index + 1, () => 0);

            if (enemyViewModel.PathDefinition.WayPoints.Length > next)
            {
                currentWayPoint      = enemyViewModel.PathDefinition.WayPoints.ElementAt(next);
                currentWayPointIndex = next.ToMaybe();
                target = CanvasHelper.GetCanvasPosition(currentWayPoint.Position);
                view.RotateTowards(target);
            }
            else
            {
                removeCollision.Execute(view);
                view.DestroyView();
            }
        }