public void AddPoints(GamePoints points) { if (GetMaxPoints().Points < points.Points) { setMaxPoints(points); } }
private string PostToDatabase(DatabaseReference reference) { GamePoints gamePoints = new GamePoints(points); string json = JsonUtility.ToJson(gamePoints); reference.Child("game_points").Child("points").SetRawJsonValueAsync(json); return("Posted to Database"); }
public static GuiManagerElement GetEndElement(GamePoints maxPoints, GuiRendererControl backToMenuControl, GuiRendererControl showRankingControl) { GuiTextRenderer mapEndedRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("Mapa finalizado") .SetBold() .SetColor("lime") .SetSize(Pixels.GetDensityIndependentPixels(40)) .Format()) .InPosition(GuiPosition.UP_CENTER) .Get(); GuiTextRenderer freeSpaceBetweenButtonsRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("\xa0") .SetSize(Pixels.GetDensityIndependentPixels(25)) .Format()) .InPosition(GuiPosition.DOWN_CENTER) .Get(); GuiTextRenderer showRankingRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("Ver clasificaci\xf3n") .SetBold() .SetColor("red") .SetSize(Pixels.GetDensityIndependentPixels(25)) .Format()) .InPosition(GuiPosition.BEFORE, freeSpaceBetweenButtonsRenderer) .WithControl(showRankingControl) .Get(); GuiTextRenderer backToMenuRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("Volver al men\xfa") .SetBold() .SetColor("cyan") .SetSize(Pixels.GetDensityIndependentPixels(25)) .Format()) .InPosition(GuiPosition.NEXT, freeSpaceBetweenButtonsRenderer) .WithControl(backToMenuControl) .Get(); GuiTextRenderer maxPointsRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("Tu r\x00e9cord: " + maxPoints.Points + " puntos") .SetBold() .SetColor("cyan") .SetSize(Pixels.GetDensityIndependentPixels(20)) .Format()) .InPosition(GuiPosition.CENTER_HALF_DOWN) .Get(); return new GuiElementGroup() .AddElement(new GuiStaticElement(mapEndedRenderer)) .AddElement(new GuiStaticElement(freeSpaceBetweenButtonsRenderer)) .AddElement(new GuiStaticElement(showRankingRenderer)) .AddElement(new GuiStaticElement(backToMenuRenderer)) .AddElement(new GuiStaticElement(maxPointsRenderer)); }
public static GuiManagerElement GetEndElement(GamePoints maxPoints, GuiRendererControl backToMenuControl, GuiRendererControl showRankingControl) { GuiTextRenderer mapEndedRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("Mapa finalizado") .SetBold() .SetColor("lime") .SetSize(Pixels.GetDensityIndependentPixels(40)) .Format()) .InPosition(GuiPosition.UP_CENTER) .Get(); GuiTextRenderer freeSpaceBetweenButtonsRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("\xa0") .SetSize(Pixels.GetDensityIndependentPixels(25)) .Format()) .InPosition(GuiPosition.DOWN_CENTER) .Get(); GuiTextRenderer showRankingRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("Ver clasificaci\xf3n") .SetBold() .SetColor("red") .SetSize(Pixels.GetDensityIndependentPixels(25)) .Format()) .InPosition(GuiPosition.BEFORE, freeSpaceBetweenButtonsRenderer) .WithControl(showRankingControl) .Get(); GuiTextRenderer backToMenuRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("Volver al men\xfa") .SetBold() .SetColor("cyan") .SetSize(Pixels.GetDensityIndependentPixels(25)) .Format()) .InPosition(GuiPosition.NEXT, freeSpaceBetweenButtonsRenderer) .WithControl(backToMenuControl) .Get(); GuiTextRenderer maxPointsRenderer = new GuiTextRendererBuilder() .WithRichText(RichTextFormatter.For("Tu r\x00e9cord: " + maxPoints.Points + " puntos") .SetBold() .SetColor("cyan") .SetSize(Pixels.GetDensityIndependentPixels(20)) .Format()) .InPosition(GuiPosition.CENTER_HALF_DOWN) .Get(); return(new GuiElementGroup() .AddElement(new GuiStaticElement(mapEndedRenderer)) .AddElement(new GuiStaticElement(freeSpaceBetweenButtonsRenderer)) .AddElement(new GuiStaticElement(showRankingRenderer)) .AddElement(new GuiStaticElement(backToMenuRenderer)) .AddElement(new GuiStaticElement(maxPointsRenderer))); }
private int getEndPoints() { if (player is NetworkTrainPlayer) { GamePoints remoteEndPoints = ((NetworkTrainPlayer)player).GetEndPoints(); if (remoteEndPoints != null) { return(remoteEndPoints.Points); } } return(points.IntPoints); }
public static bool ValidateStartNewClassicGame(GameType newGameType, GamePoints newGamePoints) { switch (newGameType) { case GameType.Classic: return(newGamePoints != GamePoints.Free); default: return(true); } }
public void changePoints(GamePoints gp, int count) { if (gp==GamePoints.Fallen) { player.Points += (5*player.Level); int y = (5 * player.Level); HasNewPoints = true; } else { player.Points += (50 * player.Level * count); HasNewPoints = true; } }
public Game(GameType type, List <Player> players, int legs, int sets, GamePoints points) { Type = type; Players = players; this.legs = legs; this.sets = sets; Points = points; legPoints = Converter.GamePointsToInt(points); StartTimeStamp = DateTime.Now; Throws = new Stack <Throw>(); Hands180 = new List <Hand180>(); Result = GameResultType.NotDefined; }
public MainWindow() { InitializeComponent(); snake = new models.Snake(); points = new GamePoints(); DispatcherTimer timer = new DispatcherTimer(); timer.Tick += TimerTIck; timer.Interval = snake.Speed; timer.Start(); KeyDown += OnButtonKeyDown; PrintSnake(); PrintPoints(); }
private void handleLocalEnd() { GamePoints finalPoints = points.GetPoints(); if (network != null) { network.LocalEndPoints(finalPoints); } SocialManager.BackgroundActions.ReportMatchEnd(points, playersPoints.PlayersCount > 1); PointsHistory pointsHistory = PointsHistoryFactory.GetForCurrentMap(); pointsHistory.AddPoints(finalPoints); GamePoints maxPoints = pointsHistory.GetMaxPoints(); gui.AddElement(GuiElementFactory.GetEndElement(maxPoints, backToMenuButton, showRankingButton)); playersPoints.DisplayEndView(); }
public static int GamePointsToInt(GamePoints points) { switch (points) { case GamePoints.Free: return(0); case GamePoints._301: return(301); case GamePoints._501: return(501); case GamePoints._701: return(701); case GamePoints._1001: return(1001); default: throw new ArgumentOutOfRangeException(nameof(points), points, null); } }
public static RpcCallSenderProcessor EndPoints(GamePoints points) { return new EndPointsRpcCallSenderProcessor(points); }
public static RpcCallSenderProcessor EndPoints(GamePoints points) { return(new EndPointsRpcCallSenderProcessor(points)); }
public void LocalEndPoints(GamePoints points) { rpcCallSender.EndPoints(points); }
public SocialActionReportToLeaderboards(GamePoints points) { this.points = points; }
public void EndPoints(GamePoints points) { setupAndSend(RpcCallSenderProcessorFactory.EndPoints(points)); }
public EndPointsRpcCallSenderProcessor(GamePoints points) : base(RPC_NAME) { this.points = points; }
public bool StartNewClassicGameValidatesCorrectly(GameType type, GamePoints points) { var isValid = Common.Validator.ValidateStartNewClassicGame(type, points); return(isValid); }
public int ConvertsCorrectly(GamePoints points) { var convertedValue = Common.Converter.GamePointsToInt(points); return(convertedValue); }
private void setMaxPoints(GamePoints points) { maxPointsStorage.Set(points.Points); }
public void SetEndPoints(GamePoints points) { endPoints = points; }
public void StartGame(Player player1, Player player2, GameType gameType, GamePoints gamePoints, int gameSets, int gameLegs) { var players = new List <Player>(); players.AddIfNotNull(player1); players.AddIfNotNull(player2); Game = new Domain.Game(gameType); dbService.GameSaveNew(Game, players); switch (gameType) { case GameType.FreeThrowsSingle: switch (gamePoints) { case GamePoints.Free: GameProcessor = new FreeThrowsSingleFreePointsProcessor(Game, players, dbService, scoreBoardService); scoreBoardService.OpenScoreBoard(gameType, players, "Free throws"); break; case GamePoints._301: GameProcessor = new FreeThrowsSingleWriteOffPointsProcessor(Game, players, dbService, scoreBoardService, 301); scoreBoardService.OpenScoreBoard(gameType, players, "Write off 301", 301); break; case GamePoints._501: GameProcessor = new FreeThrowsSingleWriteOffPointsProcessor(Game, players, dbService, scoreBoardService, 501); scoreBoardService.OpenScoreBoard(gameType, players, "Write off 501", 501); break; case GamePoints._701: GameProcessor = new FreeThrowsSingleWriteOffPointsProcessor(Game, players, dbService, scoreBoardService, 701); scoreBoardService.OpenScoreBoard(gameType, players, "Write off 701", 701); break; case GamePoints._1001: GameProcessor = new FreeThrowsSingleWriteOffPointsProcessor(Game, players, dbService, scoreBoardService, 1001); scoreBoardService.OpenScoreBoard(gameType, players, "Write off 1001", 1001); break; default: throw new ArgumentOutOfRangeException(nameof(gamePoints), gamePoints, null); } break; case GameType.FreeThrowsDouble: switch (gamePoints) { case GamePoints.Free: GameProcessor = new FreeThrowsDoubleFreePointsProcessor(Game, players, dbService, scoreBoardService); scoreBoardService.OpenScoreBoard(gameType, players, "Free throws"); break; case GamePoints._301: GameProcessor = new FreeThrowsDoubleWriteOffPointsProcessor(Game, players, dbService, scoreBoardService, 301); scoreBoardService.OpenScoreBoard(gameType, players, "Write off 301", 301); break; case GamePoints._501: GameProcessor = new FreeThrowsDoubleWriteOffPointsProcessor(Game, players, dbService, scoreBoardService, 501); scoreBoardService.OpenScoreBoard(gameType, players, "Write off 501", 501); break; case GamePoints._701: GameProcessor = new FreeThrowsDoubleWriteOffPointsProcessor(Game, players, dbService, scoreBoardService, 701); scoreBoardService.OpenScoreBoard(gameType, players, "Write off 701", 701); break; case GamePoints._1001: GameProcessor = new FreeThrowsDoubleWriteOffPointsProcessor(Game, players, dbService, scoreBoardService, 1001); scoreBoardService.OpenScoreBoard(gameType, players, "Write off 1001", 1001); break; } break; case GameType.Classic: switch (gamePoints) { case GamePoints._301: GameProcessor = new ClassicDoubleProcessor(Game, players, dbService, scoreBoardService, 301, gameLegs, gameSets); scoreBoardService.OpenScoreBoard(gameType, players, $"First to {gameSets}", 301); break; case GamePoints._501: GameProcessor = new ClassicDoubleProcessor(Game, players, dbService, scoreBoardService, 501, gameLegs, gameSets); scoreBoardService.OpenScoreBoard(gameType, players, $"First to {gameSets}", 501); break; case GamePoints._701: GameProcessor = new ClassicDoubleProcessor(Game, players, dbService, scoreBoardService, 701, gameLegs, gameSets); scoreBoardService.OpenScoreBoard(gameType, players, $"First to {gameSets}", 701); break; case GamePoints._1001: GameProcessor = new ClassicDoubleProcessor(Game, players, dbService, scoreBoardService, 1001, gameLegs, gameSets); scoreBoardService.OpenScoreBoard(gameType, players, $"First to {gameSets}", 1001); break; } break; default: throw new ArgumentOutOfRangeException(); } detectionService.OnThrowDetected += OnAnotherThrow; detectionService.OnStatusChanged += OnDetectionServiceStatusChanged; GameProcessor.OnMatchEnd += OnMatchEnd; camsDetectionBoard.OnUndoThrowButtonPressed += OnThrowUndo; camsDetectionBoard.OnCorrectThrowButtonPressed += OnThrowCorrect; }
public static void Main(string[] args) { const int Max = 35; string command = string.Empty; char[,] gameField = CreateGameField(); char[,] bombsField = CreateBombsField(); int counter = 0; int row = 0; int column = 0; bool startGame = true; bool endGame = false; bool willDetonate = false; List <GamePoints> bestGames = new List <GamePoints>(6); do { if (startGame) { Console.WriteLine("Let's play \"Mineswepper\"!\nTest your luck and try to find the fields without bombs.\nCommands:\n'top' displays current standing;\n'restartGame' begins a new game'\n'exit' quits the game!"); DrawField(gameField); startGame = false; } Console.Write("Enter rows and colums : "); command = Console.ReadLine().Trim(); if (command.Length >= 3) { if (int.TryParse(command[0].ToString(), out row) && int.TryParse(command[2].ToString(), out column) && row <= gameField.GetLength(0) && column <= gameField.GetLength(1)) { command = "turn"; } } switch (command) { case "top": DisplayGamesWithBestScores(bestGames); break; case "restartGame": gameField = CreateGameField(); bombsField = CreateBombsField(); DrawField(gameField); willDetonate = false; startGame = false; break; case "exit": Console.WriteLine("Bye!"); break; case "turn": if (bombsField[row, column] != '*') { if (bombsField[row, column] == '-') { NextMove(gameField, bombsField, row, column); counter++; } if (Max == counter) { endGame = true; } else { DrawField(gameField); } } else { willDetonate = true; } break; default: Console.WriteLine("\nError! Invalid command\n"); break; } if (willDetonate) { DrawField(bombsField); Console.Write("\nBoom! You've died with {0} points.\nEnter your nickname: ", counter); string nickname = Console.ReadLine(); GamePoints currentGamePoints = new GamePoints(nickname, counter); if (bestGames.Count < 5) { bestGames.Add(currentGamePoints); } else { for (int i = 0; i < bestGames.Count; i++) { if (bestGames[i].Points < currentGamePoints.Points) { bestGames.Insert(i, currentGamePoints); bestGames.RemoveAt(bestGames.Count - 1); break; } } } bestGames.Sort((GamePoints r1, GamePoints r2) => r2.Name.CompareTo(r1.Name)); bestGames.Sort((GamePoints r1, GamePoints r2) => r2.Points.CompareTo(r1.Points)); DisplayGamesWithBestScores(bestGames); gameField = CreateGameField(); bombsField = CreateBombsField(); counter = 0; willDetonate = false; startGame = true; } if (endGame) { Console.WriteLine("\nGood job! You successfully opened 35 fields without a single bomb exploding."); DrawField(bombsField); Console.WriteLine("Please enter your name: "); string name = Console.ReadLine(); GamePoints currentPoints = new GamePoints(name, counter); bestGames.Add(currentPoints); DisplayGamesWithBestScores(bestGames); gameField = CreateGameField(); bombsField = CreateBombsField(); counter = 0; endGame = false; startGame = true; } }while (command != "exit"); Console.WriteLine("See you soon."); Console.Read(); }
public void StartGame(List <Player> players, GameType gameType, GamePoints gamePoints, int gameSets, int gameLegs) { Game = new Domain.Game(gameType, players, gameLegs, gameSets, gamePoints); scoreBoardService.OpenScoreBoard(Game); switch (gameType) // todo ugly-spaghetti { case GameType.FreeThrowsSingle: switch (gamePoints) { case GamePoints.Free: GameProcessor = new FreeThrowsSingleFreePointsProcessor(Game, scoreBoardService); break; case GamePoints._301: case GamePoints._501: case GamePoints._701: case GamePoints._1001: GameProcessor = new FreeThrowsSingleWriteOffPointsProcessor(Game, scoreBoardService); break; default: throw new ArgumentOutOfRangeException(nameof(gamePoints), gamePoints, null); } break; case GameType.FreeThrowsDouble: switch (gamePoints) { case GamePoints.Free: GameProcessor = new FreeThrowsDoubleFreePointsProcessor(Game, scoreBoardService); break; case GamePoints._301: case GamePoints._501: case GamePoints._701: case GamePoints._1001: GameProcessor = new FreeThrowsDoubleWriteOffPointsProcessor(Game, scoreBoardService); break; } break; case GameType.Classic: GameProcessor = new ClassicDoubleProcessor(Game, scoreBoardService); break; default: throw new ArgumentOutOfRangeException(); } detectionService.OnThrowDetected += OnAnotherThrow; detectionService.OnStatusChanged += OnDetectionServiceStatusChanged; GameProcessor.OnMatchEnd += OnMatchEnd; scoreBoardService.OnUndoThrowButtonPressed += OnThrowUndo; scoreBoardService.OnManualThrowButtonPressed += OnManualThrow; }
// Use this for initialization void Start() { _gamePoints = GameObject.Find("GamePoints").GetComponent <GamePoints>(); }
public override string ToString() { return(new String(GamePoints.Select(t => t.ToChar()).ToArray())); }
// Use this for initialization void Start() { _gamePoints = GameObject.Find("GamePoints").GetComponent <GamePoints>(); _enemySpeed = Random.Range(3, 10); }