public override void UpdateButton(ButtonController button) { GroupData groupData = groupsDataInitializer.Data.Groups[button.Id]; GroupProgressData groupProgressData = progressController.GetGroupData(button.Id); GroupButtonController buttonController = button.GetComponent <GroupButtonController>(); buttonController.Init(button.Id, themeController.GetCurrentTheme(), groupData, groupProgressData); }
private float CalculateGroupStars(GroupProgressData groupData) { float stars = 0; foreach (var drawingData in groupData.Drawings) { stars += drawingData.Stars; } return(stars / groupData.Drawings.Count); }
private int GetGroupIndex(string name) { for (int i = 0; i < gameProgressData.Groups.Count; i++) { GroupProgressData groupData = gameProgressData.Groups[i]; if (groupData.Name == name) { return(i); } } return(0); }
public override void UpdateButton(ButtonController button) { GroupData groupData = groupsDataInitializer.Data.Groups[progressController.GroupIndex]; DrawingData drawingData = groupData.Drawings[button.Id]; GroupProgressData groupProgressData = progressController.GetGroupData(progressController.GroupIndex); DrawingProgressData drawingProgressData = groupProgressData.Drawings[button.Id]; DrawingButtonController buttonController = button.GetComponent <DrawingButtonController>(); buttonController.Init(button.Id, themeController.GetCurrentTheme(), drawingData, drawingProgressData); }
private float CalculateGroupFill(GroupProgressData groupData) { float fill = 0; foreach (var drawingData in groupData.Drawings) { if (drawingData.Completed) { fill++; } } return(fill / groupData.Drawings.Count); }
private void Adjust(GameProgressData gameProgressData, GameData gameConfigData) { List <GroupProgressData> orderedData = new List <GroupProgressData>(gameConfigData.Groups.Length); foreach (var groupConfigData in gameConfigData.Groups) { GroupProgressData groupProgressData = GetByName(gameProgressData.Groups, groupConfigData.Name); Adjust(groupProgressData, groupConfigData); orderedData.Add(groupProgressData); } gameProgressData.Groups.Clear(); gameProgressData.Groups.AddRange(orderedData); }
private int GetDrawingIndex(string name, int groupIndex) { GroupProgressData groupData = gameProgressData.Groups[groupIndex]; for (int i = 0; i < groupData.Drawings.Count; i++) { DrawingProgressData drawingData = groupData.Drawings[i]; if (drawingData.Name == name) { return(i); } } return(0); }
public void FinishDrawing() { GroupProgressData groupProgressData = gameProgressData.Groups[groupIndex]; DrawingProgressData drawingProgressData = groupProgressData.Drawings[drawingIndex]; drawingProgressData.Completed = true; if (drawingProgressData.Stars < livesController.Lives) { drawingProgressData.Stars = livesController.Lives; } gamesPlayed++; SaveData(); }
private void SaveData() { PlayerPrefs.SetInt(GAMES_PLAYED, gamesPlayed); GroupProgressData groupData = gameProgressData.Groups[groupIndex]; PlayerPrefs.SetString(GROUP_NAME, groupData.Name); DrawingProgressData drawingData = groupData.Drawings[drawingIndex]; PlayerPrefs.SetString(DRAWING_NAME, drawingData.Name); PlayerPrefs.SetInt(MAP_INDEX, mapIndex); gameProgressDataInitializer.Save(gameProgressData); }
private void Adjust(GroupProgressData groupProgressData, GroupData groupConfigData) { if (!groupProgressData.Unlocked) { groupProgressData.Unlocked = groupConfigData.Unlocked; } List <DrawingProgressData> orderedData = new List <DrawingProgressData>(groupConfigData.Drawings.Length); foreach (var drawingConfigData in groupConfigData.Drawings) { DrawingProgressData drawingProgressData = GetByName(groupProgressData.Drawings, drawingConfigData.Name); Adjust(drawingProgressData, drawingConfigData); orderedData.Add(drawingProgressData); } groupProgressData.Drawings.Clear(); groupProgressData.Drawings.AddRange(orderedData); }
public void Init(int id, ThemeData themeData, GroupData groupData, GroupProgressData progressData) { Init(id); for (int i = 0; i < mainImages.Length; i++) { mainImages[i].sprite = Resources.Load <Sprite>("Drawings/" + groupData.Images[i]); } background.color = themeData.GetColor(ThemeData.ColorEnum.BkgSecond); locked = !progressData.Unlocked; locker.enabled = locked; for (int i = 0; i < stars.Length; i++) { var star = stars[i]; star.color = themeData.GetColor(i + 1 <= CalculateGroupStars(progressData) ? ThemeData.ColorEnum.Main : ThemeData.ColorEnum.Second); } }
public override ButtonController[] CreateButtons(int parentId) { int size = groupsDataInitializer.Data.Groups.Length; ButtonController[] result = new ButtonController[size]; for (int i = 0; i < size; i++) { GameObject instance = CreateButton(); GroupData groupData = groupsDataInitializer.Data.Groups[i]; GroupProgressData progressData = progressController.GetGroupData(i); GroupButtonController buttonController = instance.GetComponent <GroupButtonController>(); buttonController.Init(i, themeController.GetCurrentTheme(), groupData, progressData); result[i] = buttonController; } return(result); }