Ejemplo n.º 1
0
        public FriendCollection(Dictionary <string, object> dict, IResourceService resourceService)
        {
            id      = dict.GetStringOrDefault("user_id");
            friends = new List <INetUser>();

            if (dict.ContainsKey("friends"))
            {
                Dictionary <string, object> dictFriends = dict["friends"] as Dictionary <string, object>;
                if (dictFriends != null)
                {
                    foreach (var kvp in dictFriends)
                    {
                        Dictionary <string, object> friend = kvp.Value as Dictionary <string, object>;
                        if (friend != null)
                        {
                            NetPlayer netPlayer = new NetPlayer(friend, true, resourceService);
                            if (!netPlayer.IsNull)
                            {
                                friends.Add(netPlayer);
                            }
                        }
                    }
                }
            }

            this.friends.Sort((f1, f2) => { return(f1.id.CompareTo(f2.id)); });
        }
Ejemplo n.º 2
0
        private void WriteUser(INetUser user, string wishlist, System.Action <INetUser> onSuccess, System.Action <INetError> onError)
        {
            WWWForm form = new WWWForm();

            form.AddField("op", "write_user");
            form.AddField("user_id", user.id);
            form.AddField("user_name", user.name);
            form.AddField("avatar_id", user.avatarId);
            form.AddField("level", user.level);
            form.AddField("wishlist", wishlist);

            MakeRequest(form, (json) => {
                try {
                    Dictionary <string, object> userObj = Json.Deserialize(json) as Dictionary <string, object>;
                    if (userObj == null)
                    {
                        onError?.Invoke(errorFactory.Create(NetErrorCode.json, string.Empty));
                        return;
                    }
                    NetPlayer player = new NetPlayer(userObj, true, resourceService);
                    onSuccess?.Invoke(player);
                } catch (Exception exception) {
                    onError?.Invoke(errorFactory.Create(NetErrorCode.json, string.Empty));
                }
            }, onError);
        }
Ejemplo n.º 3
0
 public void CopyFrom(NetPlayer player)
 {
     this.id       = player.id;
     this.name     = player.name;
     this.avatarId = player.avatarId;
     this.level    = player.level;
     this.isValid  = player.isValid;
 }
Ejemplo n.º 4
0
 public RankedRoomNetPlayer(Dictionary <string, object> dict, IResourceService resourceService)
 {
     this.player     = new NetPlayer(dict, true, resourceService);
     this.roomPoints = new NetRoomPoints(dict);
     if (dict.ContainsKey("rank"))
     {
         if (!int.TryParse(dict["rank"].ToString(), out rank))
         {
             rank = int.MaxValue;
         }
     }
 }
Ejemplo n.º 5
0
        public bool Load(string saveStr)
        {
            UXMLDocument document = UXMLDocument.FromXml(saveStr);
            UXMLElement  root     = document.Element(saveId);

            if (root != null)
            {
                UXMLElement localPlayerELement = root.Element("local_player");
                if (localPlayerELement != null)
                {
                    localPlayer = new NetPlayer();
                    localPlayer.Load(localPlayerELement);
                }
                else
                {
                    localPlayer = new NetPlayer();
                    localPlayer.InitSave();
                }
            }
            isLoaded = true;
            return(isLoaded);
        }
Ejemplo n.º 6
0
        public NetGift(Dictionary <string, object> dict, IResourceService resource)
        {
            _id = dict.GetStringOrDefault("gift_id");

            string senderId     = dict.GetStringOrDefault("sender_id");
            string senderName   = dict.GetStringOrDefault("sender_name");
            string senderAvatar = dict.GetStringOrDefault("sender_avatar_id");
            int    senderLevel  = dict.GetIntOrDefault("sender_level");

            string receiverId     = dict.GetStringOrDefault("receiver_id");
            string receiverName   = dict.GetStringOrDefault("receiver_name");
            string receiverAvatar = dict.GetStringOrDefault("receiver_avatar_id");
            int    receiverLevel  = dict.GetIntOrDefault("receiver_level");

            InventoryItemType itemType = dict.GetItemType("item_type");
            string            itemId   = dict.GetStringOrDefault("item_id");

            ISender           sender   = new NetPlayer(senderId, senderName, senderAvatar, senderLevel, true);
            ISender           receiver = new NetPlayer(receiverId, receiverName, receiverAvatar, receiverLevel, true);
            InventoryItemData itemData = resource.GetInventoryItemData(itemType, itemId);

            gift = new Gift(sender, receiver, itemData);
        }
Ejemplo n.º 7
0
 public RankedRoomNetPlayer(NetPlayer player, INetRoomPoints roomPoints)
 {
     this.player     = player;
     this.rank       = int.MaxValue;
     this.roomPoints = roomPoints;
 }