Ejemplo n.º 1
0
        private void ChangeTargetPoint(bool isLast = false)
        {
            TargetPointIndex++;
            if (TargetPointIndex >= TargetPointList.Count)
            {
                TargetPointIndex = 0;
                if (TargetRail.NextActiveRail == null)
                {
                    if (!Turning && !TargetRail.WayPoints.IsNullOrEmpty())
                    {
                        Turning         = true;
                        TargetPointList = TargetRail.WayPoints;
                    }
                    else
                    {
                        Turning         = false;
                        TargetPointList = TargetRail.WayPoints;
                    }
                }
                else
                {
                    TargetRail      = TargetRail.NextActiveRail;
                    TargetPointList = TargetRail.WayPoints;

                    var last = TargetRail;
                    while (last != null)
                    {
                        last.UpdateRailSprite();
                        last = last.NextActiveRail;
                    }
                }
            }

            var railPoint = TargetPointList[isLast ? 0 : TargetPointIndex];

            TargetPoint = railPoint != null ? railPoint.localPosition : NextTrain.LastTrainPos;

            _gameDataService.Score = TargetRail.Row - MapGenerator.Instance.DeltaRow;

            if (_gameDataService.Score == 100)
            {
                _achievementsService.UnlockAchievement(GPGSIds.achievement_first_steps);
            }
            else if (_gameDataService.Score == 250)
            {
                _achievementsService.UnlockAchievement(GPGSIds.achievement_next_station);
            }
            else if (_gameDataService.Score == 500)
            {
                _achievementsService.UnlockAchievement(GPGSIds.achievement_on_a_rail);
            }
            else if (_gameDataService.Score == 1000)
            {
                _achievementsService.UnlockAchievement(GPGSIds.achievement_long_journey);
            }
            else if (_gameDataService.Score == 2000)
            {
                _achievementsService.UnlockAchievement(GPGSIds.achievement_transcontinental_railway);
            }
        }
Ejemplo n.º 2
0
        public void SwitchRail(SwipeDirection direction)
        {
            if (NextRails.Count == 0)
            {
                return;
            }
            NextRails = NextRails.OrderBy(rail => rail.OutputId).ToList();

            var currentWayIndex = NextRails.FindIndex(way => way == NextActiveRail);

            if (direction == SwipeDirection.Left)
            {
                currentWayIndex--;
            }

            if (direction == SwipeDirection.Right)
            {
                currentWayIndex++;
            }

            if (currentWayIndex >= NextRails.Count)
            {
                currentWayIndex = NextRails.Count - 1;
            }

            if (currentWayIndex < 0)
            {
                currentWayIndex = 0;
            }

            NextActiveRail = NextRails[currentWayIndex];

            UpdateRailSprite();
            if (_uiService.IsFirstTime)
            {
                NextActiveRail.SwitchRail();
            }
            else
            {
                NextActiveRail.SwitchRail(direction);
            }
        }
Ejemplo n.º 3
0
        public void SwitchRail()
        {
            if (NextRails.Count == 0)
            {
                return;
            }

            NextRails = NextRails.OrderBy(rail => rail.OutputId).ToList();

            var currentWayIndex = NextRails.FindIndex(way => way == NextActiveRail);

            currentWayIndex++;
            if (currentWayIndex >= NextRails.Count)
            {
                currentWayIndex = 0;
            }
            NextActiveRail = NextRails[currentWayIndex];

            UpdateRailSprite();
            NextActiveRail.SwitchRail();
        }