Example #1
0
        public static async ETVoid OnJoinRoomAsync(long userId, string roomId)
        {
            Session session = Game.Scene.GetComponent <SessionComponent>().Session;
            G2C_CowCowJoinGameRoomGate g2c_Join = (G2C_CowCowJoinGameRoomGate)await session.Call(new C2G_CowCowJoinGameRoomGate()
            {
                UserID = userId, RoomID = roomId
            });

            if (g2c_Join.Error == 0)
            {
                Game.EventSystem.Run(CowCowEventIdType.JoinGameRoom, g2c_Join);
            }
            else
            {
                //弹窗显示异常消息
            }
        }
Example #2
0
        public static UI Create(G2C_CowCowJoinGameRoomGate room)
        {
            try
            {
                ResourcesComponent rc = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                rc.LoadBundle(UICowCowAB.CowCow_Prefabs);
                GameObject ab         = (GameObject)rc.GetAsset(UICowCowAB.CowCow_Prefabs, UICowCowType.CowCowGameRoom);
                GameObject gameObject = UnityEngine.Object.Instantiate(ab);

                UI ui = ComponentFactory.Create <UI, string, GameObject>(UICowCowType.CowCowGameRoom, gameObject);
                ui.AddComponent <UICowCow_GameRoomComponent>(); //加入游戏房间组件
                ui.GetComponent <UICowCow_GameRoomComponent>().Init(room.GameName, room.Bureau, room.RuleBit, room.RoomID, room.People, room.CurBureau);

                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }