public void Init(SaveGameViewModel viewModel) { m_button.onClick.AddListener(OnButtonClick); m_viewModel = viewModel; m_nameText.text = m_viewModel.Name; m_roundsText.text = string.Format("{0} / {1}", m_viewModel.CurrentRound, m_viewModel.MaxRounds); }
private void SaveGameViewModel_OnLoadSaveGameCommand(SaveGameViewModel saveGameViewModel) { int index = saveGameViewModel.Index; bool validIndex = index >= 0 && index < SaveGameViewModelList.Count; Debug.Assert(validIndex, string.Format("Callback of save game view model with invalid index {0}", index)); if (!validIndex) { return; } // Load save game in model with index OnLoadGameCommand?.Invoke(index); }
private void UpdateSaveGameList() { var saveGameList = GameManager.instance.SaveGameList; SaveGameViewModelList = new List <SaveGameViewModel>(saveGameList.Count); for (int i = 0; i < saveGameList.Count; i++) { SaveGameViewModel saveGameViewModel = new SaveGameViewModel(saveGameList[i].saveGame); saveGameViewModel.Index = i; saveGameViewModel.OnLoadSaveGameCommand += SaveGameViewModel_OnLoadSaveGameCommand; SaveGameViewModelList.Add(saveGameViewModel); } OnUpdateSaveGameList?.Invoke(); }
public SaveGamePage() { InitializeComponent(); DataContext = new SaveGameViewModel(); }