public void SetScore(Score score, int level) { ButtonNext.SetActive(false); gameObject.SetActive(true); int stars = 0; switch (score) { case Score.Bad: TextResult.text = BadResultText; TextResult.color = BadResult; FindObjectOfType <SoundManager>().PlaySFXLoose(); break; case Score.Ok: stars = 1; TextResult.text = OKResultText; TextResult.color = OKResult; FindObjectOfType <SoundManager>().PlaySFXVictory(); break; case Score.Good: stars = 2; TextResult.text = GoodResultText; TextResult.color = GoodResult; FindObjectOfType <SoundManager>().PlaySFXVictory(); break; case Score.Awesome: stars = 3; TextResult.text = AwesomeResultText; TextResult.color = AwesomeResult; FindObjectOfType <SoundManager>().PlaySFXAwesomeVictory(); FindObjectOfType <SoundManager>().PlaySFXVictory(); break; } SetStarsEnabled(stars); if (stars > 0 || LevelSelector.LastLevelEnabled > level) { if (LevelSelector.Levels.Count >= level + 1) { ButtonNext.SetActive(true); } } int starsHighScore = PlayerPrefsService.GetStarsHighScoreFromLevel(level); if (stars > starsHighScore) { PlayerPrefsService.SetStarsHighScoreFromLevel(stars, level); } }
private void BuildUILevels(XmlNodeList nodes) { bool nextLevelEnabled = true; for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; Button button = Instantiate(ButtonLevelSelector, ContainerLevels.transform); int level = i + 1; int starHighScore = PlayerPrefsService.GetStarsHighScoreFromLevel(level); button.interactable = (nextLevelEnabled)?true:false; if (button.interactable) { LastLevelEnabled = level; } if (starHighScore > 0) { nextLevelEnabled = true; } else { nextLevelEnabled = false; } int tracks = Convert.ToInt32(node.SelectSingleNode("tracks").InnerText); int total = Convert.ToInt32(node.SelectSingleNode("total").InnerText); int good = Convert.ToInt32(node.SelectSingleNode("good").InnerText); int speed = Convert.ToInt32(node.SelectSingleNode("speed").InnerText); LevelInfo levelInfo = new LevelInfo() { Level = level, TotalFoods = total, TotalFoodsGood = good, Speed = speed, Tracks = tracks, Stars = starHighScore }; Levels.Add(levelInfo); button.GetComponent <ButtonLevel>().Info = levelInfo; } }
public static IFilterAndDispatcher <AppState> Build(PlayerPrefsService playerPrefsService, out IDisposable disposable) { return(StoreBuilder <AppState> .Create(AppState.InitialState) .StartSubReducer(FilterCounterState) // Counter .AddReducer <IncrementAction>(CounterIncrementReducer) .AddReducer <DecrementAction>(CounterDecrementReducer) .EndSubReducer() .StartSubReducer(FilterToDoState) // ToDo .AddReducer <CreateTodoItemAction, PlayerPrefsService>(CreateToDoItemReducer, playerPrefsService) .AddReducer <RemoveTodoItemAction>(RemoveToDoItemReducer) .AddReducer <CompleteTodoItemAction>(CompleteToDoItemReducer) .AddReducer <ClearTodoItemsAction, PlayerPrefsService>(ClearToDoItemsReducer, playerPrefsService) .EndSubReducer() .Build(out disposable)); }
public static void LogPlayerPrefs() { PlayerPrefsService.LogAll(); }
public static void CreateToDoItemReducer(ToDoState state, CreateTodoItemAction action, PlayerPrefsService playerPrefsService) { var item = new TodoItem { Content = action.Content, Id = Guid.NewGuid() }; state.Items.Add(item); state.ItemAdded = item; var storedString = state.Items.Aggregate(string.Empty, (current, todoItem) => current + (todoItem + " ~ ")); playerPrefsService.Store(TODO_ITEMS, storedString); }
public static void ClearToDoItemsReducer(ToDoState state, ClearTodoItemsAction action, PlayerPrefsService playerPrefsService) { state.Items.Clear(); playerPrefsService.Clear(TODO_ITEMS); }