public Form1() { InitializeComponent(); this.Text = "מסך פתיחה"; BL.ucPlayerBoard ucp = new BL.ucPlayerBoard(); //ucp.Show(); //ccCard c1 = new ccCard(1, eColor.Red); //ccCard c2 = new ccCard(8, eColor.Green); //int top = 0, left = 0; //ccCard c3 = new ccCard(5, eColor.Yellow); //c1.Top = top; //c1.Left = left; //c1.Width = 40; //c1.Height = 60; //left += c1.Width+1; //this.Controls.Add(c1); //c2.Top = top; //c2.Left = left; //c2.Width = 40; //c2.Height = 60; //left += c2.Width+1; //this.Controls.Add(c2); //c3.Top = top; //c3.Left = left; //c3.Width = 40; //c3.Height = 60; ////c3.Font.Size = 16; //left += c3.Width+1; //this.Controls.Add(ucp); }
public void play() { //עבור שחקן רגיל //שכפול לוח המשחק של השחקן cloneMainBoard.Clear(); clonePlayerBoard = (ucPlayerBoard)playersBoards[turn].Clone(); List <ccCard> temp = new List <ccCard> { }; for (int i = 0; i < mainBoard.Count; i++) { foreach (ccCard c in mainBoard[i]) { temp.Add(c); } cloneMainBoard.Add(temp.ToList()); temp.Clear(); } if (playersBoards[turn].computer == true) { // MessageBox.Show("Wait"); Play_Computer(); } }
private void LoadUcGameFirst(string folderPath)//### { eColor tmpec = new eColor(); eStatus tmpes = new eStatus(); string curName; List <ccCard> curCards = new List <ccCard> { }; //InitializNamesAttrib(); // מתוך הנחה שמדובר במקסימום 2 שחקנים אז התור הקודם הוא או 1 או 0 int beforeTurn = turn == 0 ? 1 : 0; //XDocument doc = XDocument.Load(path + "\\" + folderPath + "\\lastGame.xml");// לא בטוח טוב XDocument doc = XDocument.Load(folderPath + ".xml"); var prop = doc.Element("properties"); // שליפת התור הנוכחי turn = (int)prop.Attribute("turn"); // שליפת אבני הקופה box.Clear(); //ריקון אבני הקופה כדי לאתחלה לפי המשחק השמור foreach (XElement crd in prop.Element("box").Elements()) { int curNum = (int)crd.Attribute("number"); string curColor = (string)crd.Attribute("color"); string stt = (string)crd.Attribute("status"); tmpec = ToEColor(curColor); tmpes = ToEStatus(stt); box.Add(new ccCard((byte)curNum, tmpec, tmpes)); } // שליפת מאפייני השחקנים ואבניהם for (int i = 0; i < numOfPlayers; i++) { curName = (string)prop.Element("player" + (i + 1)).Attribute("name"); var curPlyr = prop.Element("player" + (i + 1)); //ריקון רשימת הקלפים של השחקן כדי לאתחלה לפי המשחק השמור playersBoards[i].listCards.Clear(); curCards.Clear(); for (int j = 0; j < (int)curPlyr.Attribute("cntCard"); j++) { int curNum = (int)curPlyr.Element("card" + (j + 1)).Attribute("number"); string curColor = (string)curPlyr.Element("card" + (j + 1)).Attribute("color"); tmpec = ToEColor(curColor); curCards.Add(new ccCard((byte)curNum, tmpec)); } playersBoards[i] = new ucPlayerBoard(curCards.ToList(), curName, false); } // שליפת לוח המשחק if (mainBoard.Count > 0) { mainBoard.Clear(); //ריקון לוח המשחק כדי לאתחלה לפי המשחק השמור } else { mainBoard = new List <List <ccCard> > { } }; foreach (XElement seria in prop.Element("mainBoard").Elements()) { List <ccCard> tmp = new List <ccCard> { }; int i = 0; foreach (XElement crd in seria.Elements()) { int curNum = (int)crd.Attribute("number"); string curColor = (string)crd.Attribute("color"); string stt = (string)crd.Attribute("status"); tmpec = ToEColor(curColor); tmpes = ToEStatus(stt); tmp.Add(new ccCard((byte)curNum, tmpec, tmpes)); } mainBoard.Add(tmp); i++; } //Show_Cards(); }
public ucGame(int _numOfPlayers, List <string> name, List <bool> kindPlayer, bool networkGame, string currUserName)//ekindCard kind,אמור לקבל גם: { InitializeComponent(); // Play_Computer(); numOfPlayers = _numOfPlayers; #region אתחול כרטיסים בקופסה ccCard tempCard; byte k, j; for (int i = 0; i < 4; i++) { for (j = 0; j < 2; j++)//פעמיים כל צבע { for (k = 1; k < 14; k++) { tempCard = new ccCard(k, (eColor)i); tempCard.Status = eStatus.Box; box.Add(tempCard); } } tempCard = new ccCard(14, (eColor)i); tempCard.Status = eStatus.Box; box.Add(tempCard);//joker } #endregion currentPlayerName = currUserName; #region אתחול כרטיסים בלוחות השחקנים playersBoards = new ucPlayerBoard[numOfPlayers]; int rand; for (int i = 0; i < numOfPlayers; i++) { List <ccCard> tempList = new List <ccCard>(); for (j = 0; j < 14; j++) { bool flRet; do { flRet = false; rand = r.Next(107); if (box[rand].Status != eStatus.Box) { flRet = true; } if (!netWorkGame && box[rand].Number == 14) { flRet = true; } } while (flRet); box[rand].Status = eStatus.Player; tempList.Add(box[rand]); } playersBoards[i] = new ucPlayerBoard(tempList, name[i], kindPlayer[i]); } #endregion //הגרלת תור do { turn = r.Next(numOfPlayers); } while (playersBoards[turn].computer); #region network2 //@@ netWorkGame = networkGame; if (netWorkGame) { int drive = Microsoft.VisualBasic.FileIO.FileSystem.Drives.Count; int i; for (i = 0; i < drive; i++) { if (Microsoft.VisualBasic.FileIO.FileSystem.Drives[i].DriveType == DriveType.Removable) { path = Microsoft.VisualBasic.FileIO.FileSystem.Drives[i].Name; break; } } if (File.Exists(path + name[0] + name[1] + ".xml")) { NewPlayerNetwork = false; // האם זה שחקן מצטרף או חדש- כרגע מצטרף PlayerClosed = false; try { // LoadUcGame(path + name[0] + name[1]); mainBoard.Clear(); LoadUcGameFirst(path + name[0] + name[1]); //עבור טעינת מיקומי הפאנלים formGame - זריקת ארוע ל if (eLoadChangesFinished != null) { eLoadChangesFinished(path + name[0] + name[1]); } File.Delete(path + name[0] + name[1] + ".xml"); //ChangeTurn(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else { NewPlayerNetwork = true; saveStatusNetwork(); } } fswNetork.Path = path; //********************************************* #endregion MessageBox.Show("." + playersBoards[turn].name + " random to play first ", "Rammi-start game", MessageBoxButtons.OK, MessageBoxIcon.Information);//@@ if (netWorkGame) { if (playersBoards[0].name == currentPlayerName) { Show_Cards(0); } else { Show_Cards(1); } } else { Show_Cards(turn); } play(); //check(); if (currentPlayerName != playersBoards[turn].name) { timer1.Start(); } }
public object Clone() { ucPlayerBoard clonePB = new ucPlayerBoard(this.listCards, this.name, this.computer); return(clonePB); }