コード例 #1
0
ファイル: UsersRequest.cs プロジェクト: OlegGelezcov/Casual
        private void ReadPoints(INetUser user, INetRoom room, System.Action <NetRoomPlayerRank> onSuccess, System.Action <INetError> onError)
        {
            WWWForm form = new WWWForm();

            form.AddField("op", "read_points");
            form.AddField("room_id", room.RoomId);
            form.AddField("room_mode", room.RoomMode.ToString());
            form.AddField("user_id", user.id);
            form.AddField("user_name", user.name);
            form.AddField("avatar_id", user.avatarId);
            form.AddField("level", user.level);

            MakeRequest(form, json => {
                try {
                    Dictionary <string, object> dict = Json.Deserialize(json) as Dictionary <string, object>;
                    if (dict == null)
                    {
                        onError?.Invoke(errorFactory.Create(NetErrorCode.json, string.Empty));
                        return;
                    }
                    NetRoomPlayerRank rank = new NetRoomPlayerRank(dict, resourceService);
                    onSuccess?.Invoke(rank);
                } catch (Exception exception) {
                    onError?.Invoke(errorFactory.Create(NetErrorCode.json, string.Empty));
                }
            }, onError);
        }
コード例 #2
0
ファイル: UsersRequest.cs プロジェクト: OlegGelezcov/Casual
        private Dictionary <string, NetRoomPlayerRank> ParseRoomRanks(string json)
        {
            Dictionary <string, NetRoomPlayerRank> ranks    = new Dictionary <string, NetRoomPlayerRank>();
            Dictionary <string, object>            rootDict = Json.Deserialize(json) as Dictionary <string, object>;

            if (rootDict == null)
            {
                throw new FormatException("json");
            }
            foreach (var kvp in rootDict)
            {
                Dictionary <string, object> rankDict = kvp.Value as Dictionary <string, object>;
                if (rankDict != null)
                {
                    NetRoomPlayerRank rank = new NetRoomPlayerRank(rankDict, resourceService);
                    ranks[kvp.Key] = rank;
                }
            }
            return(ranks);
        }
コード例 #3
0
ファイル: NetService.cs プロジェクト: OlegGelezcov/Casual
 public void OnRoomNetRankReaded(INetUser user, INetRoom room, NetRoomPlayerRank rank)
 {
     RavenhillEvents.OnRoomNetRankReaded(user, room, rank);
     Debug.Log($"Room Rank Readed: {rank.ToString()}");
     UpdateRanks(room, rank);
 }
コード例 #4
0
ファイル: NetService.cs プロジェクト: OlegGelezcov/Casual
 private void UpdateRanks(INetRoom room, NetRoomPlayerRank rank)
 {
     ranks[room.GetNetRoomId()] = rank;
 }