示例#1
0
        public PlayerModel oldplayer(string ConnectionId, int id, UsersData User)
        {
            PlayerModel newPlayer = new PlayerModel();

            newPlayer.ConnectionId    = ConnectionId; //ид соединения
            newPlayer.Id              = id;           // ИД
            newPlayer.Name            = User.Name;
            newPlayer.cri             = new int[6];   //кол-во типов кри
            newPlayer.skillsInfoArray = JsonConvert.DeserializeObject <int[][]>(User.SkillData);
            newPlayer.x     = 325;
            newPlayer.y     = 310;
            newPlayer.angle = 'u';
            return(newPlayer);
        }
示例#2
0
 //====================================================================================================
 //Ответ на попытку регистрации
 private void REG_Send_Message()
 {
     this.response_buf = new byte[Client.command_length];
     if (UsersData.IsUserExist(ref user_inf, ref Server.UserList))
     {
         this.response_buf[0] = Convert.ToByte(ServerAnswers.NOPE); //Такой пользователь существует
     }
     else
     {
         user_inf.key = RandomKey.GetKey(8);
         Server.UserList.Add(user_inf);                           //Пополняем список новым пользователем
         UsersData.WriteUsersInf(Server.users_inf_way, Server.UserList);
         this.folder = Encoding.Default.GetString(user_inf.login_hash) + "//";
         Directory.CreateDirectory(this.folder);
         this.response_buf[0] = Convert.ToByte(ServerAnswers.OK); //Регистрания пройдена успешно
     }
     networkStream.Write(response_buf, 0, response_buf.Length);
 }
示例#3
0
        public Task Connect(int id)        // дисконнект конкретного игрока с задержкой 7 секунд
        {
            //BD.UsersVK
            // int id = 0;
            id = Broadcaster.Instance.players.Count();
            var User = (from u in BD.UsersData where u.Id == id select u).ToArray();

            if (User.Length > 0)            // Тут еще проверочку на пасс
            {
                if (LeavePlayers.Any(p => p.Id == id))
                {
                    LeavePlayers.First(p => p.Id == id).ConnectionId = Context.ConnectionId;
                    _broadcaster.players.Add(LeavePlayers.First(p => p.Id == id));
                    LeavePlayers.Remove(LeavePlayers.First(p => p.Id == id));
                }
                else if (_broadcaster.players.Any(p => p.Id == id))
                {
                    _broadcaster.players.First(p => p.Id == id).ConnectionId = Context.ConnectionId;
                }
                else
                {
                    PlayerModel newPlayer = oldplayer(Context.ConnectionId, id, User[0]);
                    SendPosition(newPlayer.x, newPlayer.y);
                    _broadcaster.players.Add(newPlayer);
                }
            }
            else
            {
                PlayerModel newPlayer = newplayer(Context.ConnectionId, "dEND", BD.UsersData.Count());
                #region Добавление юзера в бд
                UsersData RegModel = new UsersData();
                RegModel.Id        = BD.UsersData.Count();
                RegModel.Name      = newPlayer.Name;
                RegModel.Money     = 10000;
                RegModel.Credits   = 2;
                RegModel.SkillData = JsonConvert.SerializeObject(newPlayer.skillsInfoArray);
                BD.UsersData.InsertOnSubmit(RegModel);
                BD.SubmitChanges();
                #endregion
                SendPosition(newPlayer.x, newPlayer.y);             //кидаем его на эту точку
                _broadcaster.players.Add(newPlayer);                //добавляем в список
            }
            return(base.OnConnected());
        }
示例#4
0
 partial void DeleteUsersData(UsersData instance);
示例#5
0
 partial void UpdateUsersData(UsersData instance);
示例#6
0
 partial void InsertUsersData(UsersData instance);
示例#7
0
 public Server(int port)
 {
     UsersData.ReadUsersInf(ref users_inf_way, ref UserList);
     ServerListener = new TcpListener(IPAddress.Any, port);
     ServerListener.Start();
 }