Exemplo n.º 1
0
        private void HideTileStackWnds()
        {
            var wnds = new TileStackWnd[4] {
                Auc, Buc, Cuc, Duc
            };

            foreach (var wnd in wnds)
            {
                wnd.Visibility = Visibility.Hidden;
            }
        }
Exemplo n.º 2
0
        private void OnSinglePlayer_Button_Click(object sender, RoutedEventArgs e)
        {
            if (_players.Count == 4)
            {
                MessageBox.Show("already 4 players");
                return;
            }

            var wnds = new TileStackWnd[4] {
                Auc, Buc, Cuc, Duc
            };
            TileStackWnd freeWnd = null;

            foreach (var wnd in wnds)
            {
                var p = _players.Find((x) => x.MyWnd == wnd);
                if (p == null)
                {
                    freeWnd = wnd;
                    break;
                }
            }

            if (freeWnd == null)
            {
                MessageBox.Show("no free player-view to use");
                return;
            }

            var inputWnd = new InputWnd {
                Owner = this
            };
            var result = inputWnd.ShowDialog();

            if (result == false)
            {
                return;
            }

            var userId     = inputWnd.TextBoxUserId.Text;
            var roomNumber = inputWnd.TextBoxRoomId.Text;
            var player     = new Player(userId, userId, roomNumber, freeWnd, this);

            player.Connect();

            _players.Add(player);
        }
Exemplo n.º 3
0
        public static bool ShowDialog(MsgReadyHandTips readyHandTips, TileStackWnd owner)
        {
            var x = new RichiWnd();

            x.SetOwner(owner);
            x.SetReadyHandTips(readyHandTips);

            var result = x.ShowDialog();

            if (result == null || !result.Value)
            {
                // snip
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public Player(string name, string userId, string roomNumber, TileStackWnd myWnd, MainWindow mWnd)
        {
            Name   = name;
            MyWnd  = myWnd;
            UserId = userId;
            var url = $"{ProgramConfig.ServerUrl}/ws/monkey?userID={userId}&roomNumber={roomNumber}";

            if (url.StartsWith("https://"))
            {
                url = url.Replace("https", "wss");
            }
            else
            {
                url = url.Replace("http", "ws");
            }
            url = url.Replace("http", "ws");
            Ws  = new WebSocket(string.Format(url, userId, roomNumber));
            MyWnd.SetPlayer(this);
            MWnd = mWnd;
        }
Exemplo n.º 5
0
        private void BuildPlayers()
        {
            var names = new [] { "A", "B", "C", "D" };

            HideTileStackWnds();
            var wnds = new TileStackWnd[4] {
                Auc, Buc, Cuc, Duc
            };
            var userIds = new string[4] {
                "1", "2", "3", "4"
            };

            // TODO: 为了和unity配合测试,少启动一个
            for (var i = 0; i < CurrentDealCfg.PlayerCount - 1; ++i)
            {
                var player = new Player(names[i], userIds[i], "monkey-room", wnds[i], this);
                player.Connect();

                _players.Add(player);
            }
        }
Exemplo n.º 6
0
 private void SetOwner(TileStackWnd owner)
 {
     MyOwner    = owner;
     this.Owner = owner.MyOwner;
 }
Exemplo n.º 7
0
        public static bool ShowDialog(List <MsgMeldTile> meldList, out int tileDiscarded, TileStackWnd owner)
        {
            tileDiscarded = 0;
            var x = new ChowPongKongWnd();

            x.SetOwner(owner);
            x.SetMeldList(meldList);

            var result = x.ShowDialog();

            if (result == null || !result.Value)
            {
                // snip
                return(false);
            }

            tileDiscarded = x.SelectedTile;
            return(true);
        }
Exemplo n.º 8
0
        public static bool ShowDialog(List <MsgReadyHandTips> tiles2Discarded, out int tileDiscarded, out int readyHandFlags, int expectedReadyHandFlags, TileStackWnd owner)
        {
            tileDiscarded  = 0;
            readyHandFlags = 0;
            var x = new DiscardWnd();

            x.SetOwner(owner);
            x.SetReadyHandTips(tiles2Discarded);
            x.BtnExtra.Visibility   = Visibility.Hidden;
            x.BtnExtraXX.Visibility = Visibility.Hidden;
            if ((expectedReadyHandFlags & 1) != 0)
            {
                x.BtnExtra.Visibility = Visibility.Visible;
            }
            if ((expectedReadyHandFlags & 2) != 0)
            {
                x.BtnExtraXX.Visibility = Visibility.Visible;
            }
            var result = x.ShowDialog();

            if (result == null || !result.Value)
            {
                // snip
                return(false);
            }

            tileDiscarded  = x.SelectedTile;
            readyHandFlags = x.ReadyHandFlags;
            return(true);
        }