public void subcribeRoom(RoomGame room) { string lobbyAddress = levelId + "/" + room.id; LobbySubscribePacket packet = new LobbySubscribePacket(); packet.type = Enums.LobbyType.REGULAR; packet.gameid = gameId; packet.address = lobbyAddress; sendPacket(packet); }
public void sendSelectR(RoomGame room) { var jsonData = new JSONClass(); jsonData ["evt"] = "selectR"; jsonData ["gameid"].AsInt = gameId; jsonData ["id"].AsInt = room.id; sendService(jsonData.ToString()); }
static void Main(string[] args) { Console.WriteLine("Room Game!"); RoomGame game = new RoomGame(); System.Console.WriteLine("Navigate the different rooms. CTRL-C to quit:"); while (true) { game.ChooseRoom(); } }
private void getListGamesOfRoom(RoomGame roomGame) { // TODO: can optimize lai viec find GameObject, co the dat vao CubeiaClient CubeiaClient cubeia = GameApplication.cubeia; GameObject tableListObject = GameObject.Find("TableList"); TableListControl tableListControl = (TableListControl)tableListObject.GetComponent(typeof(TableListControl)); // cubeia.tableList = new TableGame[] {}; // if (User.getInstance().roomGame.length < 1) // return; cubeia.currentRoom = roomGame; // enter room default cubeia.tableList.Clear(); tableListControl.updateListItem(cubeia.tableList); cubeia.sendSelectR(roomGame); }
public void InitLobby() { //Para se juntar a uma sala, precisa estar no Lobby primeiro PhotonNetwork.JoinLobby(); //Se a conexão foi feita, instancia 10 botões que levam a salas diferentes if (PhotonNetwork.IsConnected) { for (int i = 0; i <= 9; i++) { RoomGame newRoom = Instantiate(roomPrefab).GetComponent <RoomGame>(); newRoom.transform.SetParent(transform, false); //Diferenciação das salas pelos nomes newRoom.roomName = "Room" + i; newRoom.roomIcon = roomIcons[i]; } } }
public void AddNewItem(RoomGame roomGame) { RectTransform rect = (RectTransform)Instantiate(RoomItem); rect.transform.parent = this.transform; rect.pivot = new Vector2(0.5f, 1); rect.offsetMax = new Vector2(0, rect.offsetMax.y); rect.offsetMin = new Vector2(MarginLR, rect.offsetMin.y); rect.anchoredPosition = new Vector2(0, bottomPositionY); bottomPositionY -= rect.rect.height + ItemSpacing; Button button = rect.GetComponent <Button>(); button.onClick.AddListener(() => { Debug.Log(roomGame.name + " clicked"); if (!roomGame.isFree) { getListGamesOfRoom(roomGame); } else if (GameApplication.user.ag > getMinAG()) { Debug.Log("Phòng Miễn phí chỉ dành cho các game thủ có tài sản dưới " + getMinAG() + " AG! Bạn vui lòng sang các phòng chơi khác để chơi nhé "); } else { getListGamesOfRoom(roomGame); } }); RectTransform textTransform = (RectTransform)rect.FindChild("Text"); Text text = textTransform.GetComponent <Text>(); text.text = roomGame.name; UpdateScrollHeight(); }
public void CreateTable(RoomGame Game) { throw new NotImplementedException(); }
public static void handleServiceTransportPacket(ServiceTransportPacket serviceTransportPacket) { User user = GameApplication.user; CubeiaClient cubeia = GameApplication.cubeia; string jsonServiceTransportPacket = System.Text.Encoding.UTF8.GetString(serviceTransportPacket.servicedata); Debug.Log("ServiceTransportPacket: " + jsonServiceTransportPacket); var serviceData = JSONNode.Parse(jsonServiceTransportPacket); string evt = serviceData ["evt"]; if (evt.Equals("0")) { // TODO: doan nay cua game mini var data = JSONNode.Parse(serviceData ["data"]); user.id = data ["userid"].AsInt; user.name = data ["username"]; user.ag = data ["gold"].AsInt; user.vip = data ["vip"].AsInt; } else if (evt.Equals("2") || evt.Equals("getLR")) { JSONArray data = JSONNode.Parse(serviceData ["data"]).AsArray; Debug.Log(string.Format("list rooms size : {0}", data.Count)); // GameObject roomListObject = GameObject.Find("RoomList"); // RoomListControl roomListControl = (RoomListControl)roomListObject.GetComponent(typeof(RoomListControl)); cubeia.roomList = new RoomGame[data.Count]; for (int i = 0; i < data.Count; i++) { bool isFree = false; if (i == data.Count - 1) { isFree = true; } RoomGame roomGame = new RoomGame( data [i] ["Id"].AsInt, data [i] ["Name"], data [i] ["MaxTable"].AsInt, data [i] ["CurPlay"].AsInt, data [i] ["MaxPlay"].AsInt, data [i] ["CurTable"].AsInt, isFree ); cubeia.roomList [i] = roomGame; Debug.Log("Parsed RoomGame: " + roomGame.toString()); // update to the view // roomListControl.AddNewItem(roomGame); } // vao room // cubeia.unsubcribeRoom(cubeia.currentRoom); cubeia.currentRoom = cubeia.roomList [0]; cubeia.sendSelectR(cubeia.currentRoom); } else if (evt.Equals("3") || evt.Equals("selectR")) { // sau khi nhan tin hieu vao room, subcribe room nay // cubeia.subcribeRoom(cubeia.currentRoom); cubeia.quickJoinTable(); // sendService("{\"evt\"=\"searchT\",\"gameid\"=8006}"); // sendCreateGame(); } }