private void GameUpdateBroadcast(Game game)
 {
     Dictionary<byte, object> parameter = new Dictionary<byte, object>
     {
         {(byte)MonopolyGameStatusChangeBroadcastParameterItem.GameDataString, JsonConvert.SerializeObject(game.Serialize(), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }) }
     };
     List<Peer> peers = new List<Peer>();
     foreach (ServerUser targetUser in (game as ServerGame).users)
     {
         peers.Add(targetUser.Peer);
     }
     server.Broadcast(peers.ToArray(), BroadcastType.MonopolyGameStatusChange, parameter);
 }
 public override void LeaveGame()
 {
     base.LeaveGame();
     playingGame = null;
 }
 public override void JoinGame(Game game, int startMoney)
 {
     base.JoinGame(game, startMoney);
     playingGame = game;
 }
 public virtual void JoinGame(Game game, int startMoney)
 {
     money = startMoney;
     inGame = true;
 }
 public void JoinGame(Game game, int startMoney)
 {
     playingGame = game;
     money = startMoney;
     inGame = true;
 }
 static void Main(string[] args)
 {
     List<Player> players =  new List<Player>()
                             {
                                 new Player(0,"player1"),
                                 new Player(1,"player2")
                             };
     game = new Game(20000, players);
     foreach(Block block in game.map.blocks)
     {
         block.OnTokenPlaceInto += TokenInto;
         if (block is LandBlock)
         {
             block.OnTokenPlaceInto += PayForTollEventTask;
             block.OnTokenPlaceInto += UpgradeLandSelectionEventTask;
             block.OnTokenPlaceInto += BuyLandSelectionEventTask;
         }
         else if (block is StartBlock)
         {
             block.OnTokenPass += PassStartBlockEventTask;
         }
         else if (block is CardBlock)
         {
             block.OnTokenPlaceInto += DrawCardEventTask;
         }
     }
     Console.WriteLine("Game start....");
     string cmd;
     int steps;
     while(!game.gameOverFlag)
     {
         foreach(Player player in game.players)
         {
             Console.WriteLine(player.username+"'s turn. input roll to roll a dice");
             while ((cmd = Console.ReadLine()) != "roll")
             {
                 switch (cmd)
                 {
                     case "status":
                         {
                             PrintPlayerData(player);
                             break;
                         }
                     case "all":
                         {
                             PrintAllPlayer(players);
                             break;
                         }
                 }
             }
             steps = game.RollDice();
             Console.WriteLine("move {0} steps",steps);
             player.Move(steps);
         }
     }
 }
Exemple #7
0
 public Map(Game game)
 {
     this.game = game;
 }