public ServerStarterModel(PlayerInfo playerInfo)
     : base(Guid.NewGuid().ToString())
 {
     this.console = new ConsoleModel(Guid.NewGuid().ToString());
       this.playerInfo = playerInfo;
       this.connectedPlayers = new ObservableCollection<PlayerAccountData>();
 }
Esempio n. 2
0
 public PlayerModel(PlayerInfo player, DeckItem deck)
     : base(player.NickName)
 {
     this.Player = player;
       this.Deck = new ObservableProperty<DeckItem, PlayerModel>(this, deck);
       this.Ready = new ObservableProperty<bool, PlayerModel>(this, false);
 }
 public ClientStarterModel(PlayerInfo playerInfo, DeckItem deck, ServicesProvider servicesProvider)
     : base(Guid.NewGuid().ToString())
 {
     this.console = new ConsoleModel(Guid.NewGuid().ToString());
       this.deck = deck;
       this.playerInfo = playerInfo;
       this.players = new ObservableCollection<PlayerAccountData>();
 }
Esempio n. 4
0
 public PlayerModel(GameModel parent, string key, PlayerInfo info, DeckItem deck, string password)
     : base(parent, null, key)
 {
     this.Info = info;
       this.Deck = deck;
       this.Points = new ObservableProperty<int, PlayerModel>(this, 0);
       this.Sectors = new ModelCollection(this);
       this.NumCounters = new ModelCollection(this);
       this.Password = password;
 }
Esempio n. 5
0
        public TestView()
        {
            InitializeComponent();
              logicStarter = new LogicHandler(new WinFormsViewFactory());

              clientPlayer1 = CreatePlayerInfo("ClientPlayer1");
              clientDeck1 = logicStarter.ServicesProvider.DecksService.LoadDeck("Reali", "Samurai");
              clientDeck1.MainCards.Shuffle();
              clientStarter1 = new ClientStarterModel(clientPlayer1, clientDeck1, logicStarter.ServicesProvider);
              clientStarter1.Started += new Action<object>(clientStarter1_Started);
              connector1 = new ClientConnector(clientPlayer1, logicStarter.ServicesProvider);

              clientPlayer2 = CreatePlayerInfo("ClientPlayer2");
              clientDeck2 = logicStarter.ServicesProvider.DecksService.LoadDeck("Reali", "Samurai");
              clientDeck2.MainCards.Shuffle();
              clientStarter2 = new ClientStarterModel(clientPlayer2, clientDeck2, logicStarter.ServicesProvider);
              clientStarter2.Started += new Action<object>(clientStarter2_Started);
              connector2 = new ClientConnector(clientPlayer2, logicStarter.ServicesProvider);

              serverPlayer = CreatePlayerInfo("ServerPlayer");
              serverDeck = logicStarter.ServicesProvider.DecksService.LoadDeck("Reali", "Samurai");
              serverDeck.MainCards.Shuffle();
        }
 public void AddPlayer(PlayerInfo player)
 {
     if(InvokeRequired)
     Invoke(new Action<PlayerInfo>(AddPlayer), player);
       else
       {
     PlayerListItem playerItem = new PlayerListItem();
     playerItem.Player = player;
     listPlayers.Controls.Add(playerItem);
       }
 }
 public void SetPlayer(string key, PlayerInfo player, bool isActive, bool handVisible)
 {
     this.Name = key;
       if(player.Picture != null)
     picAvatar.BackgroundImage = player.Picture;
       lblPlayerName.Text = player.NickName;
       toolTip.SetToolTip(picAvatar, player.Message);
 }
 public void SetPlayerReadyState(PlayerInfo player, bool ready)
 {
     if(InvokeRequired)
     Invoke(new Action<PlayerInfo, bool>(SetPlayerReadyState), player, ready);
       else
       {
     listPlayers.Controls.Find(player.NickName, true).Cast<PlayerListItem>().First().ReadyState = ready ? PlayerReadyState.Ready : PlayerReadyState.NotReady;
       }
 }
 public void RemovePlayer(PlayerInfo player)
 {
     if(InvokeRequired)
     Invoke(new Action<PlayerInfo>(RemovePlayer), player);
       else
       {
     listPlayers.Controls.RemoveByKey(player.NickName);
       }
 }
