Exemple #1
0
        public void OnFixedUpdate()
        {
            toPosition.DoWhenAbsent(() =>
            {
                var target = Vector2.zero;
                if (Position.PlayerLocation.Equals(gunDefinition.ToPosition))
                {
                    GameProvider.GetGameView().ToMaybe()
                    .Do(game =>
                    {
                        var playerPoint = game.GetPlayerPoints().Choose();
                        var tileSize    = CanvasHelper.GetTileSize();
                        var multiplier  = random.Next(2) == 1 ? 1 : -1;
                        if (CanvasHelper.IsLeft(playerPoint.Position) ||
                            CanvasHelper.IsRight(playerPoint.Position))
                        {
                            target = playerPoint.ScreenPosition +
                                     new Vector2(0f, random.Next((int)(tileSize.y)) * multiplier);
                        }
                        else
                        {
                            target = playerPoint.ScreenPosition +
                                     new Vector2(random.Next((int)(tileSize.x * 2)) * multiplier, 0f);
                        }
                    });
                }
                else
                {
                    target = CanvasHelper.GetCanvasPosition(gunDefinition.ToPosition, view.MainRectTransform);
                }

                toPosition = target.ToMaybe();
                view.RotateTowards(target);
            });
        }
Exemple #2
0
 public void OnFixedUpdate()
 {
     currentWayPointIndex.DoWhenAbsent(() =>
     {
         view.SetAnchoredPosition(CanvasHelper.GetCanvasPosition(enemyViewModel.PathDefinition.SpawnPosition));
         NextWayPoint();
     });
 }
 public void OnFixedUpdate()
 {
     toPosition.DoWhenAbsent(() =>
     {
         var start = CanvasHelper.GetCanvasPosition(powerUpDefinition.FromPosition, view.MainRectTransform);
         view.SetAnchoredPosition(start);
         var target = CanvasHelper.GetCanvasPosition(powerUpDefinition.ToPosition, view.MainRectTransform);
         toPosition = target.ToMaybe();
     });
 }
Exemple #4
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();
            }
        }