public void UpdateLevelStatus() { foreach (LevelButton levelButton in _levelButtons) { LevelProgressStatus levelProgress = PlayerDataService.Instance.GetLevelProgress(levelButton.LevelId); levelButton.ProgressStatus = levelProgress; } }
public void UpdateLevelProgress(int levelId, LevelProgressStatus levelStatus) { if ((levelId == _playerData.MaxLevelReached) && (levelStatus == LevelProgressStatus.Completed)) { _playerData.MaxLevelReached++; } _playerData.PlayerProgress[levelId] = levelStatus; SaveChanges(); }
public LevelButton(float x, float y, float size, int levelId, LevelProgressStatus progressStatus, bool isFinal = false) : base(x, y, 0, size) { IsFinal = isFinal; LevelId = levelId; ProgressStatus = progressStatus; NormalColor = new SKColor(14, 0, 163); DownColor = new SKColor(79, 0, 163); ActivatedColor = new SKColor(184, 117, 255); _buttonSprite = new Sprite(SpriteConst.LevelBase, 0, 0, size, size, new SKPaint { Color = new SKColor(255, 255, 255) }); AddChild(_buttonSprite); }
private void Build() { var levelMapPositionRepository = new LevelMapPositionRepository(); var levelMapPositions = levelMapPositionRepository.GetAll(); var higherPointY = levelMapPositions.Max(l => l.Position.Y); var newHeight = (float)(Height / 3 + higherPointY / 100 * Height); var currentLevelY = 0f; foreach (var levelMapPosition in levelMapPositionRepository.GetAll()) { LevelProgressStatus levelProgress = PlayerDataService.Instance.GetLevelProgress(levelMapPosition.Id); var buttonX = (float)levelMapPosition.Position.X / 100 * Width; var buttonY = newHeight - (float)levelMapPosition.Position.Y / 100 * Height; var levelButton = new LevelButton( buttonX, buttonY, Height / 40, levelMapPosition.Id, levelProgress); if (levelProgress == LevelProgressStatus.InProgress) { currentLevelY = buttonY; } AddChild(levelButton); DeclareTappable(levelButton); levelButton.Activated += () => LevelButton_Tapped(levelMapPosition.Id); _levelButtons.Add(levelButton); } _curve = new List <SKPoint>(); foreach (var levelButton in _levelButtons) { _curve.Add(new SKPoint(levelButton.X, levelButton.Y)); } _oldCurve = _curve; _curve = SmoothCurve(_curve); _curve = SmoothCurve(_curve); _curve = SmoothCurve(_curve); _curve = SmoothCurve(_curve); _curve = SmoothCurve(_curve); foreach (var levelButton in _levelButtons) { var closestPoint = _curve.Select(p => new KeyValuePair <SKPoint, float>(p, MathHelper.Distance(p, new SKPoint(levelButton.X, levelButton.Y)))).OrderBy(p => p.Value).First().Key; levelButton.X = closestPoint.X; levelButton.Y = closestPoint.Y; } var minHeight = -newHeight + _screenHeight; var maxHeight = 0; _y = Math.Max((-currentLevelY + SkiaRoot.ScreenHeight / 2), minHeight); _y = Math.Min(_y, maxHeight); Height = newHeight + _screenHeight; }