public void Join() { Play.UserID = "SiYuan"; Play.Connect("0.0.1"); Assert.That(Done, Is.True.After(2000000)); }
public void OpenTest() { Play.UserID = "xxx"; Play.Connect("0.0.1"); Assert.That(Done, Is.True.After(2000000)); }
public void ModifyPlayerProperties() { Play.UserID = RandomClientId; Play.Connect("0.0.1"); Assert.That(true, Is.True.After(2000000)); }
public void AuthenticateFromGameServer() { Play.UserID = "xxx"; Play.Connect("0.0.1", Play.ServerType.Game); Assert.That(Done, Is.True.After(2000000)); }
public void SetPlayerProperties() { Play.UserID = "WuJun"; Play.Connect("0.0.1"); Assert.That(Done, Is.True.After(2000000)); }
public void RoomListFetch() { Play.UserID = RandomClientId; Play.Connect("0.0.1"); Assert.That(true, Is.True.After(2000000)); }
public void CreateWithRandomName() { Play.UserID = "WuJun"; Play.Connect("0.0.1"); Assert.That(Done, Is.True.After(2000000)); }
public void RPCToMasterClient() { Play.UserID = "WuJun"; Play.Connect("0.0.1"); Assert.That(Done, Is.True.After(2000000)); }
public void Rejoin() { Play.UserID = "WuJun"; Play.Connect("0.0.1"); Assert.That(Done, Is.True.After(2000000)); }
public void FindFriends() { Play.UserID = RandomClientId; Play.Connect("0.0.1"); Assert.That(true, Is.True.After(2000000)); }
public void CreateRoomWithCustomProperties() { Play.UserID = RandomClientId; Play.Connect("0.0.1"); Assert.That(true, Is.True.After(2000000)); }
public void JoinRandomRoomWithLobbyMatchKeys() { Play.UserID = RandomClientId; Play.Connect("0.0.1"); Assert.That(true, Is.True.After(2000000)); }
public void Create() { Play.UserID = "xxx"; Play.Connect("0.0.1"); Assert.That(Done, Is.True.After(2000000)); flag++; }
void start() { // 打开调试日志 Play.ToggleLog(true); // 设置 UserID Play.UserID = "hjiang"; // 声明游戏版本,不同游戏版本的玩家会被分配在不同的隔离区域中 Play.Connect("0.0.1"); }
public TMClient ConnnectLobby(string lobbyWebSocketUrl) { Play.ToggleLog(true); Play.Logger = Console.WriteLine; Play.UserID = NickName; Play.SetRouteServer(lobbyWebSocketUrl); Play.Connect("0.0.1"); return(this); }
void Start() { Play.ToggleLog(); // 随机生成一个用户 ID string userId = Random.Range(0, int.MaxValue).ToString(); Debug.Log("userId: " + userId); // 设置用户 ID,请保证游戏内唯一 Play.UserID = userId; Play.Connect("1.0.0"); }
public void onConnectBtnClicked() { string userId = userIdInputField.text; if (string.IsNullOrEmpty(userId)) { Debug.Log("user id is null"); return; } GlobalUI.Instantce.ShowLoading(); Play.UserID = userId; Play.Connect("0.0.1"); }
// Use this for initialization void Start() { // 设置 SDK 日志委托 LeanCloud.Play.Logger.LogDelegate = (level, log) => { if (level == LogLevel.Debug) { Debug.LogFormat("[DEBUG] {0}", log); } else if (level == LogLevel.Warn) { Debug.LogFormat("[WARN] {0}", log); } else if (level == LogLevel.Error) { Debug.LogFormat("[ERROR] {0}", log); } }; // App Id var APP_ID = "FQr8l8LLvdxIwhMHN77sNluX-9Nh9j0Va"; // App Key var APP_KEY = "MJSm46Uu6LjF5eNmqfbuUmt6"; // App 节点地区 var APP_REGION = Region.EastChina; // 初始化 play.Init(APP_ID, APP_KEY, APP_REGION); // 这里使用随机数作为 userId var random = new System.Random(); var randId = string.Format("{0}", random.Next(10000000)); play.UserId = randId; this.idText.text = string.Format("Id: {0}", randId); play.On(LeanCloud.Play.Event.CONNECTED, (evtData) => { Debug.Log("connected"); // 根据当前时间(时,分)生成房间名称 var now = System.DateTime.Now; var roomName = string.Format("{0}_{1}", now.Hour, now.Minute); play.JoinOrCreateRoom(roomName); }); play.On(LeanCloud.Play.Event.ROOM_JOINED, (evtData) => { Debug.Log("joined room"); }); // 注册新玩家加入房间事件 play.On(LeanCloud.Play.Event.PLAYER_ROOM_JOINED, (evtData) => { var newPlayer = evtData["newPlayer"] as Player; Debug.LogFormat("new player: {0}", newPlayer.UserId); if (play.Player.IsMaster) { // 获取房间内玩家列表 var playerList = play.Room.PlayerList; for (int i = 0; i < playerList.Count; i++) { var player = playerList[i]; var props = new Dictionary <string, object>(); // 判断如果是房主,则设置 10 分,否则设置 5 分 if (player.IsMaster) { props.Add("point", 10); } else { props.Add("point", 5); } player.SetCustomProperties(props); } var data = new Dictionary <string, object>(); data.Add("winnerId", play.Room.Master.ActorId); var opts = new SendEventOptions(); opts.ReceiverGroup = ReceiverGroup.All; play.SendEvent("win", data, opts); } }); // 注册「玩家属性变更」事件 play.On(LeanCloud.Play.Event.PLAYER_CUSTOM_PROPERTIES_CHANGED, (evtData) => { var player = evtData["player"] as Player; // 判断如果玩家是自己,则做 UI 显示 if (player.IsLocal) { // 得到玩家的分数 long point = (long)player.CustomProperties["point"]; Debug.LogFormat("{0} : {1}", player.UserId, point); this.scoreText.text = string.Format("Score: {0}", point); } }); // 注册自定义事件 play.On(LeanCloud.Play.Event.CUSTOM_EVENT, (evtData) => { // 得到事件参数 var eventId = evtData["eventId"] as string; if (eventId == "win") { var eventData = evtData["eventData"] as Dictionary <string, object>; // 得到胜利者 Id int winnerId = (int)(long)eventData["winnerId"]; // 如果胜利者是自己,则显示胜利 UI;否则显示失败 UI if (play.Player.ActorId == winnerId) { Debug.Log("win"); this.resultText.text = "Win"; } else { Debug.Log("lose"); this.resultText.text = "Lose"; } play.Disconnect(); } }); // 连接服务器 play.Connect(); }