private void HideTileStackWnds() { var wnds = new TileStackWnd[4] { Auc, Buc, Cuc, Duc }; foreach (var wnd in wnds) { wnd.Visibility = Visibility.Collapsed; } }
public Player(string name, string userId, string tableNumber, TileStackWnd myWnd, MainWindow mWnd) { Name = name; MyWnd = myWnd; UserId = userId; var url = $"{ProgramConfig.ServerUrl}/ws/monkey?userID={userId}&tableNumber={tableNumber}"; url = url.Replace("http", "ws"); Ws = new WebSocket(string.Format(url, userId, tableNumber)); MyWnd.SetPlayer(this); MWnd = mWnd; }
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); }
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; }
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); } }
//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; //} //private void SetReadyHandTips(MsgReadyHandTips readyHandTips) //{ // var readyHandList = readyHandTips.readyHandList; // var i = 0; // for (var j = 0; j < readyHandList.Count - 1; j += 2) // { // var x = ButtonsSp1[i]; // x.Visibility = Visibility.Visible; // var tid = readyHandList[j]; // x.Content = new Image() { Source = MyOwner.ImagesSrc[tid] }; // var y = ButtonsSp0[i]; // y.Visibility = Visibility.Visible; // y.Content = readyHandList[j + 1]; // i++; // } //} private void SetOwner(TileStackWnd owner) { MyOwner = owner; this.Owner = owner.MyOwner; }
public static bool ShowDialog(List <int> tileDiscarded, TileStackWnd owner) { var tiles2Discarded = owner.TilesHandList; tileDiscarded.Clear(); var x = new DiscardWnd(); x.SetOwner(owner); x.BtnExtra.Visibility = Visibility.Hidden; x.BtnExtraXX.Visibility = Visibility.Hidden; x.SetReadyHandTips(tiles2Discarded); //x.prevCardHand = prevCardHand; //x.specialCardID = specialCardID; //if (prevCardHand != null) //{ //var currents = AgariIndex.FindGreatThanCardHand(prevCardHand, tiles2Discarded,specialCardID); //if (null == currents || currents.Count == 0) //{ // MessageBox.Show("oh shit, a huge bug"); // throw new System.Exception("huge bug"); //} //if (currents.Count > 1) //{ // x.BtnExtra.Visibility = Visibility.Visible; // x.BtnExtra.Content = "下一个提示"; //} //var current = currents[0]; //x.SelectedTiles.AddRange(current.cards); //foreach(var c in current.cards) //{ // x.HandTiles.Remove(c); //} //x.discardAbleTips = currents; //x.discardAbleTipsIndex = 0; // x.Hand2UI(); // x.Selected2UI(); //} //else { //var current = AgariIndex.SearchLongestDiscardCardHand(tiles2Discarded, specialCardID); //x.SelectedTiles.AddRange(current.cards); //foreach (var c in current.cards) //{ // x.HandTiles.Remove(c); //} x.Hand2UI(); x.Selected2UI(); } var result = x.ShowDialog(); if (result == null || !result.Value) { // snip return(false); } tileDiscarded.AddRange(x.SelectedTiles); return(true); }