コード例 #1
0
ファイル: LobbyServiceImpl.cs プロジェクト: kradchen/sgs
        public Room CreateRoom(RoomSettings settings, string password = null)
        {
            if (currentAccount == null) return null;
            if (currentAccount.CurrentRoom != null)
            {
                return null;
            }

            lock (rooms)
            {
                while (rooms.ContainsKey(newRoomId))
                {
                    newRoomId++;
                }
                Room room = new Room();
                int maxSeats = settings.GameType == GameType.Pk1v1 ? 2 : 8;
                for (int i = 0; i < maxSeats; i++)
                {
                    room.Seats.Add(new Seat() { State = SeatState.Empty });
                }
                room.Seats[0].Account = currentAccount.Account;
                room.Seats[0].State = SeatState.Host;
                room.Id = newRoomId;
                room.OwnerId = 0;
                room.Settings = settings;
                var srvRoom = new ServerRoom() { Room = room };
                rooms.Add(newRoomId, srvRoom);
                currentAccount.CurrentRoom = srvRoom;
                Trace.TraceInformation("created room {0}", newRoomId);
                return room;
            }
        }
コード例 #2
0
ファイル: LobbyServiceImpl.cs プロジェクト: kingling/sgs
        public Room CreateRoom(LoginToken token, RoomSettings settings, string password = null)
        {
            if (VerifyClient(token))
            {
                if (loggedInGuidToRoom.ContainsKey(token.TokenString))
                {
                    return null;
                }

                while (rooms.ContainsKey(newRoomId))
                {
                    newRoomId++;
                }
                Room room = new Room();
                for (int i = 0; i < 8; i++)
                {
                    room.Seats.Add(new Seat() { State = SeatState.Empty });
                }
                room.Seats[0].Account = loggedInGuidToAccount[token.TokenString];
                room.Seats[0].State = SeatState.Host;
                room.Id = newRoomId;
                room.OwnerId = 0;
                room.Settings = settings;
                rooms.Add(newRoomId, room);
                if (loggedInGuidToRoom.ContainsKey(token.TokenString))
                {
                    loggedInGuidToRoom.Remove(token.TokenString);
                }
                loggedInGuidToRoom.Add(token.TokenString, room);
                Console.WriteLine("created room {0}", newRoomId);
                return room;
            }
            Console.WriteLine("Invalid createroom call");
            return null;
        }
コード例 #3
0
ファイル: LobbyView.xaml.cs プロジェクト: shonwang/sgs
 private void btnCreateRoomConfirm_Click(object sender, RoutedEventArgs e)
 {
     RoomSettings settings = new RoomSettings();
     settings.IsDualHeroMode = cbDualHero.IsChecked == true;
     settings.NumberOfDefectors = cbDualDefector.IsChecked == true ? 2 : 1;
     int[] options1 = { 3, 4, 5, 6 };
     settings.NumHeroPicks = options1[cbHeroPickCount.SelectedIndex];
     int[] options2 = { 10, 15, 20, 30 };
     settings.TimeOutSeconds = options2[cbTimeOutSeconds.SelectedIndex];
     LobbyModel.CreateRoom(settings);
     createRoomWindow.Close();
 }
コード例 #4
0
 /// <summary>
 /// Creates and enters a new room.
 /// </summary>
 public void CreateRoom(RoomSettings settings)
 {
     var room = _connection.CreateRoom(settings);
     if (room != null)
     {
         CurrentRoom = new RoomViewModel() { Room = room };
         UpdateRooms();
         Trace.Assert(CurrentSeat != null, "Successfully created a room, but do not find myself in the room");
     }
 }
コード例 #5
0
ファイル: LobbyView.xaml.cs プロジェクト: kradchen/sgs
        private void btnCreateRoomConfirm_Click(object sender, RoutedEventArgs e)
        {
            RoomSettings settings = new RoomSettings();
            settings.IsDualHeroMode = cbDualHero.IsChecked == true;
            settings.NumberOfDefectors = cbDualDefector.IsChecked == true ? 2 : 1;
            int[] options1 = { 3, 4, 5, 6 };
            settings.NumHeroPicks = options1[cbHeroPickCount.SelectedIndex];
            int[] options2 = { 10, 15, 20, 30 };
            settings.TimeOutSeconds = options2[cbTimeOutSeconds.SelectedIndex];
            settings.EnabledPackages = EnabledPackages.None;
            if (cbGameType.SelectedIndex == 0) settings.GameType = GameType.RoleGame;
            else if (cbGameType.SelectedIndex == 1) settings.GameType = GameType.Pk1v1;
            else return;
            if (cbWind.IsChecked == true) settings.EnabledPackages |= EnabledPackages.Wind;
            if (cbFire.IsChecked == true) settings.EnabledPackages |= EnabledPackages.Fire;
            if (cbWoods.IsChecked == true) settings.EnabledPackages |= EnabledPackages.Woods;
            if (cbHills.IsChecked == true) settings.EnabledPackages |= EnabledPackages.Hills;
            if (cbGods.IsChecked == true) settings.EnabledPackages |= EnabledPackages.Gods;
            if (cbSP.IsChecked == true) settings.EnabledPackages |= EnabledPackages.SP;
            if (cbOverKnightFame.IsChecked == true) settings.EnabledPackages |= EnabledPackages.OverKnightFame;

            LobbyModel.CreateRoom(settings);
            createRoomWindow.Close();
        }