protected override async ETTask Run(ETModel.Session session, Actor_AuthorityPlayCard_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { //重置玩家提示 gamer.GetComponent <LandlordsGamerPanelComponent>().ResetPrompt(); //当玩家为先手,清空出牌 if (message.IsFirst) { gamer.GetComponent <HandCardsComponent>().ClearPlayCards(); } //显示出牌按钮 if (gamer.UserID == LandRoomComponent.LocalGamer.UserID) { LandInteractionComponent interaction = uiRoom.GetComponent <LandRoomComponent>().Interaction; interaction.IsFirst = message.IsFirst; interaction.StartPlay(); } } await ETTask.CompletedTask; }
public static async Task <bool> IsGameVersionCodeEqual() { string versionCodeInner = GlobalConfigComponent.Instance.GlobalProto.VersionCodeInner; Log.Debug($"versionCodeInner:{versionCodeInner}"); string versionCodeOuter = GlobalConfigComponent.Instance.GlobalProto.VersionCodeOuter; Log.Debug($"versionCodeOuter:{versionCodeOuter}"); string versionCode = versionCodeOuter; if (ETModel.Define.isInnetNet) { versionCode = versionCodeInner; } UnityWebRequestAsync webRequestAsync = ComponentFactory.Create <UnityWebRequestAsync>(); try { //下载VersionCode var webRequestGameVersion = webRequestAsync.DownloadAsync(versionCode); await webRequestGameVersion; var versionCodeText = webRequestAsync.Request.downloadHandler.text; ZLog.Info($"versionCode:{versionCodeText}"); webRequestAsync.Dispose(); //比较VersionCode ZLog.Info($"ETModel.Define.versionGameCode:{ETModel.Define.versionGameCode}"); if (versionCodeText.Equals(ETModel.Define.versionGameCode)) { ZLog.Info($"versionGameCode Equal"); return(true); } else { ZLog.Info($"versionGameCode Not Equal"); //while (!VideoUtil.videoFinished) // await UniRx.Async.UniTask.DelayFrame(1); UIComponent uiComponent = Game.Scene.GetComponent <UIComponent>(); UI uiLoading = uiComponent.Get(UIType.UILoading); var uiLoadingComponent = uiLoading.GetComponent <UILoadingComponent>(); //弹提示. var trans = uiLoadingComponent.view.transform.Find("ConfirmWindowVersion"); var tip = new UIUpdateVersionTip(trans); tip.OnConfirm = () => { ETModel.Define.QuitApplication(); }; return(false); } } catch (Exception e) { if (e.Message.Contains("request error")) { webRequestAsync.Dispose(); ZLog.Info("load VersionGameCode err", e.Message); return(false); } } return(false); }
protected override async ETTask Run(ETModel.Session session, Actor_SetLandlord_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>(); if (gamer.UserID == LandRoomComponent.LocalGamer.UserID) { //如果本地玩家是地主添加地主牌 Card[] Tcards = new Card[message.LordCards.Count]; for (int i = 0; i < message.LordCards.Count; i++) { Tcards[i] = message.LordCards[i]; } handCards.AddCards(Tcards); } else { //其他玩家设置手牌数 handCards.SetHandCardsNum(20); } } //设置值玩家身份 foreach (var _gamer in room.gamers) { HandCardsComponent handCardsComponent = _gamer.GetComponent <HandCardsComponent>(); LandlordsGamerPanelComponent gamerUI = _gamer.GetComponent <LandlordsGamerPanelComponent>(); if (_gamer.UserID == message.UserID) { handCardsComponent.AccessIdentity = Identity.Landlord; gamerUI.SetIdentity(Identity.Landlord); } else { handCardsComponent.AccessIdentity = Identity.Farmer; gamerUI.SetIdentity(Identity.Farmer); } } //重置玩家UI提示 foreach (var _gamer in room.gamers) { _gamer.GetComponent <LandlordsGamerPanelComponent>().ResetPrompt(); } //切换地主牌精灵 GameObject lordPokers = uiRoom.GameObject.Get <GameObject>("Desk").Get <GameObject>("LordPokers"); for (int i = 0; i < lordPokers.transform.childCount; i++) { Sprite lordCardSprite = CardHelper.GetCardSprite(message.LordCards[i].GetName()); lordPokers.transform.GetChild(i).GetComponent <Image>().sprite = lordCardSprite; } await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_GamerGrabLandlordSelect_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { if (gamer.UserID == LandRoomComponent.LocalGamer.UserID) { uiRoom.GetComponent <LandRoomComponent>().Interaction.EndGrab(); } gamer.GetComponent <LandlordsGamerPanelComponent>().SetGrab(message.IsGrab); } await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_SetMultiples_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); uiRoom.GetComponent <LandRoomComponent>().SetMultiples(message.Multiples); await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_GamerExitRoom_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent landlordsRoomComponent = uiRoom.GetComponent <LandRoomComponent>(); landlordsRoomComponent.RemoveGamer(message.UserID); await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_GamerEnterRoom_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent landRoomComponent = uiRoom.GetComponent <LandRoomComponent>(); //从匹配状态中切换为准备状态 if (landRoomComponent.Matching) { landRoomComponent.Matching = false; //进入房间取消匹配状态 //GameObject matchPrompt = uiRoom.GameObject.Get<GameObject>("MatchPrompt"); uiRoom.GameObject.Get <GameObject>("Ready").SetActive(true); } //服务端发过来3个GamerInfo 本地玩家进入房间的顺序 int localIndex = -1; for (int i = 0; i < message.Gamers.Count; i++) { if (message.Gamers[i].UserID == LandRoomComponent.LocalGamer.UserID) { //得出本地玩家是第几个进入房间,可能是0,1,2 localIndex = i; } } //添加进入房间的玩家,判定座位位置 for (int i = 0; i < message.Gamers.Count; i++) { //如果服务端发来了默认空GamerInfo 跳过 GamerInfo gamerInfo = message.Gamers[i]; if (gamerInfo.UserID == 0) { continue; } //如果这个ID的玩家不在桌上 if (landRoomComponent.GetGamer(gamerInfo.UserID) == null) { Gamer gamer = ETModel.ComponentFactory.Create <Gamer, long>(gamerInfo.UserID); // localIndex + 1 指本地玩家后进入的下一个玩家 // 不论本地玩家是第几个进入房间,都放在1号位(下边) if ((localIndex + 1) % 3 == i) { //玩家在本地玩家右边2号位 landRoomComponent.AddGamer(gamer, 2); } else { //玩家在本地玩家左边0号位 landRoomComponent.AddGamer(gamer, 0); } } } await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_AuthorityGrabLandlord_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); if (message.UserID == LandRoomComponent.LocalGamer.UserID) { //显示抢地主交互 uiRoom.GetComponent <LandRoomComponent>().Interaction.StartGrab(); } await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_GamerReady_Landlords message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); gamer.GetComponent <LandlordsGamerPanelComponent>().SetReady(); //本地玩家准备,隐藏准备按钮 if (gamer.UserID == LandRoomComponent.LocalGamer.UserID) { uiRoom.GameObject.Get <GameObject>("Ready").SetActive(false); } await ETTask.CompletedTask; }
private async System.Threading.Tasks.Task TestWifiUi() { UIComponent uiComponent = Game.Scene.GetComponent <UIComponent>(); UI uiLoading = uiComponent.Get(UIType.UILoading); var uiLoadingComponent = uiLoading.GetComponent <UILoadingComponent>(); var x = 2048 / 1024f; //如果大于1m才弹提示 if (x > 1) { while (!VideoUtil.videoFinished) { await UniTask.DelayFrame(1); } var actionEvent = new ActionEvent(); //弹提示. var trans = uiLoadingComponent.view.transform.Find("ConfirmWindow"); var tip = new UIUpdateTip(trans); //取两位小数 int j = (int)(x * 100); x = j / 100f; tip.SetInfo($"当前不是wifi环境, 更新需要消耗{x}M流量,\n是否更新 ? (点击取消将退出游戏)"); tip.OnConfirm = () => { trans.gameObject.SetActive(false); actionEvent.Dispatch(); }; tip.OnCancel = () => { Define.QuitApplication(); return; }; await actionEvent; } }
public static async Task StartDownLoadResources() { if (Define.isUseAssetBundle) { 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) { var x1 = uiLoadingComponent.DownLoadInfo.TotalSize / 1024; var x = x1 / 1024f; //如果大于1m 不是wifi才弹提示 if (x > 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)(x * 100); x = j / 100f; tip.SetInfo($"当前不是wifi环境, 更新需要消耗{x}M流量,\n是否更新 ? (点击取消将退出游戏)"); tip.OnConfirm = () => { trans.gameObject.SetActive(false); actionEvent.Dispatch(); }; tip.OnCancel = () => { Define.QuitApplication(); return; }; await actionEvent; } } await bundleDownloaderComponent.Down(); uiLoadingComponent.DownLoadInfo.IsEnd = true; } //Game.Scene.GetComponent<ResourcesComponent>().LoadOneBundle("StreamingAssets"); await Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundleAsync("StreamingAssets"); ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest"); } catch (Exception e) { Log.Error(e); } } }
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); } } }
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; }