Ejemplo n.º 1
0
 // Удаляем запись игры, если таковая имеется
 public void RemoveNote(EasyRoom note)
 {
     if (IsExists(note.Id) == true)
     {
         Notes.Remove(note);
     }
 }
Ejemplo n.º 2
0
        public void InitGameOverRoom(EasyRoom room)
        {
            Controls.Clear();
            ClientSize = new Size(800, 600);
            Text       = "Dice Game. " + room.Name + " - Game over";

            int k = 0;
            List <EasyPlayer> players = room.Players.OrderByDescending(u => u.Score).ToList();

            EList <Label> PlayersList = new EList <Label>();

            Label title = new Label {
                Parent = this, Location = new Point(10, 10), Width = 780, Text = "Игра окончена. Итоги: ", Font = new Font(Font.FontFamily, 14)
            };

            foreach (EasyPlayer player in players)
            {
                k++;
                PlayersList.Add(new Label {
                    Parent = this, Location = new Point(10, 60 + k * 40), Width = 780, Text = player.Name + ": " + player.Score, Font = new Font(Font.FontFamily, 14)
                });
            }

            Button BackToLobby = new Button()
            {
                Parent = this, Location = new Point(ClientRectangle.Width / 2 - 150, PlayersList.Last().Location.Y + 60), Size = new Size(300, 40), Text = "Вернуться в лобби", Font = new Font(Font.FontFamily, 14)
            };

            BackToLobby.Click += (object sender, EventArgs e) => {
                LocalServer.SendFrame(new Frame(room.Id, Name, MessageType.Disconnect, GameMessageType.Undefined));
                InLobby = true;
                RoomId  = -1;
                InitMain();
            };
        }
Ejemplo n.º 3
0
 // Добавляем запись игры, если таковой нет в лобби
 public void AddNote(EasyRoom note)
 {
     if (IsExists(note.Id) == false)
     {
         Notes.Add(note);
     }
 }
Ejemplo n.º 4
0
 private bool IsContaninsRoom(int id, out EasyRoom Room, EList <EasyRoom> notes)
 {
     foreach (EasyRoom room in notes)
     {
         if (room.Id == id)
         {
             Room = room;
             return(true);
         }
     }
     Room = null;
     return(false);
 }
Ejemplo n.º 5
0
        public void InitConnectToRoomForm(EasyRoom room)
        {
            Controls.Clear();
            ClientSize = new Size(800, 600);
            Text       = "Dice Game. Waiting room";

            Label RoomTitle = new Label()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 - 250, ClientSize.Height / 2 - 195), Size = new Size(500, 40), Font = new Font(Font.FontFamily, 24), Text = room.Name
            };
            Label PlayerNameInputLabel = new Label()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 - 250, ClientSize.Height / 2 + 55), Size = new Size(500, 40), Font = new Font(Font.FontFamily, 12), Text = "Введетие ваш ник"
            };
            TextBox PlayerNameInput = new TextBox()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 - 250, ClientSize.Height / 2 + 105), Size = new Size(500, 40), Font = new Font(Font.FontFamily, 12)
            };

            Button Done = new Button()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 - 250, ClientSize.Height / 2 + 155), Size = new Size(200, 40), Font = new Font(Font.FontFamily, 12), Text = "Готово"
            };
            Button Back = new Button()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 + 50, ClientSize.Height / 2 + 155), Size = new Size(200, 40), Font = new Font(Font.FontFamily, 12), Text = "Вернуться в лобби"
            };

            Done.Click += (object sender, EventArgs e) => {
                Name = PlayerNameInput.Text;
                LocalServer.SendFrame(new Frame(room.Id, Name, MessageType.Exchange, GameMessageType.Connect));
                RoomId  = room.Id;
                InLobby = false;
            };

            Back.Click += (object sender, EventArgs e) => {
                InLobby = true;
                RoomId  = -1;
                InitMain();
            };
        }
Ejemplo n.º 6
0
        public void InitGameRoom(EasyRoom room)
        {
            Controls.Clear();
            ClientSize = new Size(800, 600);
            Text       = "Dice Game. " + room.Name + " - Game";

            GameView gameView = new GameView(room, Name, Watcher)
            {
                Parent = this, Location = new Point(10, 10), Height = 400
            };

            gameView.ClickRoll += () =>
            {
                LocalServer.SendFrame(new Frame(room.Id, Name, MessageType.Exchange, GameMessageType.Send));
            };

            gameView.ClickStop += () =>
            {
                LocalServer.SendFrame(new Frame(room.Id, Name, MessageType.Exchange, GameMessageType.Wait));
            };
        }
