示例#1
0
        public void RemoveTag(TagInfo tag)
        {
            if (!_tags.ContainsKey(tag.TagID))
            {
                throw new Exception("Can't remove tag that doesn't exist");
            }

            string tagPath = GetTagPath(tag);

            File.Delete(tagPath);

            _tags.Remove(tag.TagID);

            string[] keys = _users.Keys.ToArray();
            for (int i = 0; i < keys.Length; i++)
            {
                PlayerTagsInfo user = _users[keys[i]];
                if (user.TagIds.Contains(tag.TagID))
                {
                    string[]      tags   = user.TagIds;
                    List <string> output = new List <string>();
                    for (int j = 0; j < tags.Length; j++)
                    {
                        if (tags[j] != tag.TagID)
                        {
                            output.Add(tags[j]);
                        }
                    }

                    user.TagIds = output.ToArray();

                    SaveUserTags(keys[i], user);
                }
            }
        }
示例#2
0
        public void SaveUserTags(string playfabId, PlayerTagsInfo playerTags)
        {
            string userPath = GetUserTagSavePath(playfabId);

            File.WriteAllBytes(userPath, playerTags.GetData());

            _users[playfabId] = playerTags;
        }
示例#3
0
        public override void OnStartup()
        {
            Directory.CreateDirectory(TagsPath);
            Directory.CreateDirectory(UsersPath);

            foreach (string tagPath in Directory.GetFiles(TagsPath))
            {
                TagInfo tag = new TagInfo(File.ReadAllBytes(tagPath));
                _tags.Add(tag.TagID, tag);
            }

            foreach (string user in Directory.GetFiles(UsersPath))
            {
                string         playfabID = Path.GetFileNameWithoutExtension(user);
                PlayerTagsInfo playerTag = new PlayerTagsInfo(File.ReadAllBytes(user));
                _users.Add(playfabID, playerTag);
            }
        }