コード例 #1
0
ファイル: EventManager.cs プロジェクト: Shoko84/Coinche
        /**
         *  Triggered when the it's the announce turn of the client
         *  @param   header      Infos about the header.
         *  @param   connection  Infos about the server's connection.
         *  @param   message     A client id.
         */
        public void PlayerAnnounce(PacketHeader header, Connection connection, string message)
        {
            if (GameInfos.Instance.GameStatus < GAME_STATUS.ANNONCE)
            {
                GameInfos.Instance.GameStatus = GAME_STATUS.ANNONCE;
            }
            if (GameInfos.Instance.GameStatus == GAME_STATUS.ANNONCE)
            {
                App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(delegate()
                {
                    GameWindow.Instance.ContentArea.Content = GameWindow.Instance.ContractCallCont;
                    ContractCallContent content             = GameWindow.Instance.ContractCallCont;
                    int userId = int.Parse(message);

                    if (userId == GameInfos.Instance.MyId)
                    {
                        content.ContractBox.IsEnabled        = true;
                        content.ContractValue.IsEnabled      = true;
                        content.ContractCallButton.IsEnabled = true;
                    }
                    else
                    {
                        content.ContractBox.IsEnabled        = false;
                        content.ContractValue.IsEnabled      = false;
                        content.ContractCallButton.IsEnabled = false;
                    }
                    foreach (var user in GameInfos.Instance.UsersList)
                    {
                        if (user.Id == userId)
                        {
                            user.IsPlaying = true;
                        }
                        else
                        {
                            user.IsPlaying = false;
                        }
                    }
                    if (GameWindow.Instance.GameLogger.Text != "")
                    {
                        GameWindow.Instance.GameLogger.Text += "\n\n";
                    }
                    GameWindow.Instance.GameLogger.Text += "[" + DateTime.Now.ToLongTimeString().ToString() + "] " +
                                                           GameInfos.Instance.GetClientUserById(userId).Username +
                                                           " is now announcing";
                    GameWindow.Instance.GameLoggerScroller.ScrollToBottom();
                    GameWindow.Instance.DrawCanvas();
                }));
            }
        }
コード例 #2
0
ファイル: EventManager.cs プロジェクト: Shoko84/Coinche
        /**
         *  Triggered when someone announced
         *  @param   header      Infos about the header.
         *  @param   connection  Infos about the server's connection.
         *  @param   message     A contract.
         */
        public void SomeoneHasAnnounced(PacketHeader header, Connection connection, string message)
        {
            Contract contract = JsonConvert.DeserializeObject <Contract>(message);

            App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(delegate()
            {
                if (contract.type != CONTRACT_TYPE.PASS)
                {
                    ContractCallContent content = GameWindow.Instance.ContractCallCont;

                    if (contract.score < 160)
                    {
                        content.ContractValue.Minimum = contract.score + 10;
                        content.ContractValue.Value   = contract.score + 10;
                    }
                    else
                    {
                        content.ContractValue.Minimum = 160;
                        content.ContractValue.Value   = 160;
                    }
                    if (GameInfos.Instance.ContractPicked == null || GameInfos.Instance.ContractPicked.score < contract.score)
                    {
                        GameInfos.Instance.ContractPicked = new Contract(contract.score, contract.type, contract.id);
                    }
                    if (GameWindow.Instance.GameLogger.Text != "")
                    {
                        GameWindow.Instance.GameLogger.Text += "\n\n";
                    }
                    GameWindow.Instance.GameLogger.Text += "[" + DateTime.Now.ToLongTimeString().ToString() + "] " +
                                                           GameInfos.Instance.GetClientUserById(contract.id).Username +
                                                           " announced a contract with a value of " + contract.score.ToString() +
                                                           " and a '" + contract.StringType + "' rule";
                    GameWindow.Instance.DrawCanvas();
                }
                else
                {
                    if (GameWindow.Instance.GameLogger.Text != "")
                    {
                        GameWindow.Instance.GameLogger.Text += "\n\n";
                    }
                    GameWindow.Instance.GameLogger.Text += "[" + DateTime.Now.ToLongTimeString().ToString() + "] " +
                                                           GameInfos.Instance.GetClientUserById(contract.id).Username +
                                                           " passed";
                }
                GameWindow.Instance.GameLoggerScroller.ScrollToBottom();
            }));
        }