private IEnumerator DoScoreComputation() { yield return(null); var data = new MutableLevelData { Background = Background, Bubbles = models.Values, Queue = queue, Randoms = randoms.ToArray(), ShotCount = queue.ShotCount, }; var newValues = ScoreUtil.ComputeStarsForLevel(data, BubbleFactory); for (int index = 0, count = newValues.Length; index < count; index++) { newValues[index] = (int)(newValues[index] * LevelProperties.StarMultiplier); } LevelProperties.StarValues = newValues; LevelProperties.NotifyListeners(); scoreCoroutine = null; }
public void LoadLevel(string jsonText) { var levelData = JsonUtility.FromJson <LevelData>(jsonText); var placer = new PlaceBubbleAction(); randoms = new List <RandomBubbleDefinition>(levelData.Randoms ?? new RandomBubbleDefinition[0]); GlobalState.EventService.Dispatch(new RandomBubblesChangedEvent()); foreach (var bubble in levelData.Bubbles) { state.BubbleType = bubble.Type; placer.Perform(this, bubble.X, bubble.Y); bubbleFactory.ApplyEditorModifiers(views[BubbleData.GetKey(bubble.X, bubble.Y)], bubble); models[BubbleData.GetKey(bubble.X, bubble.Y)].modifiers = bubble.modifiers; } LevelProperties.FromLevelData(levelData); LevelProperties.StarValues = ScoreUtil.ComputeStarsForLevel(levelData, BubbleFactory); LevelProperties.NotifyListeners(); queue.CopyFrom(levelData.Queue); queue.ShotCount = levelData.ShotCount; queue.NotifyListeners(); Background = levelData.Background; GlobalState.EventService.Dispatch(new LevelModifiedEvent()); GlobalState.EventService.Dispatch(new LevelEditorLoadEvent()); }
public string SaveLevel() { var data = new MutableLevelData { Background = Background, Bubbles = models.Values, Queue = queue, Randoms = randoms.ToArray(), ShotCount = queue.ShotCount, }; LevelProperties.StarValues = ScoreUtil.ComputeStarsForLevel(data, BubbleFactory); LevelProperties.NotifyListeners(); LevelProperties.ToLevelData(data); return(JsonUtility.ToJson(data)); }