Data.Player AddPlayer(int deskId, int uid) { Data.Player player = new Data.Player(); Data.PlayerInfo info = new Data.PlayerInfo(); info.id = uid; player.Info = info; player.DeskId = deskId; player.Index = player.DeskId - Data.Game.DeskId; if (player.Index < 0) { player.Index = 10 + player.Index; } player.PlayerUi = ui.GetChild("player" + (player.Index + 1)).asCom; player.PlayerUi.sortingOrder = 2000; if (!Data.Game.Players.ContainsKey(uid)) { Data.Game.Players.Add(uid, player); // 自己坐下,不用播放声音 if (uid != Data.User.Id) { roomAudio.clip = Resources.Load <AudioClip>("Game/audio/game_sit"); roomAudio.Play(); } } return(player); }
private void OnResUserInfo(NotificationArg arg) { var data = arg.GetValue <ResUserInfo>(); if (data.code != 0) { MsgBox.ShowErr(data.msg); return; } var p = Data.Game.GetPlayer(data.user.id); if (p == null) { Debug.LogWarning("当前房间列表不存在该用户:" + data.user.id); return; } Data.PlayerInfo info = new Data.PlayerInfo(); info.id = data.user.id; info.nick = data.user.nick; info.ip = data.user.ip; info.card = data.user.card; info.avatar = data.user.avatar; info.address = data.user.address; p.Info = info; p.PlayerUi.GetChild("name").text = data.user.nick; p.PlayerUi.GetChild("avatar").asLoader.url = Utils.Helper.GetReallyImagePath(data.user.avatar); p.PlayerUi.visible = true; }