Beispiel #1
0
        public static void LoadMultiplayerData()
        {
            var path = Path.Combine(GameConfig.GetUserDataPath(), "PlanetExplorers/MultiplayerCharacter");

            if (!Directory.Exists(path))
            {
                return;
            }

            GameClientLobby.Self.myRoles        = new List <CustomData.RoleInfo>();
            GameClientLobby.Self.myRolesExisted = new List <CustomData.RoleInfo>();

            foreach (var file in Directory.GetFiles(path))
            {
                using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
                {
                    if (fs.Length > 0)
                    {
                        byte[] buff = new byte[fs.Length];
                        fs.Read(buff, 0, buff.Length);

                        var customData = new CustomCharactor.CustomData();
                        customData.Deserialize(buff);

                        var steamId = SteamFriendPrcMgr.Instance.GetMyInfo()._SteamID.m_SteamID;

                        var roleId = (steamId.GetHashCode() ^ customData.charactorName.GetHashCode()) % 13000000;

                        var role = new CustomData.RoleInfo()
                        {
                            appearData = customData.appearData.Serialize(),
                            nudeData   = customData.nudeAvatarData.Serialize(),
                            name       = customData.charactorName,
                            sex        = (byte)(int)customData.sex,
                            steamId    = steamId,
                            roleID     = roleId
                        };

                        GameClientLobby.Self.myRoles.Add(role);
                        GameClientLobby.Self.myRolesExisted.Add(role);
                    }
                }
            }
        }