public override void OnSceneLoaded(Scene scene, LoadSceneMode loadMode) { base.OnSceneLoaded(scene, loadMode); Debug.Log("战斗场景加载完成"); if (battleView == null) { battleView = new BattleView(); battleView.Show(); GamePublisher.Publish(EventType.battle_music_open); } }
public override void OnSceneLoaded(Scene scene, LoadSceneMode loadMode) { base.OnSceneLoaded(scene, loadMode); Debug.Log("大厅场景加载完成"); if (lobbyView == null) { lobbyView = new LobbyView(); lobbyView.Show(); GamePublisher.Publish(EventType.lobby_music_open); } }
/// <summary> /// Retrieve a list of all GamePublishers in the database /// </summary> /// <param name="error_message"></param> /// <returns></returns> public IEnumerable <GamePublisher> ReadAllGamePublishers(out string error_message) { List <GamePublisher> gamePublisherList = new List <GamePublisher>(); error_message = ""; try { using (SqlConnection connection = new SqlConnection(_connectionString)) { string s = "SELECT id, name FROM game_publisher UNION SELECT 0, '' ORDER BY name"; SqlCommand cmd = new SqlCommand(s, connection); cmd.Connection.Open(); using (DbDataReader reader = cmd.ExecuteReader()) { var ordinals = new { Id = reader.GetOrdinal("id"), PublisherName = reader.GetOrdinal("name") }; while (reader.Read() == true) { GamePublisher temp = new GamePublisher { Id = reader.GetInt32(ordinals.Id), PublisherName = reader.GetString(ordinals.PublisherName) }; gamePublisherList.Add(temp); } } } } catch (Exception ex) { error_message = ex.ToString(); } return(gamePublisherList); }
/// <summary> /// Retrieve a list of GamePublishers /// </summary> /// <param name="error_message"></param> /// <returns></returns> public IEnumerable <GamePublisher> GetAllGamePublishers(out string error_message) { error_message = ""; try { using (SqlConnection connection = new SqlConnection(AzureDbDataSettings.connectionString)) { string query = "SELECT id, name FROM game_publisher UNION SELECT 0, '' ORDER BY name"; SqlCommand cmd = new SqlCommand(query, connection); cmd.Connection.Open(); using (DbDataReader reader = cmd.ExecuteReader()) { var ordinals = new { Id = reader.GetOrdinal("id"), PublisherName = reader.GetOrdinal("name") }; while (reader.Read()) { bool ro = reader.HasRows; GamePublisher temp = new GamePublisher { Id = reader.GetInt32(ordinals.Id), PublisherName = reader.GetString(ordinals.PublisherName) }; _gamePublishers.Add(temp); } } } } catch (Exception ex) { error_message = ex.ToString(); } return(_gamePublishers); }
public void UnRegisterListeners( ) { // Debug.Log ( "Unregistering ... " ); GamePublisher.RemoveAllEntries(); }
public override void Enter() { base.Enter(); GamePublisher.Publish(EventType.STAGE_LOGIN_IN, this); }
public override void Exit() { base.Exit(); GamePublisher.Publish(EventType.STAGE_LOGIN_OUT, this);//退出login消息 }
public void Start() { GamePublisher.Publish(EventType.START_LOAD_DATA);//加载数据 }
public override void Exit() { base.Exit(); GamePublisher.Publish(EventType.STAGE_BATTLE_OUT, this); }
private void Insert(List <Item> itemList) { foreach (Item item in itemList) { int highestVotes = -1; int suggestedPlayers = 0; foreach (Results results in item.Poll.Where(poll => poll.Name.Contains("suggested_numplayers")).ToList().First().Results) { foreach (Result result in results.Result) { if (result.Value.Contains("Best") && int.Parse(result.Numvotes) > highestVotes) { highestVotes = int.Parse(result.Numvotes); suggestedPlayers = int.Parse(results.Numplayers); } } } Games game = new Games { Id = int.Parse(item.Id), GameName = item.Name.First().Value, MinPlayers = int.Parse(item.Minplayers.Value), MaxPlayers = int.Parse(item.Maxplayers.Value), SugPlayers = suggestedPlayers, GameDesc = item.Description, PlaytimeMin = int.Parse(item.Minplaytime.Value), PlaytimeMax = int.Parse(item.Maxplaytime.Value), ReviewScore = double.Parse(item.Statistics.Ratings.Average.Value), NumReviews = int.Parse(item.Statistics.Ratings.Usersrated.Value), Complexity = double.Parse(item.Statistics.Ratings.Averageweight.Value), AgeMin = int.Parse(item.Minage.Value), AgeMax = 99, PictureUrl = item.Thumbnail }; foreach (Link link in item.Link) { if (link.Type.Contains("category")) { Category category = new Category { Id = int.Parse(link.Id), Category1 = link.Value }; GameCategory gameCategory = new GameCategory { GameId = game.Id, CategoryId = category.Id }; if (!_dbContext.GameCategory.Contains(gameCategory)) { _dbContext.Add(gameCategory); } if (!_dbContext.Category.Contains(category)) { _dbContext.Add(category); } } else if (link.Type.Contains("mechanic")) { Mechanic mechanic = new Mechanic { Id = int.Parse(link.Id), Mechanic1 = link.Value }; GameMechanic gameMechanic = new GameMechanic { GameId = game.Id, MechanicId = mechanic.Id }; if (!_dbContext.GameMechanic.Contains(gameMechanic)) { _dbContext.Add(gameMechanic); } if (!_dbContext.Mechanic.Contains(mechanic)) { _dbContext.Add(mechanic); } } else if (link.Type.Contains("publish")) { Publisher publisher = new Publisher { Id = int.Parse(link.Id), Publisher1 = link.Value }; GamePublisher gamePublisher = new GamePublisher { GameId = game.Id, PublisherId = publisher.Id }; if (!_dbContext.GamePublisher.Contains(gamePublisher)) { _dbContext.Add(gamePublisher); } if (!_dbContext.Publisher.Contains(publisher)) { _dbContext.Add(publisher); } } else if (link.Type.Contains("design")) { Designer designer = new Designer { Id = int.Parse(link.Id), Designer1 = link.Value }; GameDesigner gameDesigner = new GameDesigner { GameId = game.Id, DesignerId = designer.Id }; if (!_dbContext.GameDesigner.Contains(gameDesigner)) { _dbContext.Add(gameDesigner); } if (!_dbContext.Designer.Contains(designer)) { _dbContext.Add(designer); } } else if (link.Type.Contains("artist")) { Artist artist = new Artist { Id = int.Parse(link.Id), Artist1 = link.Value }; GameArtist gameArtist = new GameArtist { GameId = game.Id, ArtistId = artist.Id }; if (!_dbContext.GameArtist.Contains(gameArtist)) { _dbContext.Add(gameArtist); } if (!_dbContext.Artist.Contains(artist)) { _dbContext.Add(artist); } } } if (!_dbContext.Games.Contains(game)) { _dbContext.Add(game); } _dbContext.SaveChanges(); } }