protected void SaveGameAndPlayer() { // Create an array to store player into List<GamePlayer> attendees = new List<GamePlayer>(); int listItemCount = _playersListView.ChildCount; for (int i = 0; i < listItemCount; i++) { CheckBox cbox = (_playersListView.GetChildAt(i)).FindViewById<CheckBox>(Resource.Id.playerCheckbox); if (cbox.Checked) { attendees.Add(new GamePlayer() { PlayerId = (int)GameData.PlayerService.Players[i].Id, PlayerAlias = GameData.PlayerService.Players[i].Name, Score = 0 }); } } Game game = new Game() { Name = Arguments.GetString("game_name"), Players = attendees }; GameData.Service.SaveGame(game); //StartActivity(typeof(GamesActivity)); var fragment = new GameFragment(); Bundle bundle = new Bundle(); bundle.PutInt("game_id", (int)game.Id); fragment.Arguments = bundle; var trans = Activity.SupportFragmentManager.BeginTransaction(); trans.Add(Resource.Id.fragmentContainer, fragment, "GameFragment"); trans.Commit(); }
public void SaveGame(Game game) { Boolean newGame = false; if (!game.Id.HasValue) { game.Id = GetNextId (); newGame = true; } string gameString = JsonConvert.SerializeObject (game); _fileHandler.WriteAllText (GetFilename (game.Id.Value), gameString); if (newGame) _games.Add (game); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.Inflate(Resource.Layout.Game, container, false); if (Arguments != null) { int _gameId = Arguments.GetInt("game_id"); _game = GameData.Service.GetGame(_gameId); // set title //android_game_game_title // Description TextView d = view.FindViewById<TextView>(Resource.Id.gameTitle); d.Text = _game.Name; _gameListView = view.FindViewById<ListView>(Resource.Id.gamePlayerListView); _adapter = new GameViewAdapter(Activity, _game); _gameListView.Adapter = _adapter; _gameListView.ItemClick += (s, e) => { GamePlayerClicked((int)e.Id); }; } return view; }
public void SaveGame(Game game) { throw new NotImplementedException(); }
public void DeleteGame(Game game) { _fileHandler.DeleteFile (GetFilename (game.Id.Value)); _games.Remove (game); }