Exemplo n.º 1
0
        public void playerAcceptedTheChallenge()
        {
            string[] usernames = Message.Split(':');
            if (usernames.Length == 2)
            {
                User firstUser  = null;
                User secondUser = null;
                foreach (User user in Singleton.Singleton.Instance.ListOfUsersLogged)
                {
                    if (user.Username == usernames[0])
                    {
                        firstUser = user;
                    }
                    else if (user.Username == usernames[1])
                    {
                        secondUser = user;
                    }
                }

                if (firstUser != null && secondUser != null)
                {
                    firstUser.IsChallenged  = false;
                    firstUser.InGame        = true;
                    secondUser.IsChallenged = false;
                    secondUser.InGame       = true;

                    notifyUsersWithInGameStatus(firstUser);
                    notifyUsersWithInGameStatus(secondUser);

                    Room room = new Room(firstUser, secondUser, Singleton.Singleton.Instance.RoomIDHelper);
                    Singleton.Singleton.Instance.RoomIDHelper += 1;
                    MessageRoomPacket packet = new MessageRoomPacket(GameProtocol.LoadGameScene(), room.ID, firstUser.Username + ":" + secondUser.Username);
                    //MessagePacket packet = new MessagePacket(GameProtocol.LoadGameScene(), room.ID, )
                    //   + "|" + firstUser.Username + ":" + secondUser.Username);
                    Othello.Server.SendPacket(firstUser.Socket, packet.getData());
                    Othello.Server.SendPacket(secondUser.Socket, packet.getData());
                    Singleton.Singleton.Instance.ListOfRooms.Add(room);
                }
            }
        }