// Use this for initialization void Start() { PlayerDetailsComp = GetComponent<PlayerDetails> (); DropWaterComp = GetComponent<DropWater> (); Altitude = TargetAltitude = 1.0f; OriginalScale = transform.localScale; }
public static void SelectPlayer(string name, int avatar) { //check player doesnt already exist bool playerExists = false; foreach(PlayerDetails player in players) { if(player.Name == name) { currentPlayer = player; playerExists = true; } } if(!playerExists) { PlayerDetails newPlayer = new PlayerDetails(name, avatar); players.Add(newPlayer); currentPlayer = newPlayer; Directory.CreateDirectory("SavedGames" + Path.DirectorySeparatorChar + name); } Save(); }
private static void SavePlayer(JsonWriter writer, PlayerDetails player) { writer.WriteStartObject(); writer.WritePropertyName("Name"); writer.WriteValue(player.Name); writer.WritePropertyName("Avatar"); writer.WriteValue(player.Avatar); writer.WriteEndObject(); }
// Use this for initialization void Start() { WaterCollisionCheckList = new List<Vector3>(); TimeSinceLastWaterCollisionCheck = 0.0f; SFX = GetComponents<AudioSource>(); OutOfWaterSFX = SFX[2]; DropWaterSFX = SFX[1]; OutOfWaterText.enabled = false; DropWaterFX.startLifetime = TimeForWaterToDrop; PlayerDetailsComp = GetComponent<PlayerDetails> (); }
private static void Main(string[] args) { const int MaximumTurnsWithoutDying = 35; string inputPlayerCommand = string.Empty; char[,] minefield = CreateMinefield(); char[,] mines = PlaceMinesInMinefield(); int turnsCounter = 0; bool mineExplosion = false; List<PlayerDetails> highScorersList = new List<PlayerDetails>(6); int currentRow = 0; int currentColumn = 0; bool playerIsInMainMenu = true; bool turnsExceedMaxTurns = false; do { if (playerIsInMainMenu) { Console.WriteLine("Lets play \"Minesweeper\". Try your luck and find all empty fields, without bomb explosion." + "'top'- command shows high scores, 'restart' - starts a new game, 'exit' - exits game!"); MinefieldRenderer(minefield); playerIsInMainMenu = false; } Console.Write("Input row and column: "); inputPlayerCommand = Console.ReadLine().Trim(); if (inputPlayerCommand.Length >= 3) { if (int.TryParse(inputPlayerCommand[0].ToString(), out currentRow) && int.TryParse(inputPlayerCommand[2].ToString(), out currentColumn) && currentRow <= minefield.GetLength(0) && currentColumn <= minefield.GetLength(1)) { inputPlayerCommand = "turn"; } } switch (inputPlayerCommand) { case "top": RenderHighScoresOnConsole(highScorersList); break; case "restart": minefield = CreateMinefield(); mines = PlaceMinesInMinefield(); MinefieldRenderer(minefield); mineExplosion = false; playerIsInMainMenu = false; break; case "exit": Console.WriteLine("Bye, bye, bye!"); break; case "turn": if (mines[currentRow, currentColumn] != '*') { if (mines[currentRow, currentColumn] == '-') { WorkPlayerInputCommand(minefield, mines, currentRow, currentColumn); turnsCounter++; } if (MaximumTurnsWithoutDying == turnsCounter) { turnsExceedMaxTurns = true; } else { MinefieldRenderer(minefield); } } else { mineExplosion = true; } break; default: Console.WriteLine("\nError! Invalid command!\n"); break; } if (mineExplosion) { MinefieldRenderer(mines); Console.Write("\nToo bad! You died with score of: {0}. " + "Please input name: ", turnsCounter); string nickname = Console.ReadLine(); PlayerDetails player = new PlayerDetails(nickname, turnsCounter); if (highScorersList.Count < 5) { highScorersList.Add(player); } else { for (int scorer = 0; scorer < highScorersList.Count; scorer++) { if (highScorersList[scorer].Score < player.Score) { highScorersList.Insert(scorer, player); highScorersList.RemoveAt(highScorersList.Count - 1); break; } } } highScorersList.Sort((PlayerDetails firstPlayer, PlayerDetails secondPlayer) => secondPlayer.Name.CompareTo(firstPlayer.Name)); highScorersList.Sort((PlayerDetails firstPlayer, PlayerDetails secondPlayer) => secondPlayer.Score.CompareTo(firstPlayer.Score)); RenderHighScoresOnConsole(highScorersList); minefield = CreateMinefield(); mines = PlaceMinesInMinefield(); turnsCounter = 0; mineExplosion = false; playerIsInMainMenu = true; } if (turnsExceedMaxTurns) { Console.WriteLine("\nWell done! You've just cross 35 fields without dying."); MinefieldRenderer(mines); Console.WriteLine("Please, input your name: "); string name = Console.ReadLine(); PlayerDetails score = new PlayerDetails(name, turnsCounter); highScorersList.Add(score); RenderHighScoresOnConsole(highScorersList); minefield = CreateMinefield(); mines = PlaceMinesInMinefield(); turnsCounter = 0; turnsExceedMaxTurns = false; playerIsInMainMenu = true; } } while (inputPlayerCommand != "exit"); Console.WriteLine("You are playing \"Minesweeper\"!"); Console.WriteLine("Hope you're having fun."); Console.Read(); }
private PlayerDetails GetPlayerDetails(string[] playerDetail) { if ((playerDetail.GetUpperBound(0) < 2 || playerDetail.GetUpperBound(0) > 4)) return null; bool posCodeIncluded = ((playerDetail.GetUpperBound(0) > 2) && (IsPosCode(playerDetail[2]) || IsPosCode(playerDetail[3]))); bool hasFirstName = ((playerDetail.GetUpperBound(0) == 3 && !posCodeIncluded) || (playerDetail.GetUpperBound(0) == 4 && posCodeIncluded)); var outPlayerDetail = new PlayerDetails(); outPlayerDetail.FirstName = (hasFirstName ? playerDetail[0] : "").Trim(); outPlayerDetail.LastName = (hasFirstName ? playerDetail[1] : playerDetail[0]).Trim(); outPlayerDetail.ClubCode = (hasFirstName ? playerDetail[2] : playerDetail[1]).Trim().ToUpper(); if (posCodeIncluded) outPlayerDetail.PosCode = (hasFirstName ? playerDetail[3] : playerDetail[2]).Trim().ToUpper(); int price; var priceString = playerDetail[playerDetail.GetUpperBound(0)].Replace(".",""); if (int.TryParse(priceString, out price)) outPlayerDetail.Price = price; else return null; //price imported from fantasyleague? if (outPlayerDetail.Price < 1000) outPlayerDetail.Price *= 100000; return outPlayerDetail; }
private ImportAthleteAction GetOrCreateAthleteImportAction(Guid selectedTournament, PlayerDetails playerDetails) { var importAthleteAction = new ImportAthleteAction(); try { //verify and get club var club = new ClubManagement(Global.ConnectionString, SessionProps).GetClubByCode(selectedTournament, playerDetails.ClubCode); //verify and get position Inti_Position position = null; if (!String.IsNullOrEmpty(playerDetails.PosCode)) position = new CommonDataFetches(Global.ConnectionString, SessionProps).GetPosition(playerDetails.PosCode); //try to get athlete var athlete = new AthleteManagement(Global.ConnectionString, SessionProps).GetAthleteByName(playerDetails.FirstName, playerDetails.LastName); importAthleteAction.AthleteIsStored = (athlete != null); if (athlete == null) { //athlete is added with full name? var searchString = String.IsNullOrEmpty(playerDetails.FirstName) ? playerDetails.LastName : String.Format("{0}, {1}", playerDetails.FirstName, playerDetails.LastName); IList<Inti_Athlete> matchingAthletes; using (var db = Global.GetConnection()) { matchingAthletes = Searching.SearchForAthletes(db, searchString); } if (matchingAthletes.Count == 0) { //do we have position? if (position != null) { //create new athlete athlete = new Inti_Athlete(); athlete.FirstName = playerDetails.FirstName; athlete.LastName = playerDetails.LastName; } else { importAthleteAction.Exception = new Exception("Ny spelare men position saknas. Ange med position"); } } else { if (matchingAthletes.Count ==1) { athlete = matchingAthletes[0]; importAthleteAction.ImportAction += "OBS, kontrollera namnet. "; } else { var message = "Flera spelare matchar namnet:"; foreach (var matchingAthlete in matchingAthletes) { message += (matchingAthlete.FirstName + " " + matchingAthlete.LastName).Trim() + ", "; } importAthleteAction.Exception = new Exception(message); } } } if (athlete != null) { //is the athlete already in tournament? var athleteClub = new AthleteManagement(Global.ConnectionString, SessionProps).GetAthleteClubByTournament(athlete.GUID, selectedTournament); importAthleteAction.AthleteClubIsStored = (athleteClub != null); importAthleteAction.AthleteClubIsUpToDate = true; if (athleteClub == null) { if(position != null) { athleteClub = new Inti_AthleteClub(); athleteClub.Inti_Athlete = athlete; athleteClub.Inti_Club = club; athleteClub.Inti_Position = position; athleteClub.Price = playerDetails.Price; } else { importAthleteAction.Exception = new Exception("Befintlig spelare men position saknas. Ange med position"); } } else { importAthleteAction.AthleteClubIsUpToDate = (athleteClub.Inti_Club.GUID == club.GUID); //new club if (athleteClub.Inti_Club.GUID != club.GUID) { athleteClub.Inti_Club = club; } if (position != null && athleteClub.Inti_Position.GUID != position.GUID) { importAthleteAction.Exception = new Exception(String.Format("Changed position from {0} to {1}, is it the correct player?", athleteClub.Inti_Position.ShortName, position.ShortName)); } if (athleteClub.Price != playerDetails.Price) { importAthleteAction.Exception = new Exception(String.Format("Changed price from {0} to {1}, is it the correct player?", athleteClub.Price, playerDetails.Price)); } } //set import action importAthleteAction.ImportAction += GetImportAction(importAthleteAction); importAthleteAction.AthleteClub = athleteClub; } } catch (Exception exception) { importAthleteAction.Exception = exception; } return importAthleteAction; }
// Use this for initialization void Start() { Altitude = TargetAltitude = 1.0f; Direction = new Vector3 (0, 1, 0); bDied = false; bGamePaused = false; HowToPlay=GameObject.Find ("HowToPlay").GetComponent<Image> (); HowToPlay.enabled = false; DropWaterComp = GetComponent<DropWater> (); PlayerDetailsComp = GetComponent<PlayerDetails>(); GameOverText.text = ""; DropShadowObject = transform.GetChild(0).gameObject; OriginalScale = transform.localScale; rend = gameObject.GetComponent<SpriteRenderer>(); bInTheAir = true; }
private async void SendTerrainDetailsAsync(PlaceInstanceTerrainDetails[,,] placeInstanceTerrainDetails, PlayerDetails playerDetails) { await Task.Factory.StartNew(() => SendTerrainDetails(placeInstanceTerrainDetails, playerDetails)); }
private async void HandleClientCommandsAsync() { _logger.UpdateLog("TCP client command handling started!"); List <ClientCommandInfo> clientCmdList = new List <ClientCommandInfo>(); PlayerDetails playerDetails = null; bool commandExecuted = false; while (this.State == WorkingState.Enabled) { await Task.Factory.StartNew(() => Thread.Sleep(_commandHandlingTickRate)); clientCmdList = TcpServer.GetCommandsFromAllCLients(); foreach (ClientCommandInfo cmdInfo in clientCmdList) { if (!cmdInfo.ClientInfo.IsWorking) { _playerHandler.UnregisterPlayer(cmdInfo.ClientInfo.ClientId); continue; } //COMMAND HANDLING playerDetails = _playerHandler.GetPlayer(cmdInfo.ClientInfo.ClientId); if (playerDetails == null) { playerDetails = _playerHandler.RegisterPlayer(cmdInfo.ClientInfo.ClientId); } commandExecuted = _commandHandler.ExecuteCommand(cmdInfo, playerDetails); if (!commandExecuted) { if (playerDetails != null) { if (String.IsNullOrWhiteSpace(playerDetails.Login)) { playerDetails.LoginAttemptCount++; _logger.UpdateLog($"Login attempt count set to [{playerDetails.LoginAttemptCount}] for TCP client ID [{cmdInfo.ClientInfo.ClientId}]"); if (playerDetails.LoginAttemptCount > 2) { TcpServer.KickClient(cmdInfo.ClientInfo.ClientId); _playerHandler.UnregisterPlayer(cmdInfo.ClientInfo.ClientId); _logger.UpdateLog("Player kicked!"); } } } else { _logger.UpdateLog($"Cannot execute command for TCP client ID [{cmdInfo.ClientInfo.ClientId}] - player details not found (NULL)!"); } } } if (clientCmdList.Count > 0) { clientCmdList.Clear(); } } _logger.UpdateLog("TCP client command handling stopped!"); }
private void OnEnable() { playerData = DataManager.LoadPlayer(); gold = playerData.gold; }
public PlayerDetails RetrievePlayerDetails(int playerId) { PlayerDetails result = _playerRepository.GetPlayerDetails(playerId); return(result); }
public void TestFixtureSetUp() { AutomapperConfiguration.Configure(); minionViewModelBuilderMock = MockRepository.GenerateMock <IMinionViewModelBuilder>(); mapperFactory = MockRepository.GenerateStub <IMapperFactory>(); currentUser = new ApplicationUser() { CurrentGamingGroupId = gamingGroupId, Id = "application user id" }; var gameDefinition1 = new GameDefinition() { Name = "test game 1", Id = gameDefinitionIdThatIsChampionedByCurrentPlayer, }; gameDefinitionThatIsFormerlyChampionedByCurrentPlayer = new GameDefinition { Name = "formerly championed game", Id = gameDefinitionIdThatIsFormerlyChampionedByCurrentPlayer }; gameDefinitionThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer = new GameDefinition { Name = "currently and formerly championed game", Id = gameDefinitionIdThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer }; var playedGame1 = new PlayedGame() { Id = 1, GameDefinition = gameDefinition1 }; var playedGame2 = new PlayedGame() { Id = 2, GameDefinitionId = gameDefinitionIdThatIsFormerlyChampionedByCurrentPlayer }; var playerGameResults = new List <PlayerGameResult>() { new PlayerGameResult() { PlayedGameId = 12, PlayedGame = playedGame1 }, new PlayerGameResult() { PlayedGameId = 13, PlayedGame = playedGame2 } }; normalPlayer = new PlayerVersusPlayerStatistics { OpposingPlayerName = "Jim", OpposingPlayerId = 1, OpposingPlayerActive = false, NumberOfGamesWonVersusThisPlayer = 10, NumberOfGamesLostVersusThisPlayer = 10 }; playerWithNoGamesPlayed = new PlayerVersusPlayerStatistics { OpposingPlayerId = 2 }; minionPlayer = new PlayerVersusPlayerStatistics { OpposingPlayerName = "Minion Player", OpposingPlayerId = 5, NumberOfGamesWonVersusThisPlayer = 20, NumberOfGamesLostVersusThisPlayer = 0 }; nemesisPlayer = new PlayerVersusPlayerStatistics { OpposingPlayerName = "nemesis player", OpposingPlayerId = 3, NumberOfGamesWonVersusThisPlayer = 0, NumberOfGamesLostVersusThisPlayer = 100 }; previousNemesisPlayer = new PlayerVersusPlayerStatistics { OpposingPlayerName = "Previous Nemesis Player", OpposingPlayerId = 13, NumberOfGamesWonVersusThisPlayer = 0, NumberOfGamesLostVersusThisPlayer = 42 }; var nemesis = new Nemesis() { NemesisPlayerId = nemesisPlayer.OpposingPlayerId, NumberOfGamesLost = 3, LossPercentage = 75, NemesisPlayer = new Player() { Name = "Ace Nemesis", } }; var previousNemesis = new Nemesis() { NemesisPlayerId = previousNemesisPlayer.OpposingPlayerId, NumberOfGamesLost = 5, LossPercentage = 66, NemesisPlayer = new Player() { Name = "Bravo Nemesis", } }; playerDetails = new PlayerDetails() { Id = playerId, ApplicationUserId = currentUser.Id, Active = true, Name = "Skipper", LongestWinningStreak = 39, PlayerGameResults = playerGameResults, PlayerStats = new PlayerStatistics() { TotalGames = 5, NemePointsSummary = new NemePointsSummary(1, 3, 5), AveragePlayersPerGame = 3, TotalGamesLost = 1, TotalGamesWon = 4, WinPercentage = 20 }, CurrentNemesis = nemesis, PreviousNemesis = previousNemesis, Minions = new List <Player> { new Player { Id = minionPlayer.OpposingPlayerId } }, GamingGroupId = gamingGroupId, GamingGroupName = "gaming group name", PlayerVersusPlayersStatistics = new List <PlayerVersusPlayerStatistics> { normalPlayer, playerWithNoGamesPlayed, nemesisPlayer, previousNemesisPlayer, minionPlayer }, PlayerGameSummaries = new List <PlayerGameSummary> { new PlayerGameSummary { GameDefinitionId = gameDefinitionIdThatIsChampionedByCurrentPlayer }, new PlayerGameSummary { GameDefinitionId = gameDefinitionIdThatIsFormerlyChampionedByCurrentPlayer }, new PlayerGameSummary { GameDefinitionId = gameDefinitionIdThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer } }, NemePointsSummary = new NemePointsSummary(1, 3, 5) }; gameResultViewModelBuilder = MockRepository.GenerateMock <IGameResultViewModelBuilder>(); gameResultViewModelBuilder.Expect(build => build.Build(playerGameResults[0])) .Repeat .Once() .Return(new Models.PlayedGame.GameResultViewModel() { PlayedGameId = playerGameResults[0].PlayedGameId }); gameResultViewModelBuilder.Expect(build => build.Build(playerGameResults[1])) .Repeat .Once() .Return(new Models.PlayedGame.GameResultViewModel() { PlayedGameId = playerGameResults[1].PlayedGameId }); foreach (var player in playerDetails.Minions) { minionViewModelBuilderMock.Expect(mock => mock.Build(player)) .Return(new MinionViewModel() { MinionPlayerId = player.Id }); } var championedGames = new List <Champion> { new Champion { GameDefinition = gameDefinition1, GameDefinitionId = gameDefinitionIdThatIsChampionedByCurrentPlayer }, new Champion { GameDefinition = gameDefinitionThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer, GameDefinitionId = gameDefinitionIdThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer } }; playerDetails.ChampionedGames = championedGames; var formerChampionedGames = new List <GameDefinition> { gameDefinitionThatIsFormerlyChampionedByCurrentPlayer, gameDefinitionThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer }; playerDetails.FormerChampionedGames = formerChampionedGames; builder = new PlayerDetailsViewModelBuilder(gameResultViewModelBuilder, minionViewModelBuilderMock, mapperFactory); playerDetailsViewModel = builder.Build(playerDetails, twitterMinionBraggingUrl, currentUser); }
static void PlayerWin(PlayerDetails activePlayer) { Console.WriteLine(activePlayer.Name + " HAS DONE IT, " + activePlayer.Name + " GOT 4 IN A ROW"); }