コード例 #1
0
ファイル: GameState.cs プロジェクト: harryi3t/SignalR-Demos
        public Game CreateGame(Player player1, Player player2)
        {
            Game game = new Game
            {
                Player1 = player1,
                Player2 = player2,
                Board = new GameBoard()
            };

            string group = Guid.NewGuid().ToString("d");
            _games[group] = game;

            player1.isPlaying = true;
            player2.isPlaying = true;
            player1.Group = group;
            player2.Group = group;

            Groups.Add(player1.Id, group);
            Groups.Add(player2.Id, group);

            return game;
        }
コード例 #2
0
ファイル: GameHub.cs プロジェクト: harryi3t/SignalR-Demos
 private bool IsMatch(Game game, Card card)
 {
     if (card == null)
         return false;
     if(game.LastCard != null)
     {
         if (game.LastCard.Pair == card.Id)
             return true;
     }
     return false;
 }
コード例 #3
0
ファイル: GameHub.cs プロジェクト: harryi3t/SignalR-Demos
 private Card FindCard(Game game, string cardName)
 {
     return game.Board.Pieces.FirstOrDefault(c => c.Name == cardName);
 }
コード例 #4
0
ファイル: GameState.cs プロジェクト: harryi3t/SignalR-Demos
        public void ResetGame(Game game)
        {
            var groupName = game.Player1.Group;
            var player1Name = game.Player1.Name;
            var player2Name = game.Player2.Name;

            Groups.Remove(game.Player1.Id, groupName);
            Groups.Remove(game.Player2.Id, groupName);

            Player p1, p2;
            _players.TryRemove(player1Name, out p1);
            _players.TryRemove(player1Name, out p2);

            Game g;
            _games.TryRemove(groupName, out g);
        }
コード例 #5
0
ファイル: GameState.cs プロジェクト: harryi3t/SignalR-Demos
 public Player GetOpponent(Game game, Player player)
 {
     return (game.Player1.Id == player.Id) ? game.Player2 : game.Player1;
 }