Esempio n. 10
0
        void clientStarter2_Started(object sender)
        {
            if(opponentData2 != null)
              {
            PlayerInfo[] players = new PlayerInfo[] { clientPlayer2, clientPlayer1, serverPlayer };
            DeckItem[] decks = new DeckItem[] { clientDeck2, clientDeck1, serverDeck };

            StartGame(Enumerable.Repeat(new PlayerConnection() { NetClient = opponentData2.Channel }, 1).ToList(), players.ToList(), decks.ToList(),
              new string[] { string.Empty, string.Empty, string.Empty}, GameType.Client, false);
              }
        }
Esempio n. 11
0
        void listener_PlayerConnected(object sender, ServiceNetClient client, PlayerAccountData connectedPlayer)
        {
            if(++playerCounter < 2)
            return;

              if(InvokeRequired)
            Invoke(new Action<object, ServiceNetClient, PlayerAccountData>(listener_PlayerConnected), sender, client, connectedPlayer);
              else
              {
            ServerListener listener = (ServerListener)sender;
            if(listener.PlayerConnections != null)
            {
              listener.Dispose();
              clientStarter1.Start(null);
              clientStarter2.Start(null);

              PlayerInfo[] players = new PlayerInfo[] { serverPlayer, clientPlayer2, clientPlayer1 };
              DeckItem[] decks = new DeckItem[] { serverDeck, clientDeck2, clientDeck1 };
              Thread.Sleep(1000);
              StartGame(listener.PlayerConnections, players.ToList(), decks.ToList(),
            new string[] { string.Empty, string.Empty, string.Empty }, GameType.Host, false);
            }
              }
        }
Esempio n. 12
0
        private void btnStartSolitaire_Click(object sender, EventArgs e)
        {
            PlayerInfo[] players = new PlayerInfo[] { serverPlayer, clientPlayer2, clientPlayer1 };
              DeckItem[] decks = new DeckItem[] { serverDeck, clientDeck2, clientDeck1 };

              StartGame(new List<PlayerConnection>(), players.ToList(), decks.ToList(),
            new string[] { string.Empty, string.Empty, string.Empty }, GameType.Solitaire, true);
        }
Esempio n. 13
0
        public void AddPlayer(string key, PlayerInfo info, bool isActive, bool handVisible)
        {
            if(InvokeRequired)
            Invoke(new Action<string, PlayerInfo, bool, bool>(AddPlayer), key, info, isActive, handVisible);
              else
              {
            try
            {
              gameStructure.Players.Add(new PlayerStructure() { PlayerKey = key, Item = info, IsActive = isActive });

              PlayerView playerView = new PlayerView();
              playerView.SetPlayer(key, info, isActive, handVisible);
              playerView.AnimateHand = SettingsManager.Settings.AnimateHand;
              playerView.Dock = DockStyle.Fill;
              if(isActive)
              {
            activePlayerKey = key;
            pnlGameFields.Panel2.Controls.Add(playerView);
              }
              else
              {
            pnlGameFields.Panel1Collapsed = false;
            TabPage page = new TabPage();
            page.Name = key;
            page.Text = info.NickName;
            page.Controls.Add(playerView);
            page.BorderStyle = BorderStyle.None;
            tabControl.TabPages.Add(page);
              }
              playerViews.Add(playerView);

              PlayerStatusView statusView = new PlayerStatusView();
              statusView.SetPlayer(key, info, isActive, handVisible);
              statusView.Dock = DockStyle.Fill;
              if(isActive)
            playerStatusContainer.Panel2.Controls.Add(statusView);
              else
            playerStatusContainer.Panel1.Controls.Add(statusView);
            }
            catch(Exception ex)
            {
              HandleException(ex);
            }
              }
        }
Esempio n. 14
0
 public ServerListener(PlayerInfo player, ServicesProvider servicesProvider, int port)
 {
     this.Player = player;
       this.servicesProvider = servicesProvider;
       this.netMessageService = new NetMessageService(port);
 }
Esempio n. 15
0
 protected virtual void OnPlayerDisconnected(ServiceNetClient client, PlayerInfo player)
 {
     if(PlayerDisconnected != null)
     PlayerDisconnected(this, client, player);
 }
Esempio n. 16
0
 public ClientConnector(PlayerInfo playerInfo, ServicesProvider servicesProvider)
 {
     this.playerInfo = playerInfo;
       this.servicesProvider = servicesProvider;
 }