public List <Game> GetGames(int?leagueID = null, int?playerID = null, int?teamID = null, DataCache dataCache = null) { if (UserHelper.HasGetPermissions(teamID: teamID, leagueID: leagueID)) { var games = GameDataProvider.GetInstance().GetGames(leagueID: leagueID, playerID: playerID, teamID: teamID, dataCache: dataCache); var stats = GameDataProvider.GetInstance().GetStats(leagueID: leagueID, playerID: playerID, dataCache: dataCache); var gameStats = stats.Select(s => ConvertObjects.ConvertType2(s)).ToList(); return(games.Select(g => { var game = ConvertObjects.ConvertType(g); return new Game() { ID = g.ID, GameDate = g.GameDate, Team1ID = g.Team1ID, Team1Score = GetTeamScore(gameStats, game, true), Team2ID = g.Team2ID, Team2Score = GetTeamScore(gameStats, game, false) }; }).ToList()); } else { return(null); } }
public void UpdateGame(Game game) { if (UserHelper.HasUpdatePermissions()) { GameDataProvider.GetInstance().UpdateGame(ConvertObjects.ConvertType(game)); } }
public void AddStat(PlayerGameStat stat, BaseballGameState state = null) { if (UserHelper.HasUpdatePermissions()) { stat.States = new List <int>(); if (state != null) { if (state.PlayerOnFirst != null) { stat.States.Add((int)StatStates.First); } if (state.PlayerOnSecond != null) { stat.States.Add((int)StatStates.Second); } if (state.PlayerOnThird != null) { stat.States.Add((int)StatStates.Third); } if (state.NumberOfOuts == 1) { stat.States.Add((int)StatStates.Out1); } if (state.NumberOfOuts == 2) { stat.States.Add((int)StatStates.Out2); } } var gameStat = ConvertObjects.ConvertType(stat); GameDataProvider.GetInstance().AddStat(gameStat); } }
public static bool SetUserImage(string gameId, Bitmap image, string sourceFile) { var game = Games[gameId]; if (GameImageCache.TryRemove(gameId, out Bitmap oldImage)) { var imageFormat = Ujeby.Common.Tools.Graphics.GetImageFormat(new FileInfo(sourceFile).Extension); var imageLocation = GameDataProvider.SaveGameImage(game.Title, image, imageFormat); var newGameImage = new GameImage { LocalFilename = imageLocation, SourceUrl = sourceFile, }; var oldUserData = game.CustomData <UserData>(); if (oldUserData != null) { oldUserData.Image = newGameImage; } else { game.Data = game.Data.Concat(new GameData[] { new UserData(game.Title) { Image = newGameImage } }).ToArray(); } return(UpdateGameImageCache(gameId, newGameImage)); } return(false); }
public BaseballGameState GetExistingGameState(int gameID, int leagueID, DataCache dataCache = null) { var gameState = ConvertObjects.ConvertType(GameDataProvider.GetInstance().GetBaseballGameState(gameID, dataCache)); if (gameState.Inning == 0) { gameState.Inning = 1; gameState.TopOfInning = true; } var players = PlayersService.GetInstance().GetPlayers(gameID: gameID, leagueID: leagueID, dataCache: dataCache); if (gameState.PlayerOnFirst != null) { var player = players.First(p => p.ID == gameState.PlayerOnFirst.ID); gameState.PlayerOnFirst.Name = player.Name; gameState.PlayerOnFirst.Number = player.Number; } if (gameState.PlayerOnSecond != null) { var player = players.First(p => p.ID == gameState.PlayerOnSecond.ID); gameState.PlayerOnSecond.Name = player.Name; gameState.PlayerOnSecond.Number = player.Number; } if (gameState.PlayerOnThird != null) { var player = players.First(p => p.ID == gameState.PlayerOnThird.ID); gameState.PlayerOnThird.Name = player.Name; gameState.PlayerOnThird.Number = player.Number; } return(gameState); }
public DynamicRangeChunkVolume(GraphicsDevice device, GameDataProvider provider) { chunkWishList = new HashSet<WorldPosition>(); this.provider = provider; volume = new Chunk[16, 16, 16]; vertexBuffers = new CDictionary<Chunk, VBuffer7>(); this.device = device; this.effect = Static.Effect; MiniMap = new Texture2D(Static.Device, 64, 64); MiniMapBuffer = new Color[64 * 64]; MiniMapLayer = new Layer(MiniMap, 1, 0.7f, LayerDock.Far, LayerDock.Far, () => { return true; } ); MiniMapLayer.Push(new LayerCell { SourceTexture = new Rectangle(0, 0, 64, 64), DestinationScreen = new Rectangle(-270, -270, 256, 256) }); redrawWorker = new Timer(doRedraw); redrawWorker.Change(50, 50); hoverBoxMesh = HelpfulStuff.getCube(0.51f, GraphicsHelper.TextureCoord(36)); }
public DynamicRangeChunkVolume(GraphicsDevice device, GameDataProvider provider) { chunkWishList = new HashSet<WorldPosition>(); this.provider = provider; volume = new Chunk[16, 16, 16]; vertexBuffers = new CDictionary<Chunk, VertexBuffer[]>(); this.device = device; this.effect = Static.Effect; }
public void ParseSourceFGD() { var hl2 = @"D:\Github\sledge\_Resources\FGD\portal2.fgd"; GameDataProvider.Register(new FgdProvider()); var gd = GameDataProvider.GetGameDataFromFile(hl2); Assert.IsTrue(gd.Classes.Count > 0); }
public void ParseTF2FGD() { var tf2 = @"D:\Github\sledge\_Resources\FGD\tf2.fgd"; GameDataProvider.Register(new FgdProvider()); var gd = GameDataProvider.GetGameDataFromFile(tf2); Assert.IsTrue(gd.MaterialExclusions.Count > 0); Assert.IsTrue(gd.AutoVisgroups.Count > 0); }
public void Awake() { GameObject existing = GameObject.FindGameObjectWithTag("GameDataProvider"); if (existing == null) { Debug.Log("to sche"); GameDataProvider gameDataProvider = Resources.Load <GameDataProvider>("gamedataprovider/GameDataProvider"); GameObject.Instantiate(gameDataProvider); } }
public void Start() { gameDataProvider = GameObject.FindGameObjectWithTag("GameDataProvider").GetComponent <GameDataProvider>(); textToPlaceIn = GetComponent <Text>(); int value; if (gameDataProvider.gameData.TryGetInt(gameVariable, out value)) { textToPlaceIn.text = value + ""; } }
public void ParseGoldsourceFgd() { var gs = @"D:\Github\sledge\_Resources\FGD\Half-Life.fgd"; GameDataProvider.Register(new FgdProvider()); var gd = GameDataProvider.GetGameDataFromFile(gs); var types = gd.Classes.SelectMany(x => x.Properties).Select(x => x.VariableType).Distinct(); foreach (var variableType in types) { Console.WriteLine(variableType); } }
/// <summary> /// download game image /// </summary> /// <param name="gameImage"></param> static bool DownloadGameImage(GameImage gameImage) { if (gameImage != null && !GameDataProvider.ImageExists(gameImage.LocalFilename) && !string.IsNullOrEmpty(gameImage.SourceUrl)) { var image = WebUtils.DownloadImage(gameImage.SourceUrl, out ImageFormat imageFormat); if (image != null) { GameDataProvider.SaveImage(gameImage.LocalFilename, image, imageFormat); return(true); } } return(false); }
public static void Start() { MapProvider.Register(new RmfProvider()); MapProvider.Register(new VmfProvider()); GameDataProvider.Register(new FgdProvider()); TextureProvider.Register(new WadProvider()); // var editor = new Editor.Editor(); // editor.Load += (sender, e) => PostStart(sender as Editor.Editor); // Application.Run(editor); // var settings = Context.DBContext.GetAllSettings().ToDictionary(x => x.Key, x => x.Value); // Serialise.DeserialiseSettings(settings); // var settingsform = new Editor.Settings.SettingsForm(); // Application.Run(settingsform); // var map = MapProvider.GetMapFromFile(MapFile); // Document.Game = Game; // Document.Map = map; // Document.GameData = GameDataProvider.GetGameDataFromFiles(Game.Fgds.Select(f => f.Path)); // var entity = new EntityEditor(); // entity.Objects.AddRange(map.WorldSpawn.Children.OfType<Entity>().Take(1)); // Application.Run(entity); /* * var nat = new NativeFile(new DirectoryInfo(@"F:\Steam\steamapps\common\Half-Life")); * var gcf1 = new GcfFile(@"F:\Steam\steamapps\half-life.gcf"); * var gcf2 = new GcfFile(@"F:\Steam\steamapps\half-life engine.gcf"); * //var gcf3 = new GcfFile(@"F:\Steam\steamapps\half-life base content.gcf"); * var gcf4 = new GcfFile(@"F:\Steam\steamapps\platform.gcf"); * var com = new CompositeFile(null, new IFile[] { nat, gcf1, gcf2, gcf4 }); */ var nat = new NativeFile(new DirectoryInfo(@"F:\Half-Life WON")); var com = new CompositeFile(null, new[] { new NativeFile(new DirectoryInfo(@"F:\Half-Life WON\valve")), new NativeFile(new DirectoryInfo(@"F:\Half-Life WON\tfc")), }); //var pak = new PakFile(@"F:\Half-Life WON\valve\pak0.pak"); // var vir = new VirtualFile(null, "valve", new[] {pak}); //var com = new CompositeFile(null, new IFile[] { nat, vir }); var fsb = new FileSystemBrowserControl { Dock = DockStyle.Fill, File = com }; //, FilterText = "WAD Files", Filter = "*.wad"}; var form = new Form { Controls = { fsb }, Width = 500, Height = 500 }; Application.Run(form); }
public void Start() { GameDataProvider gameDataProvider = GameObject.FindGameObjectWithTag("GameDataProvider").GetComponent <GameDataProvider>(); textToPlaceIn = GetComponent <Text>(); int value; if (gameDataProvider.gameData.TryGetInt(gameVariable, out value)) { if (value < pickValues.Count && value >= 0) { textToPlaceIn.text = pickValues[value] + ""; } } }
public bool CreateNewStatGroup(int sportID, int gameID, int?playerID, int teamID) { if (UserHelper.HasUpdatePermissions()) { var statGroup = new StatGroup(); if (sportID == (int)SportsList.Baseball) { statGroup = ConvertObjects.ConvertType(GameDataProvider.GetInstance().GetStatGroup(gameID, playerID, teamID, true)); } return(true); } else { throw new UnauthorizedAccessException("nope"); } }
public DynamicRangeChunkVolume(GraphicsDevice device, GameDataProvider provider) { chunkWishList = new HashSet<WorldPosition>(); this.provider = provider; volume = new Chunk[16, 16, 16]; vertexBuffers = new CDictionary<Chunk, VBuffer7>(); this.device = device; this.effect = Static.Effect; MiniMap = new Texture2D(Static.Device, 64, 64); MiniMapBuffer = new Color[64 * 64]; MiniMapLayer = new Layer(MiniMap, 1, 0.7f, LayerDock.Far, LayerDock.Far, () => true); MiniMapLayer.Push(new LayerCell { SourceTexture = new Rectangle(0, 0, 64, 64), DestinationScreen = new Rectangle(-270, -270, 256, 256) }); }
public List <Player> GetPlayers(int?teamID = null, int?gameID = null, int?leagueID = null, DataCache dataCache = null) { var players = PlayerDataProvider.GetInstance().GetPlayers(teamID: teamID, gameID: gameID, leagueID: leagueID, dataCache: dataCache); if (gameID.HasValue) { var dtoGame = GameDataProvider.GetInstance().GetGames(gameID: gameID, dataCache: dataCache).First(); var game = ConvertObjects.ConvertType(dtoGame); var validTeams = new List <int>() { game.Team1ID, game.Team2ID }; if (!players.Exists(p => p.TeamID == game.Team1ID)) { //ADD TEAM PLAYER var dtoPlayer = new DTOPlayer() { Name = "Team 1 Player", TeamID = game.Team1ID }; players.Add(dtoPlayer); } if (!players.Exists(p => p.TeamID == game.Team2ID)) { //ADD TEAM PLAYER var dtoPlayer = new DTOPlayer() { Name = "Team 2 Player", TeamID = game.Team2ID }; players.Add(dtoPlayer); } } return(players .Where(p => UserHelper.HasGetPermissions(playerID: p.ID, gameID: gameID)) .Select(p => new Player() { ID = p.ID, Name = p.Name, Number = p.Number, TeamID = p.TeamID }) .ToList()); }
public List <StatGroup> GetStatGroups(int sportID, int gameID, int?playerID) { if (UserHelper.HasGetPermissions(gameID: gameID)) { var statGroups = new List <StatGroup>(); if (sportID == (int)SportsList.Baseball) { var dtoStatGroups = GameDataProvider.GetInstance().GetStatGroups(gameID, playerID); statGroups = dtoStatGroups.Select(sg => new StatGroup() { GroupID = sg.GroupID }).ToList(); } return(statGroups); } else { throw new UnauthorizedAccessException("nope"); } }
public PlayerStats GetStats(int sportID, int gameID, int?playerID, int teamID, int leagueID, DataCache dataCache = null) { var stats = GameDataProvider.GetInstance().GetStats(gameID, playerID: playerID, teamID: teamID, dataCache: dataCache); var player = PlayersService.GetInstance().GetPlayers(teamID: teamID, gameID: gameID, leagueID: leagueID, dataCache: dataCache).Where(p => p.ID == playerID).First(); return(new PlayerStats() { PlayerName = player.Name, TeamID = teamID, GameID = gameID, PlayerID = player.ID, PlayerNumber = player.Number, Stats = stats.Select(s => new Stat() { StatType = ConvertObjects.ConvertType(s), GroupID = s.GroupID, Value = s.Value }).ToList() }); }
private void Start() { gameDataProvider = GameObject.FindGameObjectWithTag("GameDataProvider").GetComponent <GameDataProvider>(); int mainSourceValue; if (gameDataProvider.gameData.TryGetInt(mainSource, out mainSourceValue)) { for (int i = 0; i < possibleChoices.Count; i++) { if (possibleChoices[i].checkValue == mainSourceValue) { choiceSource = possibleChoices[i].gameVariableToGet; } } } else { choiceSource = possibleChoices[0].gameVariableToGet; } }
public PlayerStats GetPlayerStats(int playerID, DataCache dataCache = null) { var stats = GameDataProvider.GetInstance().GetStats(playerID: playerID, dataCache: dataCache); var player = PlayersService.GetInstance().GetPlayer(playerID, dataCache: dataCache); return(new PlayerStats() { PlayerName = player.Name, PlayerID = player.ID, PlayerNumber = player.Number, Stats = stats.Select(s => new Stat() { StatType = ConvertObjects.ConvertType(s), GroupID = s.GroupID, Value = s.Value, LeagueID = s.LeagueID, GameID = s.GameID, TeamID = s.TeamID, Sport = (SportsList)s.SportID }).ToList() }); }
public NextBatter SaveNewGameState(BaseballGameState state, bool manualAdjustment, DataCache dataCache = null) { var nextBatterResult = new NextBatter(); if (UserHelper.HasUpdatePermissions()) { var game = GamesService.GetInstance().GetGame(state.GameID, dataCache: dataCache); if (!manualAdjustment) { var atBatTeamID = state.TopOfInning ? game.Team1ID : game.Team2ID; var atBatPlayerID = state.TopOfInning ? state.Team1Player?.ID : state.Team2Player?.ID; var battingOrder = GameDataProvider.GetInstance().GetBattingOrder(state.GameID, atBatTeamID); if (battingOrder.Count == 0) { battingOrder.Add(new DTOBattingOrder() { BattingOrder = 1 }); } var currentBatter = battingOrder.First(bo => bo.PlayerID == atBatPlayerID); var nextBatter = battingOrder.FirstOrDefault(bo => bo.BattingOrder == currentBatter.BattingOrder + 1); if (nextBatter == null) { nextBatter = battingOrder.First(); } if (state.TopOfInning) { state.Team1Player = new PlayerBase() { ID = nextBatter.PlayerID }; } else { state.Team2Player = new PlayerBase() { ID = nextBatter.PlayerID }; } nextBatterResult.PlayerID = nextBatter.PlayerID; nextBatterResult.TeamID = atBatTeamID; } //Change Teams if (state.NumberOfOuts == 3) { state.NumberOfOuts = 0; state.TopOfInning = !state.TopOfInning; if (state.TopOfInning) { state.Inning++; } state.PlayerOnFirst = null; state.PlayerOnSecond = null; state.PlayerOnThird = null; var nextAtBatTeamID = state.TopOfInning ? game.Team1ID : game.Team2ID; var battingOrderNextTeam = GameDataProvider.GetInstance().GetBattingOrder(state.GameID, nextAtBatTeamID); nextBatterResult.TeamID = nextAtBatTeamID; var nextAtBatPlayer = state.TopOfInning ? state.Team1Player : state.Team2Player; if (nextAtBatPlayer == null) { if (battingOrderNextTeam.Any()) { nextBatterResult.PlayerID = battingOrderNextTeam.First().PlayerID; } else { nextBatterResult.PlayerID = null; } } else { nextBatterResult.PlayerID = battingOrderNextTeam.FirstOrDefault(bo => bo.PlayerID == nextAtBatPlayer.ID).PlayerID; } } GameDataProvider.GetInstance().SaveBaseballGameState(ConvertObjects.ConvertType2(state)); } return(nextBatterResult); }
public void OnSet() { GameDataProvider gameDataProvider = GameObject.FindGameObjectWithTag("GameDataProvider").GetComponent <GameDataProvider>(); gameDataProvider.gameData.SetInt(gameVariable, value); }
private void Start() { timedEventPlanner = new TimedEventPlanner(); gameDataProvider = GameObject.FindGameObjectWithTag("GameDataProvider").GetComponent <GameDataProvider>(); StartGame(); }
public void Start() { /* RESOURCE LIST CREATION */ #if UNITY_EDITOR AssetDatabase.Refresh(); FileServices.CreateResourcesList("Assets/Resources/resourceslist.txt"); #endif FileServices.LoadResourcesList("resourceslist"); #region LOAD RESOURCES // logger and ioc _logger = new Logger("info.log", false); _resolver = new IoCResolver(_logger); _resolver.RegisterItem(_logger); _config = new UserConfigurationManager(new UserConfigurationData { GameVolume = 1f, MusicVolume = 1f }); _resolver.RegisterItem(_config); // messager _messager = new Messager(); _resolver.RegisterItem(_messager); // unity reference master _unity = GetComponent <UnityReferenceMaster>(); _unity.DebugModeActive = false; _resolver.RegisterItem(_unity); // player var player = new UserAccountManager(); _resolver.RegisterItem(player); // material provider var materialProvider = new MaterialProvider(_logger); MaterialLoader.LoadMaterial(materialProvider, "Materials"); _resolver.RegisterItem(materialProvider); // texture provider var textureProvider = new TextureProvider(_logger); var spriteProvider = new SpriteProvider(_logger); TextureLoader.LoadTextures(textureProvider, spriteProvider, "Textures"); _resolver.RegisterItem(textureProvider); _resolver.RegisterItem(spriteProvider); // sound provider var soundProvider = new SoundProvider(_logger); SoundLoader.LoadSounds(_logger, soundProvider, "Sounds"); _resolver.RegisterItem(soundProvider); // prefab provider var prefabProvider = new PrefabProvider(_logger); PrefabLoader.LoadPrefabs(prefabProvider); _resolver.RegisterItem(prefabProvider); // pooling var poolingObjectManager = new PoolingObjectManager(_logger, prefabProvider); _resolver.RegisterItem(poolingObjectManager); var soundPoolManager = new PoolingAudioPlayer(_logger, _config, _unity, prefabProvider.GetPrefab("audio_source_prefab")); _resolver.RegisterItem(soundPoolManager); _particles = new PoolingParticleManager(_resolver); _resolver.RegisterItem(_particles); // canvas provider var canvasProvider = new CanvasProvider(_logger); _unity.LoadCanvases(canvasProvider); _resolver.RegisterItem(canvasProvider); // data provider var gameDataProvider = new GameDataProvider(_logger); /* DATA GOES HERE */ _resolver.RegisterItem(gameDataProvider); #endregion _uiManager = new UiManager(); _resolver.RegisterItem(_uiManager); // lock the resolver (stop any new items being registered) _resolver.Lock(); /* BEGIN STATE */ _currentState = new MenuState(_resolver); _currentState.Initialize(); /* SUBSCRIBE FOR GAME END */ _onExit = _messager.Subscribe <ExitMessage>(OnExit); }
public List <GameLog> GetGameLog(int gameID, DataCache dataCache = null) { var game = GameDataProvider.GetInstance().GetGameLog(gameID: gameID); return(game.Select(g => ConvertObjects.ConvertType(g)).ToList()); }
public Game GetGame(int gameID, DataCache dataCache = null) { var dtoGame = GameDataProvider.GetInstance().GetGames(gameID: gameID, dataCache: dataCache).First(); var game = ConvertObjects.ConvertType(dtoGame); var validTeams = new List <int>() { game.Team1ID, game.Team2ID }; var teams = TeamsService.GetInstance().GetTeams(validTeams: validTeams, dataCache: dataCache); if (UserHelper.HasGetPermissions(game)) { var stats = GameDataProvider.GetInstance().GetStats(gameID: gameID, dataCache: dataCache); var statTypes = GameDataProvider.GetInstance().GetStatTypes(game.SportID, dataCache: dataCache); var players = PlayersService.GetInstance().GetPlayers(gameID: gameID, leagueID: game.LeagueID, dataCache: dataCache); var gameStats = stats.Select(s => ConvertObjects.ConvertType2(s)).ToList(); var playerStats = new List <PlayerStats>(); foreach (var player in players) { var playerStat = new PlayerStats() { GameID = gameID, PlayerID = player.ID, PlayerName = player.Name, TeamID = player.TeamID, Stats = new List <Stat>() }; foreach (var statType in statTypes.Where(st => !st.IsCalculated)) { var existingStat = gameStats.FirstOrDefault(s => s.StatType.ID == statType.StatTypeID && s.PlayerID == player.ID && s.TeamID == player.TeamID); var stat = new GameStat() { GameID = gameID, PlayerID = player.ID, TeamID = player.TeamID, Value = 0, StatType = ConvertObjects.ConvertType(statType) }; if (existingStat != null) { stat.Value = gameStats.Where(s => s.StatType.ID == statType.StatTypeID && s.PlayerID == player.ID && s.TeamID == player.TeamID).Sum(s => s.Value); } stat.StatType.GridDisplayOrder = statType.GridDisplayOrder; stat.StatType.SelectionDisplayOrder = statType.SelectionDisplayOrder; playerStat.Stats.Add(ConvertObjects.ConvertType(stat)); } playerStats.Add(playerStat); } int team1score = 0; int team2score = 0; team1score = GetTeamScore(gameStats, game, true); team2score = GetTeamScore(gameStats, game, false); var selectedGame = new Game() { ID = game.ID, GameDate = game.GameDate, Team1ID = game.Team1ID, Team1Score = team1score, Team1Name = teams.First(t => t.ID == game.Team1ID).Name, Team2ID = game.Team2ID, Team2Score = team2score, Team2Name = teams.First(t => t.ID == game.Team2ID).Name, PlayerStats = playerStats, SportID = game.SportID }; foreach (var ps in selectedGame.PlayerStats) { var playerGameStats = gameStats.Where(g => g.PlayerID == ps.PlayerID).ToList(); foreach (var calcStat in statTypes.Where(st => st.IsCalculated)) { ps.Stats.Add(new Stat() { StatType = ConvertObjects.ConvertType(calcStat), Value = StatsCalculations.GetValue((CalculatedStatTypes)calcStat.StatTypeID, playerGameStats) }); } } return(selectedGame); } else { return(null); } }
public void Start() { /* RESOURCE LIST CREATION */ #if UNITY_EDITOR AssetDatabase.Refresh(); FileServices.CreateResourcesList("Assets/Resources/resourceslist.txt"); #endif FileServices.LoadResourcesList("resourceslist"); #region LOAD RESOURCES // logger and ioc _logger = new Logger("info.log", false); _resolver = new IoCResolver(_logger); _resolver.RegisterItem(_logger); _config = new UserConfigurationManager(new UserConfigurationData { GameVolume = 1f, MusicVolume = 1f }); _resolver.RegisterItem(_config); // messager _messager = new Messager(); _resolver.RegisterItem(_messager); // unity reference master _unity = GetComponent<UnityReferenceMaster>(); _unity.DebugModeActive = false; _resolver.RegisterItem(_unity); // player var player = new UserAccountManager(); _resolver.RegisterItem(player); // material provider var materialProvider = new MaterialProvider(_logger); MaterialLoader.LoadMaterial(materialProvider,"Materials"); _resolver.RegisterItem(materialProvider); // texture provider var textureProvider = new TextureProvider(_logger); var spriteProvider = new SpriteProvider(_logger); TextureLoader.LoadTextures(textureProvider, spriteProvider, "Textures"); _resolver.RegisterItem(textureProvider); _resolver.RegisterItem(spriteProvider); // sound provider var soundProvider = new SoundProvider(_logger); SoundLoader.LoadSounds(_logger, soundProvider, "Sounds"); _resolver.RegisterItem(soundProvider); // prefab provider var prefabProvider = new PrefabProvider(_logger); PrefabLoader.LoadPrefabs(prefabProvider); _resolver.RegisterItem(prefabProvider); // pooling var poolingObjectManager = new PoolingObjectManager(_logger, prefabProvider); _resolver.RegisterItem(poolingObjectManager); var soundPoolManager = new PoolingAudioPlayer(_logger, _config, _unity, prefabProvider.GetPrefab("audio_source_prefab")); _resolver.RegisterItem(soundPoolManager); _particles = new PoolingParticleManager(_resolver); _resolver.RegisterItem(_particles); // canvas provider var canvasProvider = new CanvasProvider(_logger); _unity.LoadCanvases(canvasProvider); _resolver.RegisterItem(canvasProvider); // data provider var gameDataProvider = new GameDataProvider(_logger); /* DATA GOES HERE */ _resolver.RegisterItem(gameDataProvider); #endregion _uiManager = new UiManager(); _resolver.RegisterItem(_uiManager); // lock the resolver (stop any new items being registered) _resolver.Lock(); /* BEGIN STATE */ _currentState = new MenuState(_resolver); _currentState.Initialize(); /* SUBSCRIBE FOR GAME END */ _onExit = _messager.Subscribe<ExitMessage>(OnExit); }
public List <State> GetStates(int sportID) { var statStates = GameDataProvider.GetInstance().GetStates(sportID); return(statStates.Select(s => ConvertObjects.ConvertType(s)).ToList()); }
public List <PlayerStats> GetAllStats(int?teamID = null, int?sportID = null, int?leagueID = null, int?playerID = null, DataCache dataCache = null) { var stats = GameDataProvider.GetInstance().GetStats(teamID: teamID, leagueID: leagueID, playerID: playerID, dataCache: dataCache); var players = PlayerDataProvider.GetInstance().GetPlayers(teamID: teamID, leagueID: leagueID, playerID: playerID, dataCache: dataCache); List <Team> teamList = new List <Team>(); if (teamID.HasValue) { teamList.Add(new Team() { ID = teamID.Value, LeagueID = leagueID.Value, SportID = sportID.Value }); } else { teamList = TeamsService.GetInstance().GetTeams(leagueID: leagueID, playerID: playerID, showAll: true, dataCache: dataCache); } var statTypes = GameDataProvider.GetInstance().GetStatTypes(sportID, dataCache: dataCache); var gameStats = stats.Select(s => ConvertObjects.ConvertType2(s)).ToList(); var playerStats = new List <PlayerStats>(); foreach (var player in players) { foreach (var team in teamList) { var playerStat = new PlayerStats() { TeamID = team.ID, LeagueID = team.LeagueID, SportID = team.SportID, PlayerName = player.Name, PlayerNumber = teamID.HasValue ? player.Number : team.PlayerNumber, GameID = 0, PlayerID = player.ID, Stats = new List <Stat>() }; foreach (var statType in statTypes.Where(st => !st.IsCalculated && st.SportID == team.SportID)) { var stat = stats.Where(s => s.StatTypeID == statType.StatTypeID && s.PlayerID == player.ID && s.LeagueID == team.LeagueID).Sum(s => s.Value); playerStat.Stats.Add(new Stat() { Value = stat, StatType = ConvertObjects.ConvertType(statType) }); } playerStats.Add(playerStat); } } foreach (var playerStat in playerStats) { var playerGameStats = gameStats.Where(g => g.PlayerID == playerStat.PlayerID && g.LeagueID == playerStat.LeagueID).ToList(); foreach (var calcStat in statTypes.Where(st => st.IsCalculated && st.SportID == playerStat.SportID)) { playerStat.Stats.Add(new Stat() { StatType = ConvertObjects.ConvertType(calcStat), Value = StatsCalculations.GetValue((CalculatedStatTypes)calcStat.StatTypeID, playerGameStats) }); } } return(playerStats); }
private void EditorLoad(object sender, EventArgs e) { FileTypeRegistration.RegisterFileTypes(); SettingsManager.Read(); if (TaskbarManager.IsPlatformSupported) { TaskbarManager.Instance.ApplicationId = FileTypeRegistration.ProgramId; _jumpList = JumpList.CreateJumpList(); _jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent; _jumpList.Refresh(); } UpdateDocumentTabs(); UpdateRecentFiles(); DockBottom.Hidden = DockLeft.Hidden = DockRight.Hidden = true; MenuManager.Init(mnuMain, tscToolStrip); MenuManager.Rebuild(); SidebarManager.Init(RightSidebar); ViewportManager.Init(TableSplitView); ToolManager.Init(); foreach (var tool in ToolManager.Tools) { var tl = tool; var hotkey = Sledge.Settings.Hotkeys.GetHotkeyForMessage(HotkeysMediator.SwitchTool, tool.GetHotkeyToolType()); tspTools.Items.Add(new ToolStripButton( "", tl.GetIcon(), (s, ea) => Mediator.Publish(HotkeysMediator.SwitchTool, tl.GetHotkeyToolType()), tl.GetName()) { Checked = (tl == ToolManager.ActiveTool), ToolTipText = tl.GetName() + (hotkey != null ? " (" + hotkey.Hotkey + ")" : ""), DisplayStyle = ToolStripItemDisplayStyle.Image, ImageScaling = ToolStripItemImageScaling.None, AutoSize = false, Width = 36, Height = 36 } ); } TextureProvider.SetCachePath(SettingsManager.GetTextureCachePath()); MapProvider.Register(new RmfProvider()); MapProvider.Register(new MapFormatProvider()); MapProvider.Register(new VmfProvider()); MapProvider.Register(new ObjProvider()); GameDataProvider.Register(new FgdProvider()); TextureProvider.Register(new WadProvider()); TextureProvider.Register(new SprProvider()); TextureProvider.Register(new VmtProvider()); ModelProvider.Register(new MdlProvider()); WadProvider.ReplaceTransparentPixels = !Sledge.Settings.View.DisableWadTransparency && !Sledge.Settings.View.GloballyDisableTransparency; TextureHelper.EnableTransparency = !Sledge.Settings.View.GloballyDisableTransparency; TextureHelper.DisableTextureFiltering = Sledge.Settings.View.DisableTextureFiltering; TextureHelper.ForceNonPowerOfTwoResize = Sledge.Settings.View.ForcePowerOfTwoTextureResizing; Subscribe(); Mediator.MediatorException += (mthd, ex) => Logging.Logger.ShowException(ex.Exception, "Mediator Error: " + ex.Message); if (Sledge.Settings.View.LoadSession) { foreach (var session in SettingsManager.LoadSession()) { LoadFileGame(session.Item1, session.Item2); } } ProcessArguments(System.Environment.GetCommandLineArgs()); }
public Document(string mapFile, Map map, Game game) { MapFile = mapFile; Map = map; Game = game; Environment = new GameEnvironment(game); MapFileName = mapFile == null ? DocumentManager.GetUntitledDocumentName() : Path.GetFileName(mapFile); SelectListTransform = Matrix4.Identity; _subscriptions = new DocumentSubscriptions(this); _memory = new DocumentMemory(); var cam = Map.GetActiveCamera(); if (cam != null) { _memory.SetCamera(cam.EyePosition, cam.LookPosition); } Selection = new SelectionManager(this); History = new HistoryManager(this); if (Map.GridSpacing <= 0) { Map.GridSpacing = Grid.DefaultSize; } try { GameData = GameDataProvider.GetGameDataFromFiles(game.Fgds.Select(f => f.Path)); } catch (ProviderException) { // TODO: Error logging GameData = new GameData(); } if (game.OverrideMapSize) { GameData.MapSizeLow = game.OverrideMapSizeLow; GameData.MapSizeHigh = game.OverrideMapSizeHigh; } TextureCollection = TextureProvider.CreateCollection(Environment.GetGameDirectories(), Game.AdditionalPackages, Game.GetTextureBlacklist(), Game.GetTextureWhitelist()); /* .Union(GameData.MaterialExclusions) */ // todo material exclusions var texList = Map.GetAllTextures(); var items = TextureCollection.GetItems(texList); TextureProvider.LoadTextureItems(items); Map.PostLoadProcess(GameData, GetTexture, SettingsManager.GetSpecialTextureOpacity); Map.UpdateDecals(this); Map.UpdateModels(this); Map.UpdateSprites(this); HelperManager = new HelperManager(this); Renderer = new RenderManager(this); if (MapFile != null) { Mediator.Publish(EditorMediator.FileOpened, MapFile); } // Autosaving if (Game.Autosave) { var at = Math.Max(1, Game.AutosaveTime); Scheduler.Schedule(this, Autosave, TimeSpan.FromMinutes(at)); } }
public List <StatType> GetStatTypes(int?sportID = null, DataCache dataCache = null) { return(GameDataProvider.GetInstance().GetStatTypes(sportID, dataCache) .Select(s => ConvertObjects.ConvertType(s)).ToList()); }