Inheritance: INotifyPropertyChanged
示例#1
0
文件: RoleGame.cs 项目: maplegh/sgs
 private static void StartGameDeal(Game game)
 {
     List<CardsMovement> moves = new List<CardsMovement>();
     // Deal everyone 4 cards
     foreach (Player player in game.Players)
     {
         CardsMovement move = new CardsMovement();
         move.Cards = new List<Card>();
         move.To = new DeckPlace(player, DeckType.Hand);
         for (int i = 0; i < 4; i++)
         {
             game.SyncImmutableCard(player, game.PeekCard(0));
             Card c = game.DrawCard();
             move.Cards.Add(c);
         }
         moves.Add(move);
     }
     game.MoveCards(moves, null);
     int p = 0;
     foreach (Player player in game.Players)
     {
         game.PlayerAcquiredCard(player, moves[p].Cards);
         p++;
     }
 }
示例#2
0
文件: Server.cs 项目: maplegh/sgs
 /// <summary>
 /// Initialize and start the server.
 /// </summary>
 public Server(Game game, int capacity)
 {
     maxClients = capacity;
     handlers = new ServerHandler[capacity];
     for (int i = 0; i < capacity; i++)
     {
         handlers[i] = new ServerHandler();
     }
     this.game = game;
     Trace.TraceInformation("Server initialized with capacity {0}", capacity);
 }
示例#3
0
 public GlobalServerUiProxy(Game g, Dictionary<Player, IUiProxy> p)
 {
     game = g;
     proxy = new Dictionary<Player, ServerNetworkUiProxy>();
     foreach (var v in p)
     {
         if (!(v.Value is ServerNetworkUiProxy))
         {
             Trace.TraceWarning("Some of my proxies are not server network proxies!");
             continue;
         }
         proxy.Add(v.Key, v.Value as ServerNetworkUiProxy);
     }
 }
示例#4
0
文件: Server.cs 项目: pxoylngx/sgs
 /// <summary>
 /// Initialize and start the server.
 /// </summary>
 public Server(Game game, int capacity, IPAddress address)
 {
     ipAddress = address;
     IPEndPoint ep = new IPEndPoint(ipAddress, 0);
     listener = new TcpListener(ep);
     listener.Start();
     ipPort = ((IPEndPoint)listener.LocalEndpoint).Port;
     maxClients = capacity;
     handlers = new ServerHandler[capacity];
     for (int i = 0; i < capacity; i++)
     {
         handlers[i] = new ServerHandler();
     }
     this.game = game;
     Trace.TraceInformation("Server initialized with capacity {0}", capacity);
 }
示例#5
0
文件: Pk1v1Game.cs 项目: kradchen/sgs
 protected static void StartGameDeal(Game game, Player player)
 {
     List<CardsMovement> moves = new List<CardsMovement>();
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     move.To = new DeckPlace(player, DeckType.Hand);
     game.Emit(GameEvent.StartGameDeal, new GameEventArgs() { Source = player });
     int dealCount = player.MaxHealth + player[Player.DealAdjustment];
     for (int i = 0; i < dealCount; i++)
     {
         game.SyncImmutableCard(player, game.PeekCard(0));
         Card c = game.DrawCard();
         move.Cards.Add(c);
     }
     moves.Add(move);
     game.MoveCards(moves, null, GameDelays.GameBeforeStart);
 }
示例#6
0
文件: Server.cs 项目: shonwang/sgs
 /// <summary>
 /// Initialize and start the server.
 /// </summary>
 public Server(Game game, int capacity, IPAddress address)
 {
     isStopped = false;
     ipAddress = address;
     IPEndPoint ep = new IPEndPoint(ipAddress, 0);
     listener = new TcpListener(ep);
     listener.Start();
     ipPort = ((IPEndPoint)listener.LocalEndpoint).Port;
     numberOfGamers = capacity;
     handlers = new List<ServerHandler>();
     for (int i = 0; i < capacity; i++)
     {
         handlers.Add(new ServerHandler());
     }
     this.game = game;
     Trace.TraceInformation("Server initialized with capacity {0}", capacity);
 }
示例#7
0
 /// <summary>
 /// Initialize and start the server.
 /// </summary>
 public Server(Game game, int capacity, IPAddress address)
 {
     ipAddress = address;
     IPEndPoint ep = new IPEndPoint(ipAddress, 0);
     listener = new TcpListener(ep);
     listener.Start();
     ipPort = ((IPEndPoint)listener.LocalEndpoint).Port;
     numberOfGamers = capacity;
     Gamers = new List<ServerGamer>();
     for (int i = 0; i <= capacity; i++)
     {
         ServerGamer gamer = new ServerGamer() { Game = game, OnlineStatus = Network.OnlineStatus.Offline };
         gamer.OnDisconnected += Server_OnDisconnected;
         gamer.StartSender();
         Gamers.Add(gamer);
     }
     this.game = game;
     Trace.TraceInformation("Server initialized with capacity {0}", capacity);
 }
示例#8
0
 private static void StartGameDeal(Game game)
 {
     List<CardsMovement> moves = new List<CardsMovement>();
     // Deal everyone 4 cards
     foreach (Player player in game.AlivePlayers)
     {
         CardsMovement move = new CardsMovement();
         move.Cards = new List<Card>();
         move.To = new DeckPlace(player, DeckType.Hand);
         game.Emit(GameEvent.StartGameDeal, new GameEventArgs() { Source = player });
         int dealCount = 4 + player[Player.DealAdjustment];
         for (int i = 0; i < dealCount; i++)
         {
             game.SyncImmutableCard(player, game.PeekCard(0));
             Card c = game.DrawCard();
             move.Cards.Add(c);
         }
         moves.Add(move);
     }
     game.MoveCards(moves, null, GameDelays.GameBeforeStart);
 }
 public GlobalClientProxy(Game g, ClientNetworkProxy p, List<ClientNetworkProxy> inactive)
 {
     game = g;
     proxy = p;
     inactiveProxies = inactive;
 }
示例#10
0
文件: RoleGame.cs 项目: pxoylngx/sgs
 private void _DebugDealingDeck(Game game)
 {
     if (game.Decks[null, DeckType.Dealing].Any(tc => tc.Type is HeroCardHandler || tc.Type is RoleCardHandler || tc.Id == Card.UnknownHeroId || tc.Id == Card.UnknownRoleId))
     {
         var card = game.Decks[null, DeckType.Dealing].FirstOrDefault(tc => tc.Type is HeroCardHandler || tc.Type is RoleCardHandler || tc.Id == Card.UnknownHeroId || tc.Id == Card.UnknownRoleId);
         Trace.TraceError("Dealing deck poisoning by card {0} @ {1}", card.Id, game.Decks[null, DeckType.Dealing].IndexOf(card));
         Trace.Assert(false);
     }
 }
示例#11
0
文件: Server.cs 项目: pxoylngx/sgs
 public ServerHandler()
 {
     disconnected = false;
     semIn = new Semaphore(0, int.MaxValue);
     semOut = new Semaphore(0, int.MaxValue);
     semAccess = new Semaphore(1, 1);
     queueIn = new Queue<object>();
     queueOut = new Queue<object>();
     stream = null;
     client = null;
     commId = 0;
     threadServer = null;
     threadClient = null;
     game = null;
 }