Exemplo n.º 1
0
        void ccCard_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            dragedCard = (sender as ccCard);
            //dragedCardLocation = dragedCard.Location;
            // dragedCardLocation = RelativeLocation(dragedCard);
            dragedCardParent = dragedCard.Parent;
            //if(toDrag)
            (sender as ccCard).DoDragDrop((sender as ccCard), DragDropEffects.Move);

            //b_strat=true
            //x_start=e.x staRTY=E.Y
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        public object Clone()
        {
            ccCard cloneCard = new ccCard(this.number, this.color, false);

            return(cloneCard);
        }