Exemplo n.º 1
0
        private void WritePoints(UserRoomPoints userRoomPoints, System.Action <UserRoomPoints> onSuccess, System.Action <INetError> onError)
        {
            WWWForm form = new WWWForm();

            form.AddField("op", "write_points");
            form.AddField("room_id", userRoomPoints.RoomPoints.RoomId);
            form.AddField("room_mode", userRoomPoints.RoomPoints.RoomMode.ToString());
            form.AddField("user_id", userRoomPoints.User.id);
            form.AddField("user_name", userRoomPoints.User.name);
            form.AddField("avatar_id", userRoomPoints.User.avatarId);
            form.AddField("level", userRoomPoints.User.level);
            form.AddField("points", userRoomPoints.RoomPoints.Points);

            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;
                    }
                    UserRoomPoints returnedPoints = new UserRoomPoints(dict, resourceService);
                    onSuccess?.Invoke(returnedPoints);
                } catch (Exception exception) {
                    onError?.Invoke(errorFactory.Create(NetErrorCode.json, string.Empty));
                }
            }, onError);
        }
Exemplo n.º 2
0
 public void WritePoints(UserRoomPoints userRoomPoints)
 {
     WritePoints(userRoomPoints, (returnedPoints) => {
         netService.OnUserRoomPointsWritten(returnedPoints);
     }, (error) => {
         netService.OnNetErrorOccured("write_points", error);
     });
 }
Exemplo n.º 3
0
 public void OnUserRoomPointsWritten(UserRoomPoints roomPoints)
 {
     RavenhillEvents.OnUserRoomPointsWritten(roomPoints);
     Debug.Log($"User Room Points Written: {roomPoints.ToString()}");
 }