Пример #1
0
        public UI Create(Scene scene, string type, GameObject gameObject)
        {
            try
            {
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle($"{type}.unity3d");
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}");
                GameObject lobby            = UnityEngine.Object.Instantiate(bundleGameObject);
                lobby.layer = LayerMask.NameToLayer(LayerNames.UI);
                UI ui = ComponentFactory.Create <UI, GameObject>(lobby);

                ui.AddUiComponent <UILobbyComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
Пример #2
0
        public static UI Create <T>(string uiName) where T : Component, new()
        {
            try
            {
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle(uiName.StringToAB());
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(uiName.StringToAB(), uiName);
                GameObject gameObject       = UnityEngine.Object.Instantiate(bundleGameObject);

                UI ui = ComponentFactory.Create <UI, string, GameObject>(uiName, gameObject);
                ui.AddComponent <T>();

                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
Пример #3
0
        public void Awake(GameObject parent)
        {
            room = Game.Scene.GetComponent <UIComponent>().Get(UICowCowType.CowCowGameRoom).GetComponent <UICowCow_GameRoomComponent>();
            res  = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            res.LoadBundle(UICowCowAB.CowCow_Prefabs);
            GameObject ab = (GameObject)res.GetAsset(UICowCowAB.CowCow_Prefabs, UICowCowType.CowCowDissoltion);

            this.GameObject = UnityEngine.Object.Instantiate(ab);
            this.GameObject.transform.SetParent(parent.transform, false);
            this.GameObject.name = UICowCowType.CowCowDissoltion;

            ReferenceCollector rc = this.GameObject.GetComponent <ReferenceCollector>();

            gamerInfo   = rc.Get <GameObject>("GamerInfo");
            agreeBtn    = rc.Get <GameObject>("Agree").GetComponent <Button>();
            disagreeBtn = rc.Get <GameObject>("Disagree").GetComponent <Button>();

            agreeBtn.onClick.Add(OnAgree);
            disagreeBtn.onClick.Add(OnDisagree);
        }
Пример #4
0
        public static UI Create(string bundleName, string prefab, string uiName,
                                bool fromPool = false)
        {
            try
            {
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle(bundleName);
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(bundleName, prefab);
                GameObject gameObject       = UnityEngine.Object.Instantiate(bundleGameObject);

                UI ui = ComponentFactory.Create <UI, string, GameObject>(uiName, gameObject, fromPool);

                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
Пример #5
0
        public UI Create(Scene scene, UIType type, GameObject gameObject)
        {
            try
            {
                ResourcesComponent resourcesComponent = Model.Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle($"{type}.unity3d");
                GameObject bundleGameObject = resourcesComponent.GetAsset <GameObject>($"{type}.unity3d", $"{type}");
                GameObject login            = UnityEngine.Object.Instantiate(bundleGameObject);
                login.layer = LayerMask.NameToLayer(LayerNames.UI);
                UI ui = ComponentFactory.Create <UI, GameObject>(login);

                ui.AddComponent <UILoginComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e.ToStr());
                return(null);
            }
        }
Пример #6
0
        public static UI Create()
        {
            try
            {
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle(UIType.UIRegisterAndLogin.StringToAB());
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UIRegisterAndLogin.StringToAB(), UIType.UIRegisterAndLogin);
                GameObject gameObject       = UnityEngine.Object.Instantiate(bundleGameObject);

                UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UIRegisterAndLogin, gameObject, false);

                ui.AddComponent <UIRegisterAndLoginComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
Пример #7
0
        public UI_Z Create(Scene scene, string type, GameObject parent)
        {
            try
            {
                ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle($"{type}.unity3d");
                GameObject bundleGameObject = resourcesComponent.GetAsset <GameObject>($"{type}.unity3d", $"{type}");
                GameObject newUi            = UnityEngine.Object.Instantiate(bundleGameObject);
                newUi.layer = LayerMask.NameToLayer(LayerNames.UI);
                UI_Z ui = ComponentFactory.Create <UI_Z, GameObject>(newUi);

                //此处务必使用AddUiComponent代替原本et中的AddComponent否则UI_Z中的UiComponent属性会为空
                ui.AddUiComponent <UILoginComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e.ToStr());
                return(null);
            }
        }
Пример #8
0
 public UI Create()
 {
     try
     {
         ResourcesComponent res = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
         res.LoadBundle(UIType.UILobby.StringToAB());
         GameObject bundleGameObject = res.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby) as GameObject;
         GameObject go = UnityEngine.Object.Instantiate(bundleGameObject);
         go.layer = LayerMask.NameToLayer(LayerNames.UI);
         UI  ui  = ComponentFactory.Create <UI, string, GameObject>(UIType.UILobby, go, false);
         var com = ui.AddComponent <UILobbyComponent>();
         adapter = ui.AddComponent <UILobbyAdapterComponent>();
         adapter.Init(com);
         return(ui);
     }
     catch (Exception e)
     {
         Log.Error(e);
         return(null);
     }
 }
Пример #9
0
        public static UI Create()
        {
            try
            {
                ResourcesComponent res = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                res.LoadBundle(GlobalsUIAB.Globals_Prefabs);
                GameObject ab = (GameObject)res.GetAsset(GlobalsUIAB.Globals_Prefabs, GlobalsUIType.UIPopupsCanvas);
                GameObject go = UnityEngine.Object.Instantiate(ab);

                UI ui = ComponentFactory.Create <UI, string, GameObject>(GlobalsUIType.UIPopupsCanvas, go, false);

                res.UnloadBundle(GlobalsUIAB.Globals_Prefabs);
                ui.AddComponent <UIPopupsComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
Пример #10
0
        /// <summary>
        /// 创建UI
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static UI Create(string type)
        {
            try
            {
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle(ATLAS_NAME);
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(ATLAS_NAME, type);
                GameObject gameObject       = UnityEngine.Object.Instantiate(bundleGameObject);

                UI ui = ComponentFactory.Create <UI, string, GameObject>(type, gameObject, false);

                Game.Scene.GetComponent <UIComponent>().Add(ui);

                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
Пример #11
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);
            }
        }
Пример #12
0
        public UIEx Create(Scene scene, string type, GameObject parent)
        {
            try
            {
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle(type.StringToAB());
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(type.StringToAB(), type);
                GameObject gameObject       = UnityEngine.Object.Instantiate(bundleGameObject);
                gameObject.layer = LayerMask.NameToLayer(LayerNames.UI);

                UIEx ui = ComponentFactory.Create <UIEx, GameObject>(gameObject);

                ui.AddUiComponent <TestComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
 public static UI Create()
 {
     try
     {
         ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
         resourcesComponent.LoadBundle(UIType.UILobby.StringToAB());
         //拿到大厅资源 进行克隆实例
         GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby);
         GameObject gameObject       = UnityEngine.Object.Instantiate(bundleGameObject);
         //创建大厅实体->调用UI Awake方法 传递这2个参数
         UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UILobby, gameObject, false);
         //添加UILobbyComponent组件 那么就会调度UILobbyComponent的Awake方法
         ui.AddComponent <UILobbyComponent>();
         return(ui);
     }
     catch (Exception e)
     {
         Log.Error(e);
         return(null);
     }
 }
        public UI Create(Scene scene, string type, GameObject parent)
        {
            try
            {
                //this.LogInfo($"当前已经Load出来这个:{type}的Ab包,因为子类继承了AUIFactoty,而AUIFactoty实现了IUIFactory的Create方法,所以子类看不到Create就创建过了");
                //if (currentSubGameType != SubGameType.Hall)
                //{
                //    this.LogInfo($"当前开始从子游戏类目:{currentSubGameType}下面加载AB资源包");
                //}
                //获取资源组件
                resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                //加载AB包
                resourcesComponent.LoadBundle($"{type}.unity3d");
                //this.LogInfo("[AB包异步加载完毕]====>"+ $"{type}.unity3d");
                //通过对应的AB包得到对应的预制体,
                GameObject bundlePrefab = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}");


                //通过AB包加载预制体
                GameObject login = UnityEngine.Object.Instantiate(bundlePrefab); //这个时候已经clone出来了 其实已经走了awake了
                //this.LogInfo("[预设体加载完毕]====>" + $"{login.name}");
                //第二次加载时直接从缓存里加载,由于加载速度比从磁盘快,实例化出来就awake开始执行了,执行完毕后,才王下面执行
                //设置层级
                login.layer = LayerMask.NameToLayer(LayerNames.UI);
                //创建ui对象  [使用工厂将UI 和游戏对象绑定]
                UI ui = ComponentFactory.Create <UI, GameObject>(login);


                //暂时调整一下执行顺序,等绑定上组件后,再执行实例化
                //给ui对象挂载组件
                //AddComponet(ui);
                //this.LogInfo($"[从{type}.unity3d -> {bundlePrefab.name}异步结束 并绑定UI组件{ui.Name}完毕]");
                return(ui);
            }
            catch (Exception e)
            {
                Debug.Log("我的错" + e.ToStr());
                return(null);
            }
        }
Пример #15
0
        public void Awake(bool isWin)
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle($"{CONTENT_NAME}.unity3d");

            if (isWin)
            {
                rc.Get <GameObject>("Lose").SetActive(false);
            }
            else
            {
                rc.Get <GameObject>("Win").SetActive(false);
            }

            gamerContent = rc.Get <GameObject>("GamerContent");
            Button continueButton = rc.Get <GameObject>("ContinueButton").GetComponent <Button>();

            continueButton.onClick.Add(OnContinue);
            contentPrefab = (GameObject)resourcesComponent.GetAsset($"{CONTENT_NAME}.unity3d", CONTENT_NAME);
        }
Пример #16
0
        public static UI Create()
        {
            try
            {
                string uiType = UIType.UIMain;
                //1.获取资源组件
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                //加载bundle
                resourcesComponent.LoadBundle(uiType.StringToAB());
                //将bundle加载成obj
                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(uiType.StringToAB(), uiType);
                //实例化
                GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);
                UI         ui         = ComponentFactory.Create <UI, string, GameObject>(uiType, gameObject, false);

                ui.AddComponent <UIMainComponent>();
                return(ui);
            }
            catch (System.Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
Пример #17
0
        public void Awake()
        {
            res = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            res.LoadBundle(UICowCowAB.CowCow_Prefabs);
            res.LoadBundle(UICowCowAB.CowCow_Texture);

            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            BackGround    = rc.Get <GameObject>("BackGround");
            UIRoomGamer   = rc.Get <GameObject>("UIRoomGamer");
            this.bureau   = rc.Get <GameObject>("GameBureau").GetComponent <Text>();
            this.gameName = rc.Get <GameObject>("GameName").GetComponent <Text>();
            this.gameRule = rc.Get <GameObject>("GameRule").GetComponent <Text>();
            this.roomId   = rc.Get <GameObject>("RoomID").GetComponent <Text>();
            Text         nowTime     = rc.Get <GameObject>("NowTime").GetComponent <Text>();
            Button       phizBtn     = rc.Get <GameObject>("PhizBtn").GetComponent <Button>();
            Button       keyboardBtn = rc.Get <GameObject>("KeyboardBtn").GetComponent <Button>();
            EventTrigger voiceEvent  = rc.Get <GameObject>("VoiceBtn").GetComponent <EventTrigger>();
            Button       dissBtn     = rc.Get <GameObject>("DissBtn").GetComponent <Button>();
            Button       settingBtn  = rc.Get <GameObject>("SettingBtn").GetComponent <Button>();

            readyBtn  = rc.Get <GameObject>("ReadyBtn").GetComponent <Button>();
            inviteBtn = rc.Get <GameObject>("InviteBtn").GetComponent <Button>();

            cardHeap              = rc.Get <GameObject>("CardHeap").GetComponent <Image>();
            betButtonPanel        = rc.Get <GameObject>("BetButtonPanel").GetComponent <CanvasGroup>();
            grabBankerButtonPanel = rc.Get <GameObject>("GrabBankerButtonPanel").GetComponent <CanvasGroup>();
            Button[] betBtns        = new Button[betButtonPanel.transform.childCount];
            Button[] grabBankerBtns = new Button[grabBankerButtonPanel.transform.childCount];
            for (int i = 0; i < betBtns.Length; i++)
            {
                int n = i + 1;
                betBtns[i] = rc.Get <GameObject>($"X{(i + 1)}Btn").GetComponent <Button>();
                betBtns[i].onClick.Add(() => { this.OnBet(n); });
                grabBankerBtns[i] = rc.Get <GameObject>($"GrabBankerX{(i + 1)}Btn").GetComponent <Button>();
                grabBankerBtns[i].onClick.Add(() => { this.OnGrabBanker(n); });
            }
            Button grabBankerCloseBtn = rc.Get <GameObject>("GrabBankerCloseBtn").GetComponent <Button>();

            grabBankerCloseBtn.onClick.Add(() => {
                this.OnGrabBanker(1); //所有玩家都不抢庄时,默认为1
            });


            phizBtn.onClick.Add(Onphiz); // 表情
            keyboardBtn.onClick.Add(OnKeyboard);
            dissBtn.onClick.Add(OnDiss);
            readyBtn.onClick.Add(OnReady);
            inviteBtn.onClick.Add(OnInvite);
            settingBtn.onClick.Add(OnSetting);

            voiceEvent.triggers.Add(AddEventTrigger(EventTriggerType.PointerDown, OnVoiceDown));
            voiceEvent.triggers.Add(AddEventTrigger(EventTriggerType.PointerUp, OnVoiceUp));

            isShowTime = true;
            NowTime(nowTime).Coroutine();


            // 隐藏即可
            Game.Scene.GetComponent <UIComponent>().Get(UICowCowType.CowCowLobby).GetComponent <UICowCowLobbyComponent>().ShowHideLobby(false);
            //Game.EventSystem.Run(CowCowEventIdType.RemoveLobby);
        }