Ejemplo n.º 7
0
        public void InitWaitingRoom(EasyRoom room)
        {
            Controls.Clear();
            ClientSize = new Size(800, 600);
            Text       = "Dice Game. Waiting room";

            Label RoomTitle = new Label()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 - 250, ClientSize.Height / 2 - 195), Size = new Size(500, 40), Font = new Font(Font.FontFamily, 24), Text = room.Name
            };

            Label PlyersCount = new Label()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 - 250, ClientSize.Height / 2 - 125), Size = new Size(500, 40), Font = new Font(Font.FontFamily, 12), Text = "Игроки: " + room.Players.Count + "/2"
            };
            Label PlayerName = new Label()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 - 250, ClientSize.Height / 2 - 85), Size = new Size(500, 40), Font = new Font(Font.FontFamily, 12), Text = "Ваш ник: " + Name
            };
            Label GameStatus = new Label()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 - 250, ClientSize.Height / 2 - 45), Size = new Size(500, 40), Font = new Font(Font.FontFamily, 12), Text = "Ожидаем подключения игроков"
            };

            Button Back = new Button()
            {
                Parent = this, Location = new Point(ClientSize.Width / 2 - 250, ClientSize.Height / 2 + 155), Size = new Size(500, 40), Font = new Font(Font.FontFamily, 12), Text = "Вернуться в лобби"
            };

            Back.Click += (object sender, EventArgs e) => {
                LocalServer.SendFrame(new Frame(room.Id, Name, MessageType.Disconnect, GameMessageType.Undefined));
                InLobby = true;
                RoomId  = -1;
                InitMain();
            };
        }
Ejemplo n.º 8
0
        public GameView(EasyRoom room, string localPlayer, bool IsWatcher) : base()
        {
            Width      = 780;
            AutoScroll = true;
            Notes      = room.Players;
            lam s = () => { return(false); };

            Playerrows = new EList <PlayerNoteView>();

            for (int i = 0; i < room.Players.Count; i++)
            {
                s = () => { if (room.Players[i].Name == room.ActivePlayer)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            } };
                PlayerNoteView pl;
                if (i > 0)
                {
                    pl = new PlayerNoteView(room.Players[i], s())
                    {
                        Parent = this, Location = new Point(0, Playerrows.Last().Location.Y + 60)
                    };
                }
                else
                {
                    pl = new PlayerNoteView(room.Players[i], s())
                    {
                        Parent = this, Location = new Point(0, 0)
                    };
                }

                Playerrows.Add(pl);
            }

            /*foreach (EasyPlayer player in Notes)
             * {
             *  s = ()=> { if (player.Name == room.ActivePlayer) return true; else return false; };
             *  PlayerNoteView pl;
             *  if (player.Id > 1)
             *  {
             *      pl = new PlayerNoteView(player, s()) { Parent = this, Location = new Point(0, Playerrows.Last().Location.Y + 60) };
             *  }
             *  else
             *  {
             *      pl = new PlayerNoteView(player, s()) { Parent = this, Location = new Point(0, 0) };
             *  }
             *
             *  Playerrows.Add(pl);
             * }*/

            s = () => { if (room.ActivePlayer == localPlayer)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        } };

            RollButton = new Button()
            {
                Parent = this, Location = new Point(10, Playerrows.Last().Location.Y + 80), Size = new Size(200, 40), Text = "Roll", Enabled = s(), Visible = !IsWatcher
            };
            StopButton = new Button()
            {
                Parent = this, Location = new Point(220, Playerrows.Last().Location.Y + 80), Size = new Size(200, 40), Text = "Штап", Enabled = s(), Visible = !IsWatcher
            };

            RollButton.Click += (object sender, EventArgs e) => {
                ClickRoll?.Invoke();
            };

            StopButton.Click += (object sender, EventArgs e) => {
                ClickStop?.Invoke();
            };
        }
Ejemplo n.º 9
0
 // обновляем данные записи (при получении фрейма с новым статусом сервера)
 public void SetSource(EasyRoom note)
 {
     Source = note;
     SetAll();
 }
Ejemplo n.º 10
0
 public GameNoteView(EasyRoom note) : base()
 {
     Source = note;
     SetAll();
 }