Ejemplo n.º 1
0
        public override void Run()
        {
            UI ui = UILobbyFactory.Create();

            Game.Scene.GetComponent <UIComponent>().Add(ui);
        }
Ejemplo n.º 2
0
 public void Add(string type, UI ui)
 {
     this.uis.Add(type, ui);
 }
Ejemplo n.º 3
0
        public static async Task StartDownLoadResources()
        {
            if (Define.IsAsync)
            {
                try
                {
                    using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.GetComponent <BundleDownloaderComponent>())
                    {
                        var         t                  = bundleDownloaderComponent.LoadInfo();
                        UIComponent uiComponent        = Game.Scene.GetComponent <UIComponent>();
                        UI          uiLoading          = uiComponent.Get(UIType.UILoading);
                        var         uiLoadingComponent = uiLoading.GetComponent <UILoadingComponent>();
                        uiLoadingComponent.DownLoadInfo = bundleDownloaderComponent.DownloadInfo;
                        bundleDownloaderComponent.BundleRealProgress      = uiLoadingComponent.BundleRealDownload;
                        bundleDownloaderComponent.BundleEachFrameProgress = uiLoadingComponent.BundleDownloadFrames;
                        uiLoadingComponent.UpdateProgress = bundleDownloaderComponent.UpdateProgress;
                        var needDown = await t;
                        if (needDown)
                        {
                            while (!VideoUtil.videoFinished)
                            {
                                await UniRx.Async.UniTask.DelayFrame(1);
                            }
                            var sizeKB = bundleDownloaderComponent.TotalSize / 1024;
                            var sizeM  = sizeKB / 1024f;
                            //如果大于1m 不是wifi才弹提示
                            if (sizeM > 1 && Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
                            {
                                while (!VideoUtil.videoFinished)
                                {
                                    await UniRx.Async.UniTask.DelayFrame(1);
                                }
                                var actionEvent = new ActionEvent();
                                //弹提示.
                                var trans = uiLoadingComponent.view.transform.Find("ConfirmWindow");
                                var tip   = new UIUpdateTip(trans);
                                //取两位小数
                                int j = (int)(sizeM * 100);
                                sizeM = j / 100f;
                                //50138140
                                var tips = "Currently not connected to WIFI, please choose whether to download the update.";
                                tip.SetTitle("Tips");
                                tip.SetInfo(tips);//$"当前不是wifi环境, 更新需要消耗{sizeM}M流量,\n是否更新 ? (点击取消将退出游戏)");
                                tip.OnConfirm = () =>
                                {
                                    trans.gameObject.SetActive(false);
                                    actionEvent.Dispatch();
                                };
                                tip.OnCancel = () =>
                                {
                                    Define.QuitApplication();
                                    return;
                                };

                                await actionEvent;
                            }

                            await bundleDownloaderComponent.Down();

                            uiLoadingComponent.DownLoadInfo.IsEnd = true;
                            SaveVersion();
                        }

                        /*若想在播放开场视频时就开始使用wifi下载,注掉下面
                         * while(!VideoUtil.videoFinished)
                         *  await UniRx.Async.UniTask.DelayFrame(1);*/

                        uiLoadingComponent.UpdateProgressNew(0.9f);
                    }
                    //await Game.Scene.GetComponent<ResourcesComponent>().LoadOneBundleAsync("StreamingAssets");

                    //ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent<ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
Ejemplo n.º 4
0
 public void Add(UI ui)
 {
     this.children.Add(ui.Name, ui);
     ui.Parent = this;
 }
        protected override async ETTask Run(ETModel.Session session, Actor_GameStartHandCards_Ntt message)
        {
            UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom);
            LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>();

            //初始化玩家UI
            foreach (GamerCardNum gamerCardNum in message.GamersCardNum)
            {
                Gamer gamer = room.GetGamer(gamerCardNum.UserID);
                LandlordsGamerPanelComponent gamerUI = gamer.GetComponent <LandlordsGamerPanelComponent>();
                gamerUI.GameStart();

                HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>();
                if (handCards != null)
                {
                    handCards.Reset();
                }
                else
                {
                    //Log.Debug("没有可以复用的HandCardsComponent,创建一个。");
                    handCards = gamer.AddComponent <HandCardsComponent, GameObject>(gamerUI.Panel);
                }

                //显示牌背面或者手牌
                handCards.Appear();
                //添加与更新本地玩家的手牌
                if (gamer.UserID == LandRoomComponent.LocalGamer.UserID)
                {
                    //本地玩家添加手牌
                    Card[] Tcards = new Card[message.HandCards.Count];
                    for (int i = 0; i < message.HandCards.Count; i++)
                    {
                        Tcards[i] = message.HandCards[i];
                    }
                    handCards.AddCards(Tcards);
                }
                else
                {
                    //设置其他玩家手牌数
                    handCards.SetHandCardsNum(gamerCardNum.Num);
                }
            }

            //显示牌桌UI
            GameObject desk = uiRoom.GameObject.Get <GameObject>("Desk");

            desk.SetActive(true);
            GameObject lordPokers = desk.Get <GameObject>("LordPokers");

            //重置地主牌
            Sprite lordSprite = CardHelper.GetCardSprite("None");

            for (int i = 0; i < lordPokers.transform.childCount; i++)
            {
                lordPokers.transform.GetChild(i).GetComponent <Image>().sprite = lordSprite;
            }

            LandRoomComponent uiRoomComponent = uiRoom.GetComponent <LandRoomComponent>();

            //设置初始倍率
            uiRoomComponent.SetMultiples(1);

            await ETTask.CompletedTask;
        }