public IActionResult CreateNewGame(long UserId, GameTypeEnum GameType) { var cntTask = _gameRepo.UserGamesPlayedToday(UserId); var cnt = cntTask.Result; if (cnt != 0) { return(new BadRequestObjectResult(new ShakeException(ShakeError.AlreadyPlayedToday, "You have already played a game today."))); } var gameTask = _gameRepo.NewGame(UserId, GameType); gameTask.Wait(); var gameId = gameTask.Result.Single(); var success = _wallets.SubtractABuck(UserId).Result; if (!success) { return(new NoContentResult()); } var getgameTask = _gameRepo.GetGameById(gameId); getgameTask.Wait(); var gameObj = getgameTask.Result; return(Ok(gameObj)); }
/// <see cref="IMultiplayerService.CreateNewGame"/> public void CreateNewGame(string mapFile, GameTypeEnum gameType, GameSpeedEnum gameSpeed) { /// TODO: this is only a PROTOTYPE implementation! this.scenarioManager.OpenScenario(mapFile); this.scenarioManager.ActiveScenario.Map.FinalizeMap(); this.playerManager = new PlayerManager(this.scenarioManager.ActiveScenario); this.playerManager[0].ConnectRandomPlayer(RaceEnum.Terran); this.playerManager[1].ConnectRandomPlayer(RaceEnum.Terran); this.playerManager[2].ConnectRandomPlayer(RaceEnum.Terran); this.playerManager[3].ConnectRandomPlayer(RaceEnum.Terran); this.playerManager.Lock(); this.selectionManager.Reset(this.playerManager[0].Player); this.fogOfWarBC.StartFogOfWar(this.playerManager[0].Player); this.mapWindowBC.ScrollTo(this.playerManager[0].StartPosition); this.commandManager.NewCommand += this.PostCommand; this.commandDispatcher = new CommandDispatcher(); this.triggeredScheduler = new TriggeredScheduler(1000 / (int)gameSpeed); this.triggeredScheduler.AddScheduledFunction(this.pathfinder.Update); this.triggeredScheduler.AddScheduledFunction(this.ExecuteCommands); this.triggeredScheduler.AddScheduledFunction(this.scenarioManager.ActiveScenario.Update); this.triggeredScheduler.AddScheduledFunction(this.commandManager.Update); this.triggeredScheduler.AddScheduledFunction(this.fogOfWarBC.ExecuteUpdateIteration); this.triggeredScheduler.AddScheduledFunction(() => { if (this.GameUpdated != null) { this.GameUpdated(); } }); this.testDssTaskCanFinishEvt = new ManualResetEvent(false); this.dssTask = this.taskManager.StartTask(this.TestDssTaskMethod, "DssThread"); }
// methods // ---------- // create initial game state // ---------- public static void createGameState(GameTypeEnum gameType) { GameType = gameType; GameStatus = GameStatusEnum.InProgress; // initialize decks ActiveDeck = new ActiveDeck(); ActiveDeckCount = "0"; DiscardDeck = new DiscardDeck(); DiscardDeckCount = "0"; // initialise actors TableDealer = createDealer(); DealerHandVisibility = Visibility.Hidden; NextGameControlsVisibility = Visibility.Hidden; ActiveGameControlsVisibility = Visibility.Visible; // initialise players list Players = new List <Player>(); PlayerTurnIndex = 0; // clear all event delegates clearEventDelegates(); }
public static Game GetByEnum(GameTypeEnum gameEnum) { foreach (Game game in GAMES) { if (game.GameType == gameEnum) { return(game); } } return(null); }
public static Game NewGameByType(GameTypeEnum gameType, GameState state) { switch (gameType) { case GameTypeEnum.Battle: return(new BattleGame(state)); default: GD.Print("NewGameByType: invalid gameType: " + gameType); return(null); } }
private RoomInfo GetRoom(GameTypeEnum GameType) { var rooms = _Loader.GetRoomList(); var orderByDescending = rooms.Where(a => !a.privateRoom && ValidateRoom(a) && a.playerCount < 8 && (a.version == bs.settings.mpVersion)).OrderByDescending(a => a.playerCount); if (android && !Application.isEditor) { orderByDescending = orderByDescending.OrderBy(a => a.maxPlayers); } RoomInfo firstOrDefault = orderByDescending.FirstOrDefault(a => a.gameType == (GameType)); return(firstOrDefault); }
public void StartNewGame(GameTypeEnum gameType) { if (games.ContainsKey(gameType)) { games[gameType].End(); games[gameType].QueueFree(); games.Remove(gameType); } games[gameType] = GameConstants.NewGameByType(gameType, state); AddChild(games[gameType]); games[gameType].Start(); activeGame = gameType; }
public Table( string id, string name, GameTypeEnum gameType, Player owner) { const int INITIAL_CAPACITY = 10; Players = new List <Player>(INITIAL_CAPACITY); History = new List <TableHistory>(INITIAL_CAPACITY); ID = id; Name = name; GameType = gameType; Owner = owner; State = TableState.Waiting; }
/* * Constructor. * <param name="gameId">game name</param> * <param name="steam">steam id</param> * <param name="gameDir">game pathname below user dir</param> * <param name="scriptFile">name of the script file containing mod entries</param> */ public Game(GameTypeEnum gameType, string gameId, string steam, string gameDir, string scriptFile = "user.script.txt") { GameType = gameType; Id = gameId; steamId = steam; UserDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "The Creative Assembly", gameDir); ScriptFilename = scriptFile; DefaultPfhType = "PFH3"; retrievers = new RetrieveLocation[] { delegate() { return(gameDirectory); }, delegate() { return(GetInstallLocation(WOW_NODE)); }, delegate() { return(GetInstallLocation(WIN_NODE)); } }; }
public async Task <IEnumerable <long> > NewGame(long UserId, GameTypeEnum type) { var obj = new { UserId = UserId, gType = (int)type, Year = DateTime.Now.Year, Day = DateTime.Now.DayOfYear }; var insSql = $@" Insert Into Games(TypeId,UserId,Year,Day) Values(@gType, @UserId, @Year, @Day); SELECT CAST(SCOPE_IDENTITY() as bigint) "; return(await _conn.QueryAsync <long>(insSql, obj)); }
void Load(GameTypeEnum game) { if (_gameTableDefinitions.ContainsKey(game)) { return; } string path = DirectoryHelper.SchemaDirectory + "\\" + GameInformationFactory.GetGameById(game).ShortID + "_schema.json"; // Try local copy first if (!File.Exists(path)) { path = "Resources\\Schemas\\" + GameInformationFactory.GetGameById(game).ShortID + "_schema.json"; } var content = LoadSchemaFile(path); if (content != null) { _gameTableDefinitions.Add(game, content); } path = DirectoryHelper.SchemaDirectory + "\\" + GameInformationFactory.GetGameById(game).ShortID + "_AnimMetaDataSchema.json"; // Try local copy first if (!File.Exists(path)) { var allResource = GetResourceNames(); var resourceFileName = GameInformationFactory.GetGameById(game).ShortID + "_AnimMetaDataSchema.json"; var entry = allResource.FirstOrDefault(x => x.Key.ToString().Contains(resourceFileName, StringComparison.InvariantCultureIgnoreCase)); if (entry.Key != null) { using var resourceReader = new StreamReader(entry.Value as Stream); var resourceContent = resourceReader.ReadToEnd(); content = LoadSchemaFileFromContent(resourceContent); } } else { content = LoadSchemaFile(path); } if (content != null) { _gameAnimMetaDefinitions.Add(game, content); } }
public void HostRoomWindow() { SetupWindow(800, 600); gui.BeginHorizontal(); gui.BeginVertical(); bool startButton = Button("Start"); if (Button("Load Map from url")) { LoadMapFromUrl(); } Label("Room Name:"); room.name = gui.TextField(room.name, 20); room.privateRoom = Toggle(room.privateRoom, "Private Room"); GameTypeEnum gameType = (GameTypeEnum)Toolbar((int)room.gameType, new[] { "StreetRace", "Pursuit", "Deathmatch", "TDM" }, hor: 2, title: "Game Type"); if (gameType != room.gameType) { room.gameType = gameType; room.matchTime = 3 * 60; } room.maxPlayers2 = (int)HorizontalSlider("Max Players", room.maxPlayers2, 1, 30, startButton); gui.EndVertical(); gui.BeginVertical(skin.box); gui.Label(mapStats.texture); Label(Tr("Select Map")); foreach (var a in bs.settings.maps) { if ((a.hidden == 0 || isDebug) && GlowButton(a.mapName, a == room.sets.mapStats)) { room.sets.mapStats = a; } } gui.EndVertical(); gui.EndHorizontal(); if (startButton) { _Loader.StartCoroutine(_Loader.LoadLevel(true)); } }
/// <summary> /// game type -> level select /// </summary> private void OnGameType_SelectSinglePlayer(Button button, MouseButtonEventArgs eventArgs) { GameType = GameTypeEnum.SinglePlayer; SwitchGui(mmm.GameTypeGui, mmm.LevelSelectGui); }
public static int NumberOfWinsBy(this IEnumerable <HistoryModel> historyModels, GameTypeEnum gameType) { return(historyModels.Count((historyModel) => gameType == historyModel.GameType)); }
public static GameInformation GetGameById(GameTypeEnum type) { return(Games.FirstOrDefault(x => x.Type == type)); }
/// <summary> /// /// </summary> /// <param name="gameType"></param> public GameTypeAttribute(GameTypeEnum gameType) { GameType = gameType; }
/// <summary> /// creates a new instance and overall a brand new roller derby game. /// </summary> public void createNewGame(GameTypeEnum gameType) { try { //we need to save the settings from the initial window that the user selected. bool saveGameOnline = GameViewModel.Instance.SaveGameOnline; bool publishGame = GameViewModel.Instance.PublishGameOnline; bool beingTested = GameViewModel.Instance.IsBeingTested; instance = new GameViewModel(); #if DEBUG instance.ScoreboardMode = ScoreboardModeEnum.Debug; #else instance.ScoreboardMode = ScoreboardModeEnum.Live; #endif instance.SaveGameOnline = saveGameOnline; instance.PublishGameOnline = publishGame; instance.IsBeingTested = beingTested; instance.GameId = Guid.NewGuid(); instance.IdForOnlineManagementUse = Guid.NewGuid(); instance.Policy = PolicyViewModel.Instance; instance.Team1.TimeOutsLeft = PolicyViewModel.Instance.TimeOutsPerPeriod; instance.Team2.TimeOutsLeft = PolicyViewModel.Instance.TimeOutsPerPeriod; //must start with a negative one for pre game intermissions... //should prob do this a better way, but havent figured it out yet. GameViewModel.Instance.CurrentPeriod = 0; //TODO: Team names should be different? instance.Team1.TeamName = "Home"; instance.CurrentTeam1Score = 0; instance.CurrentTeam1JamScore = 0; instance.ScoresTeam1 = new List<ScoreViewModel>(); instance.Team1.TeamId = Guid.NewGuid(); instance.Team2.TeamName = "Away"; instance.Team1.Logo = new TeamLogo(); instance.Team2.Logo = new TeamLogo(); instance.CurrentTeam2Score = 0; instance.CurrentTeam2JamScore = 0; instance.ScoresTeam2 = new List<ScoreViewModel>(); instance.Team2.TeamId = Guid.NewGuid(); instance.GameDate = DateTime.UtcNow; instance.TimeOuts = new List<TimeOutViewModel>(); instance.GameName = "Bout"; instance.CurrentIntermission = GameViewModelIntermissionTypeEnum.PreGameIntermission; instance.NameOfIntermission = PolicyViewModel.Instance.IntermissionOtherText; createNewPeriod(); createLineUpClock(); instance.Jams.Clear(); instance.CurrentJam = null; createNewJam(); createNewIntermission(); instance.Advertisements = new List<AdvertisementViewModel>(); instance.SlideShowSlides = new List<SlideShowViewModel>(); AdvertisementViewModel.getAdvertsFromDirectory(); setupAdvertisements(); setCurrentAdvertisement(); _team1.clearTeamPositions(); _team2.clearTeamPositions(); setupTimerForOnlineGame(); setupTimerForSlideShow(); instance.EditModeItems = new List<EditModeModel>(); instance.AssistsForTeam1 = new List<AssistViewModel>(); instance.BlocksForTeam1 = new List<BlockViewModel>(); instance.PenaltiesForTeam1 = new List<PenaltyViewModel>(); instance.AssistsForTeam2 = new List<AssistViewModel>(); instance.BlocksForTeam2 = new List<BlockViewModel>(); instance.PenaltiesForTeam2 = new List<PenaltyViewModel>(); instance.OfficialReviews = new List<OfficialReviewViewModel>(); instance.UsingServerScoring = false; instance.Officials = new Officials.Officials(); instance.ScoreboardSettings = new ScoreboardSettings(); liveGameTimer_Elapsed(this, null); this.NewGame(this, null); } catch (Exception e) { ErrorViewModel.Save(e, this.GetType(), ErrorGroupEnum.UI); } }
public static void SetGameType(GameTypeEnum value) { PlayerPrefs.SetString(GAME_TYPE_KEY, value.ToString()); }
private RoomInfo GetRoom(GameTypeEnum GameType) { var rooms = _Loader.GetRoomList(); var orderByDescending = rooms.Where(a => !a.privateRoom && ValidateRoom(a) && a.playerCount < 8 && (a.version == bs.settings.mpVersion)).OrderByDescending(a => a.playerCount); if (android && !Application.isEditor) orderByDescending = orderByDescending.OrderBy(a => a.maxPlayers); RoomInfo firstOrDefault = orderByDescending.FirstOrDefault(a => a.gameType == (GameType)); return firstOrDefault; }
public async Task <GameType> GetGameType(GameTypeEnum typeIn) { var sql = @"select Id, Name, RollsPerGame, MaxPlaysPerDay From GameTypes where Id = @typeId"; return(await _conn.QueryFirstOrDefaultAsync <GameType>(sql, new { typeId = (int)typeIn })); }
/// <summary> /// level select -> previous /// </summary> private void OnLevelSelect_SelectBack(Button button, MouseButtonEventArgs eventArgs) { switch (GameType) { case GameTypeEnum.SinglePlayer: GameType = GameTypeEnum.None; SwitchGui(mmm.LevelSelectGui, mmm.GameTypeGui); break; case GameTypeEnum.NetworkedHost: mmm.NetworkHostPasswordTextBox.Text = ""; mmm.NetworkHostPortTextBox.Text = ""; LKernel.GetG<NetworkManager>().StopThread(); SwitchGui(mmm.LevelSelectGui, mmm.NetworkHostGui); break; default: throw new InvalidOperationException("OnLevelSelect_SelectBack was invoked from an invalid GUI state - how did we get here?"); } }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { await this.RunAsyncOperation(async() => { if (string.IsNullOrEmpty(this.GameNameTextBox.Text)) { await MessageBoxHelper.ShowMessageDialog("Name is missing"); return; } if (string.IsNullOrEmpty(this.GameChatCommandTextBox.Text)) { await MessageBoxHelper.ShowMessageDialog("Commands is missing"); return; } if (this.GameChatCommandTextBox.Text.Any(c => !Char.IsLetterOrDigit(c) && !Char.IsWhiteSpace(c))) { await MessageBoxHelper.ShowMessageDialog("Commands can only contain letters and numbers"); return; } foreach (PermissionsCommandBase command in ChannelSession.AllChatCommands) { if (this.command != command && this.GameNameTextBox.Text.Equals(command.Name)) { await MessageBoxHelper.ShowMessageDialog("There already exists a chat command with the same name"); return; } } IEnumerable <string> commandStrings = this.GetCommandStrings(); if (commandStrings.GroupBy(c => c).Where(g => g.Count() > 1).Count() > 0) { await MessageBoxHelper.ShowMessageDialog("Each command string must be unique"); return; } foreach (PermissionsCommandBase command in ChannelSession.AllChatCommands) { if (command.IsEnabled && this.GetExistingCommand() != command) { if (commandStrings.Any(c => command.Commands.Contains(c))) { await MessageBoxHelper.ShowMessageDialog("There already exists a chat command that uses one of the command strings you have specified"); return; } } } int cooldown = 0; if (!int.TryParse(this.GameCooldownTextBox.Text, out cooldown) || cooldown < 0) { await MessageBoxHelper.ShowMessageDialog("Cooldown must be 0 or greater"); return; } if (this.GameLowestRoleAllowedComboBox.SelectedIndex < 0) { await MessageBoxHelper.ShowMessageDialog("A permission level must be selected"); return; } if (this.GameTypeComboBox.SelectedIndex < 0) { await MessageBoxHelper.ShowMessageDialog("A game type must be selected"); return; } GameTypeEnum gameType = EnumHelper.GetEnumValueFromString <GameTypeEnum>((string)this.GameTypeComboBox.SelectedItem); if (this.CurrencyTypeComboBox.SelectedIndex < 0 || this.CurrencyRequirementTypeComboBox.SelectedIndex < 0) { await MessageBoxHelper.ShowMessageDialog("A currency type and requirement must be selected"); return; } int minimum = 0; int maximum = 0; CurrencyRequirementTypeEnum currencyRequirementType = EnumHelper.GetEnumValueFromString <CurrencyRequirementTypeEnum>((string)this.CurrencyRequirementTypeComboBox.SelectedItem); if (currencyRequirementType != CurrencyRequirementTypeEnum.NoCurrencyCost && (!int.TryParse(this.CurrencyMinimumCostTextBox.Text, out minimum) || minimum < 0)) { await MessageBoxHelper.ShowMessageDialog("The currency minimum must be 0 or greater"); return; } if (currencyRequirementType == CurrencyRequirementTypeEnum.MinimumAndMaximum && (!int.TryParse(this.CurrencyMaximumCostTextBox.Text, out maximum) || maximum <= minimum)) { await MessageBoxHelper.ShowMessageDialog("The currency maximum must be greater than the minimum"); return; } int gameLength = 0; int minParticipants = 0; if (this.MultiplayerGameDetailsGrid.Visibility == Visibility.Visible) { if (!int.TryParse(this.GameLengthTextBox.Text, out gameLength) || gameLength < 0) { await MessageBoxHelper.ShowMessageDialog("Game length must be 0 or greater"); return; } if (!int.TryParse(this.GameMinimumParticipantsTextBox.Text, out minParticipants) || minParticipants < 1) { await MessageBoxHelper.ShowMessageDialog("Minimum participants must be 1 or greater"); return; } } List <GameOutcome> outcomes = new List <GameOutcome>(); List <GameOutcomeGroup> outcomeGroups = new List <GameOutcomeGroup>(); if (gameType == GameTypeEnum.SinglePlayer || gameType == GameTypeEnum.IndividualProbabilty) { foreach (GameOutcomeCommandControl commandControl in this.outcomeCommandControls) { GameOutcome outcome = await commandControl.GetOutcome(); if (outcome == null) { return; } outcomes.Add(outcome); } if (outcomes.Select(o => o.Name).GroupBy(n => n).Where(g => g.Count() > 1).Count() > 0) { await MessageBoxHelper.ShowMessageDialog("Each outcome must have a unique name"); return; } foreach (GameOutcomeGroupControl groupControl in this.outcomeGroupControls) { GameOutcomeGroup group = await groupControl.GetOutcomeGroup(); if (group == null) { return; } outcomeGroups.Add(group); for (int i = 0; i < outcomes.Count; i++) { group.Probabilities[i].OutcomeName = outcomes[i].Name; } } } UserRole permissionsRole = EnumHelper.GetEnumValueFromString <UserRole>((string)this.GameLowestRoleAllowedComboBox.SelectedItem); if (this.command != null) { ChannelSession.Settings.GameCommands.Remove(this.command); } UserCurrencyRequirementViewModel currencyRequirement = new UserCurrencyRequirementViewModel((UserCurrencyViewModel)this.CurrencyTypeComboBox.SelectedItem, minimum, maximum); if (gameType == GameTypeEnum.SinglePlayer) { this.command = new SinglePlayerGameCommand(this.GameNameTextBox.Text, this.GetCommandStrings(), permissionsRole, cooldown, currencyRequirement, currencyRequirementType, outcomes, outcomeGroups, this.LoseLeftoverProbabilityCommandControl.GetCommand()); } else if (gameType == GameTypeEnum.IndividualProbabilty) { IndividualProbabilityGameCommand ipCommand = new IndividualProbabilityGameCommand(this.GameNameTextBox.Text, this.GetCommandStrings(), permissionsRole, cooldown, currencyRequirement, currencyRequirementType, outcomes, outcomeGroups, this.LoseLeftoverProbabilityCommandControl.GetCommand(), gameLength, minParticipants); ipCommand.GameStartedCommand = this.GameStartedCommandControl.GetCommand(); ipCommand.GameEndedCommand = this.GameEndedCommandControl.GetCommand(); ipCommand.UserJoinedCommand = this.UserJoinedCommandControl.GetCommand(); ipCommand.NotEnoughUsersCommand = this.NotEnoughUsersCommandControl.GetCommand(); this.command = ipCommand; } else if (gameType == GameTypeEnum.OnlyOneWinner) { OnlyOneWinnerGameCommand oowCommand = new OnlyOneWinnerGameCommand(this.GameNameTextBox.Text, this.GetCommandStrings(), permissionsRole, cooldown, currencyRequirement, gameLength, minParticipants); oowCommand.GameStartedCommand = this.GameStartedCommandControl.GetCommand(); oowCommand.GameEndedCommand = this.GameEndedCommandControl.GetCommand(); oowCommand.UserJoinedCommand = this.UserJoinedCommandControl.GetCommand(); oowCommand.NotEnoughUsersCommand = this.NotEnoughUsersCommandControl.GetCommand(); this.command = oowCommand; } else if (gameType == GameTypeEnum.UserCharity) { UserCharityGameCommand ucCommand = new UserCharityGameCommand(this.GameNameTextBox.Text, this.GetCommandStrings(), permissionsRole, cooldown, currencyRequirement, currencyRequirementType, this.GiveToRandomUserCharityToggleButton.IsChecked.GetValueOrDefault()); ucCommand.UserParticipatedCommand = this.UserParticipatedCommandControl.GetCommand(); this.command = ucCommand; } ChannelSession.Settings.GameCommands.Add(this.command); await ChannelSession.SaveSettings(); this.Close(); }); }
/// <summary> /// makes the proper game policy changes to the game /// </summary> /// <param name="gameType"></param> public void changeGameSelectionType(GameTypeEnum gameType) { GameSelectionType = gameType.ToString(); if (gameType == GameTypeEnum.MADE) { NumberOfPeriods = 4; PeriodClock = (long)TimeSpan.FromMinutes(15).TotalMilliseconds; JamClockTimePerJam = (long)TimeSpan.FromSeconds(90).TotalMilliseconds; LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; TimeOutsPerPeriod = 3; } else if (gameType == GameTypeEnum.MADE_COED) { NumberOfPeriods = 8; PeriodClock = (long)TimeSpan.FromMinutes(10).TotalMilliseconds; JamClockTimePerJam = (long)TimeSpan.FromSeconds(90).TotalMilliseconds; LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; TimeOutsPerPeriod = 3; } else if (gameType == GameTypeEnum.WFTDA) { NumberOfPeriods = 2; PeriodClock = (long)TimeSpan.FromMinutes(30).TotalMilliseconds; JamClockTimePerJam = (long)TimeSpan.FromMinutes(2).TotalMilliseconds; LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; TimeOutsPerPeriod = 2; } else if (gameType == GameTypeEnum.RENEGADE) {//TODO: find renenegade rule set } else if (gameType == GameTypeEnum.OSDA) { NumberOfPeriods = 4; PeriodClock = (long)TimeSpan.FromMinutes(15).TotalMilliseconds; JamClockTimePerJam = (long)TimeSpan.FromMinutes(90).TotalMilliseconds; LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; TimeOutsPerPeriod = 1; } else if (gameType == GameTypeEnum.OSDA_COED) { NumberOfPeriods = 8; PeriodClock = (long)TimeSpan.FromMinutes(10).TotalMilliseconds; JamClockTimePerJam = (long)TimeSpan.FromSeconds(90).TotalMilliseconds; LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; TimeOutsPerPeriod = 1; } }
/// <summary> /// game type -> network host /// </summary> private void OnGameType_SelectNetworkedHost(Button button, MouseButtonEventArgs eventArgs) { GameType = GameTypeEnum.NetworkedHost; mmm.NetworkHostPasswordTextBox.Text = ""; mmm.NetworkHostPortTextBox.Text = ""; SwitchGui(mmm.GameTypeGui, mmm.NetworkHostGui); }
/// <summary> /// creates a new instance and overall a brand new roller derby game. /// </summary> public void createNewGame(GameTypeEnum gameType) { instance = new GameViewModel(); instance.GameId = Guid.NewGuid(); //instance.Periods = Config.WFTDA_DEFAULT_PERIODS; instance.Team1.TimeOutsLeft = PolicyViewModel.Instance.TimeOutsPerPeriod; instance.Team2.TimeOutsLeft = PolicyViewModel.Instance.TimeOutsPerPeriod; GameViewModel.Instance.CurrentPeriod = 0; //TODO: Team names should be different? instance.Team1.TeamName = "Home"; instance.CurrentTeam1Score = 0; instance.ScoresTeam1 = new List<ScoreViewModel>(); instance.Team1.TeamId = Guid.NewGuid(); instance.Team2.TeamName = "Away"; instance.CurrentTeam2Score = 0; instance.ScoresTeam2 = new List<ScoreViewModel>(); instance.Team2.TeamId = Guid.NewGuid(); instance.GameDate = DateTime.UtcNow; instance.TimeOuts = new List<TimeOutViewModel>(); createNewPeriod(); createNewJam(); createLineUpClock(); instance.Advertisements = new List<AdvertisementViewModel>(); AdvertisementViewModel.getAdvertsFromDirectory(); setupAdvertisements(); setCurrentAdvertisement(); this.NewGame(this, null); }
private async void GameTypeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { await this.RunAsyncOperation(async() => { if (this.GameTypeComboBox.SelectedIndex >= 0) { this.CurrencyGrid.IsEnabled = true; this.MultiplayerGameDetailsGrid.Visibility = Visibility.Collapsed; this.OutcomesDetailsGrid.Visibility = Visibility.Collapsed; this.UserCharityGameGrid.Visibility = Visibility.Collapsed; GameTypeEnum gameType = EnumHelper.GetEnumValueFromString <GameTypeEnum>((string)this.GameTypeComboBox.SelectedItem); if (gameType == GameTypeEnum.OnlyOneWinner) { this.CurrencyRequirementTypeComboBox.SelectedItem = EnumHelper.GetEnumName(CurrencyRequirementTypeEnum.RequiredAmount); this.CurrencyRequirementTypeComboBox.IsEnabled = false; } else { this.CurrencyRequirementTypeComboBox.SelectedIndex = -1; this.CurrencyRequirementTypeComboBox.IsEnabled = true; } if (gameType == GameTypeEnum.IndividualProbabilty || gameType == GameTypeEnum.OnlyOneWinner) { this.MultiplayerGameDetailsGrid.Visibility = Visibility.Visible; } if (gameType == GameTypeEnum.SinglePlayer || gameType == GameTypeEnum.IndividualProbabilty) { this.OutcomesDetailsGrid.Visibility = Visibility.Visible; this.outcomeCommandControls.Clear(); GameOutcomeCommandControl outcomeControl = new GameOutcomeCommandControl(new GameOutcome("Win")); await outcomeControl.Initialize(this); this.outcomeCommandControls.Add(outcomeControl); this.outcomeGroupControls.Clear(); GameOutcomeGroup userGroup = new GameOutcomeGroup(UserRole.User); userGroup.Probabilities.Add(new GameOutcomeProbability(50, 25)); this.outcomeGroupControls.Add(new GameOutcomeGroupControl(userGroup)); GameOutcomeGroup subscriberGroup = new GameOutcomeGroup(UserRole.Subscriber); subscriberGroup.Probabilities.Add(new GameOutcomeProbability(50, 25)); this.outcomeGroupControls.Add(new GameOutcomeGroupControl(subscriberGroup)); GameOutcomeGroup modGroup = new GameOutcomeGroup(UserRole.Mod); modGroup.Probabilities.Add(new GameOutcomeProbability(50, 25)); this.outcomeGroupControls.Add(new GameOutcomeGroupControl(modGroup)); } if (gameType == GameTypeEnum.UserCharity) { this.UserCharityGameGrid.Visibility = Visibility.Visible; } } }); }
/// <summary> /// makes the proper game policy changes to the game /// </summary> /// <param name="gameType"></param> public void changeGameSelectionType(GameTypeEnum gameType) { try { GameSelectionType = gameType; if (gameType == GameTypeEnum.MADE) { instance.NumberOfPeriods = 4; instance.PeriodClock = (long)TimeSpan.FromMinutes(15).TotalMilliseconds; instance.JamClockTimePerJam = (long)TimeSpan.FromSeconds(90).TotalMilliseconds; instance.LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; instance.TimeOutsPerPeriod = 1; } else if (gameType == GameTypeEnum.TEXAS_DERBY) { instance.NumberOfPeriods = 4; instance.PeriodClock = (long)TimeSpan.FromMinutes(8).TotalMilliseconds; instance.JamClockTimePerJam = (long)TimeSpan.FromSeconds(60).TotalMilliseconds; instance.LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; instance.TimeOutsPerPeriod = 1; instance.TimeOutClock = (long)TimeSpan.FromSeconds(120).TotalMilliseconds; } else if (gameType == GameTypeEnum.MADE_COED) { instance.NumberOfPeriods = 8; instance.PeriodClock = (long)TimeSpan.FromMinutes(15).TotalMilliseconds; instance.JamClockTimePerJam = (long)TimeSpan.FromSeconds(90).TotalMilliseconds; instance.LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; instance.TimeOutsPerPeriod = 1; } else if (gameType == GameTypeEnum.RDCL) { instance.NumberOfPeriods = 4; instance.PeriodClock = (long)TimeSpan.FromMinutes(15).TotalMilliseconds; instance.JamClockTimePerJam = (long)TimeSpan.FromSeconds(60).TotalMilliseconds; instance.LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; instance.TimeOutsPerPeriod = 3; } else if (gameType == GameTypeEnum.WFTDA_2010) { instance.NumberOfPeriods = 2; instance.PeriodClock = (long)TimeSpan.FromMinutes(30).TotalMilliseconds; instance.JamClockTimePerJam = (long)TimeSpan.FromMinutes(2).TotalMilliseconds; instance.LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; instance.TimeOutsPerPeriod = 2; instance.StopPeriodClockWhenLineUpClockHitsZero = false; } else if (gameType == GameTypeEnum.WFTDA) { instance.NumberOfPeriods = 2; instance.PeriodClock = (long)TimeSpan.FromMinutes(30).TotalMilliseconds; instance.JamClockTimePerJam = (long)TimeSpan.FromMinutes(2).TotalMilliseconds; instance.LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; instance.TimeOutsPerPeriod = 3; instance.StopPeriodClockWhenLineUpClockHitsZero = false; } else if (gameType == GameTypeEnum.USARS) { instance.NumberOfPeriods = 2; instance.PeriodClock = (long)TimeSpan.FromMinutes(30).TotalMilliseconds; instance.JamClockTimePerJam = (long)TimeSpan.FromMinutes(2).TotalMilliseconds; instance.LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; instance.TimeOutsPerPeriod = 3; instance.TimeOutClock = (long)TimeSpan.FromSeconds(90).TotalMilliseconds; } else if (gameType == GameTypeEnum.RENEGADE) {//TODO: find renenegade rule set } else if (gameType == GameTypeEnum.OSDA) { instance.NumberOfPeriods = 4; instance.PeriodClock = (long)TimeSpan.FromMinutes(15).TotalMilliseconds; instance.JamClockTimePerJam = (long)TimeSpan.FromMinutes(90).TotalMilliseconds; instance.LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; instance.TimeOutsPerPeriod = 1; } else if (gameType == GameTypeEnum.OSDA_COED) { instance.NumberOfPeriods = 8; instance.PeriodClock = (long)TimeSpan.FromMinutes(10).TotalMilliseconds; instance.JamClockTimePerJam = (long)TimeSpan.FromSeconds(90).TotalMilliseconds; instance.LineUpClockPerJam = (long)TimeSpan.FromSeconds(30).TotalMilliseconds; instance.TimeOutsPerPeriod = 1; } else if (gameType == GameTypeEnum.CUSTOM) { //because its custom game, we let the user decide all the presets. } } catch (Exception exception) { ErrorViewModel.Save(exception, this.GetType(), ErrorGroupEnum.UI); } }
/////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// network host -> game type /// </summary> private void OnHostInfo_SelectBack(Button button, MouseButtonEventArgs eventArgs) { GameType = GameTypeEnum.None; SwitchGui(mmm.NetworkHostGui, mmm.GameTypeGui); }
public static void SetGameType(GameTypeEnum arg_gameType) { gameType = arg_gameType; }
private void OnLevelLoad(LevelChangedEventArgs eventArgs) { // don't need to unhide/hide any GUIs, since that's all done in the MainMenuManager if (eventArgs.NewLevel.Type == LevelType.Menu) GameType = GameTypeEnum.None; }