internal void OnMessageReceived(NearbyPlayer sender, byte[] data) { Debug.Log("New Messaggeee!!!! "); Debug.Log(data.ToString()); UpdateGameStateFromData(data); }
internal void OnRoomFound(NearbyRoom room, bool available) { if (available) { myEndpointId = UnityEngine.Random.Range(1000, 10000).ToString(); myName = UnityEngine.Random.Range(1000, 10000).ToString(); NearbyPlayer nearbyPlayer = new NearbyPlayer(SystemInfo.deviceUniqueIdentifier, myEndpointId, myName); room.JoinRoom(nearbyPlayer, Encoding.ASCII.GetBytes("asdasd"), OnRoomJoined); // GameObject obj = Instantiate() as GameObject; } }
public void Init(NearbyPlayer info) { if (info == null || false == info.IsValid()) { return; } m_nearbyPlayer = info; SetPro(info.Profession); SetHeadPic(info.Profession); SetName(info.Name); SetLevel(info.Level); SetCombatNum(info.CombatNum); SetVipLevel(info.VipLevel); SetGuildName(info.GuildName); }
public void onCreateRoom() { myEndpointId = UnityEngine.Random.Range(1000, 10000).ToString(); myName = UnityEngine.Random.Range(1000, 10000).ToString(); NearbyPlayer nearbyPlayer = new NearbyPlayer(SystemInfo.deviceUniqueIdentifier, myEndpointId, myName); globalNearbyPlayer = nearbyPlayer; NearbyRoom.StopAll(); PlayGamesPlatform.InitializeNearby((client) => { Debug.Log("Nearby connections initialized"); }); NearbyRoom nearbyRoom = new NearbyRoom("Most Popular Room!!"); nearbyRoom.AutoJoin = true; nearbyRoom.AlwaysOpen = true; isClient = false; nearbyRoom.OpenRoom(); //List<string> appIdentifiers = new List<string>(); //appIdentifiers.Add(PlayGamesPlatform.Nearby.GetAppBundleId()); //PlayGamesPlatform.Nearby.StartAdvertising( // "Awesome Game Host", // User-friendly name // appIdentifiers, // App bundle Id for this game // TimeSpan.FromSeconds(0),// 0 = advertise forever // (AdvertisingResult result) => // { // Debug.Log("OnAdvertisingResult: " + result); // }, // (ConnectionRequest request) => // { // Debug.Log("Received connection request: " + // request.RemoteEndpoint.ServiceId + " " + // request.RemoteEndpoint.EndpointId + " " + // request.RemoteEndpoint.Name); // } // ); }
void ShowNearByPlayerContent(GC_NEAR_PLAYERLIST packet) { if (null == m_AroundPlayerListItem) { Module.Log.LogModule.ErrorLog("load friend item fail"); return; } if (m_TabController.GetHighlightTab() == null) { return; } GameObject curTab = m_TabController.GetHighlightTab().gameObject; if (curTab.name != "1") { return; } Utils.CleanGrid(m_AroundPlayerGrid); SelectPlayerListItem(null); int idCount = packet.GuidCount; for (int i = 0; i < idCount; i++) { NearbyPlayer player = new NearbyPlayer(); player.Guid = packet.GetGuid(i); player.Name = packet.GetName(i); player.Level = packet.GetLevel(i); player.Profession = packet.GetProf(i); player.CombatNum = packet.GetCombatNum(i); player.VipLevel = packet.GetVipLevel(i); player.GuildName = packet.GetGuildName(i); GameObject AroundPlayerItem = Utils.BindObjToParent(m_AroundPlayerListItem, m_AroundPlayerGrid, i.ToString()); if (AroundPlayerItem == null || AroundPlayerItem.GetComponent <AroundPlayerItemLogic>() == null) { continue; } AroundPlayerItem.SetActive(true); AroundPlayerItem.GetComponent <AroundPlayerItemLogic>().Init(player); } m_AroundPlayerGrid.GetComponent <UIGrid>().Reposition(); m_AroundPlayerSumLabel.text = idCount.ToString(); }
internal void onStartDiscovery() { NearbyRoom.StopAll(); myEndpointId = UnityEngine.Random.Range(1000, 10000).ToString(); myName = UnityEngine.Random.Range(1000, 10000).ToString(); NearbyPlayer nearbyPlayer = new NearbyPlayer(SystemInfo.deviceUniqueIdentifier, myEndpointId, myName); globalNearbyPlayer = nearbyPlayer; NearbyRoom.FindRooms(OnRoomFound); //PlayGamesPlatform.InitializeNearby((client) => //{ // Debug.Log("Nearby connections initialized"); //}); //Debug.Log("onStartDiscovery called"); //PlayGamesPlatform.Nearby.StartDiscovery( // PlayGamesPlatform.Nearby.GetServiceId(), // TimeSpan.FromSeconds(0), // listener); }
public void InitPlayerListItemInfo(NearbyPlayer info) { HideAllUI(); m_nearbyPlayer = info; if (info != null) { m_ItemType = PlayerListItemType.NearByPlayer; //设置GUID m_Guid = info.Guid; //姓名 SetName(info.Name); //职业 SetPro(info.Profession); //等级 SetLevel(info.Level); //战斗力 SetCombatNum(info.CombatNum); } }
public void UpdateNearbyPlayer(NearbyPlayer player, bool available, ulong sessionStartTime) { object[] objArray1 = new object[] { player, available, sessionStartTime }; base.method_8("UpdateNearbyPlayer", objArray1); }