How to Find Rooms Based on Skill Level¶
To be able to search for rooms using skill level it is necessary to store some average level of all members of the room. This can be done using the SetRoom() method.
StrixNetwork.instance.SetRoom(
1, // Room Id
new RoomProperties { key1 = 25 }, // Average skill level
args => {
Debug.Log("SetRoom succeeded");
},
args => {
Debug.Log("SetRoom failed. error = " + args.cause);
}
);
To search for rooms by skill level one may perform a range search using GreaterThanEquals() and LessThanEquals().
StrixNetwork.instance.SearchJoinableRoom(
new And(
new List<ICondition> {
new GreaterThanEquals(new Field("key1"), new Value((double)24)),
new LessThanEquals(new Field("key1"), new Value((double)28))
}
),
null, 10, 0,
args => {
foreach (var roomInfo in args.roomInfoCollection) {
logger.Info("roomId " + roomInfo.roomId + " name " + roomInfo.name);
}
},
args => {
logger.Info("SearchJoinableRoom failed. error = " + args.cause);
}
);
And the following example using ConditionBuilder.
StrixNetwork.instance.SearchJoinableRoom(
ConditionBuilder.Builder()
.Field("key1").GreaterThanEquals((double)24)
.And()
.Field("key1").LessThanEquals((double)28)
.Build(),
null, 10, 0,
args => {
foreach (var roomInfo in args.roomInfoCollection) {
logger.Info("roomId " + roomInfo.roomId + " name " + roomInfo.name);
}
},
args => {
logger.Info("SearchJoinableRoom failed. error = " + args.cause);
}
);