public static async ETTask <FUI> Create() { await ETTask.CompletedTask; // 可以同步或者异步加载,异步加载需要搞个转圈圈,这里为了简单使用同步加载 // await ETModel.Game.Scene.GetComponent<FUIPackageComponent>().AddPackageAsync(FUIType.Login); ETModel.Game.Scene.GetComponent <FUIPackageComponent>().AddPackage(FUIType.MainInterface); FUI fui = ComponentFactory.Create <FUI, GObject>(UIPackage.CreateObject(FUIType.MainInterface, FUIType.MainInterface)); fui.Name = FUIType.MainInterface; // 这里可以根据UI逻辑的复杂度关联性,拆分成多个小组件来写逻辑,这里逻辑比较简单就只使用一个组件了 fui.AddComponent <MainItfViewComponent>(); // FUI uilong = Game.Scene.GetComponent<FUIComponent>().Get(FUIType.Login); // // uilong.GetComponent<LoginViewComponent>(); return(fui); }
public UI Create(Scene scene, string type, GameObject gameObject) { try { Debug.Log("354"); ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject login = UnityEngine.Object.Instantiate(bundleGameObject); login.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(login); ui.AddComponent <MyUILoginComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static UI Create() { try { string uiType = UIType.UIMainLobby; ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(uiType.StringToAB()); 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 <UIMainLobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
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 go = UnityEngine.Object.Instantiate(bundleGameObject); go.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(go); // ui.AddUIBaseComponent<UILogin_LineComponent>(); AddSubComponent(ui); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
private void CreateItemList(List <Bag> itemList) { GameObject obj = null; if (itemList.Count <= 0) { SetMoreHide(0); } for (int i = 0; i < itemList.Count; ++i) { if (i < bagItemList.Count) { bagItemList[i].SetActive(true); obj = bagItemList[i]; } else { obj = GameObject.Instantiate(bagItem); obj.transform.SetParent(grid.transform); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; bagItemList.Add(obj); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIBagItemComponent>(); uiList.Add(ui); } if (item != null && IsCurPropUseUp()) { SetItemInfo(item); } else { SetItemInfo(itemList[0]); } uiList[i].GetComponent <UIBagItemComponent>().SetItemInfo(itemList[i], i + 1); } SetMoreHide(itemList.Count); }
private async ETVoid RunAsync(Session session, G2B_CreateTank message, Action <B2G_CreateTank> reply) { B2G_CreateTank response = new B2G_CreateTank(); try { Battle battle = Game.Scene.GetComponent <BattleComponent>().Get(message.BattleId); // 随机生成一辆坦克,id和instanceId不相等 Tank tank = ComponentFactory.CreateWithId <Tank>(IdGenerater.GenerateId()); tank.PlayerId = message.PlayerId; tank.Battle = battle; tank.Name = message.Name; tank.Level = message.Level; tank.AddComponent <NumericComponent>(); battle.Add(tank); tank.TankCamp = message.Camp == 1? TankCamp.Left : TankCamp.Right; await tank.AddComponent <MailBoxComponent>().AddLocation(); tank.AddComponent <TankGateComponent, long>(message.GateSessionId); response.TankId = tank.Id; reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async ETTask Run(Session session, G2M_CreateUnit request, M2G_CreateUnit response, Action reply) { Unit unit = ComponentFactory.CreateWithId <Unit>(IdGenerater.GenerateId()); unit.Position = new Vector3(-10, 0, -10); SyncType type = Game.Scene.GetComponent <NetSyncComponent>().type; if (type == SyncType.State) { unit.AddComponent <MoveComponent>(); unit.AddComponent <UnitPathComponent>(); } await unit.AddComponent <MailBoxComponent>().AddLocation(); unit.AddComponent <UnitGateComponent, long>(request.GateSessionId); Game.Scene.GetComponent <UnitComponent>().Add(unit); response.UnitId = unit.Id; // 广播创建的unit M2C_CreateUnits createUnits = new M2C_CreateUnits(); Unit[] units = Game.Scene.GetComponent <UnitComponent>().GetAll(); foreach (Unit u in units) { UnitInfo unitInfo = new UnitInfo(); unitInfo.X = u.Position.x; unitInfo.Y = u.Position.y; unitInfo.Z = u.Position.z; unitInfo.UnitId = u.Id; createUnits.Units.Add(unitInfo); } MessageHelper.Broadcast(createUnits); reply(); }
protected override async void Run(Session session, C2G_AddAccountInfo message, Action <G2C_AddAccountInfo> reply) { G2C_AddAccountInfo response = new G2C_AddAccountInfo(); response.IsOk = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); AccountInfo accountInfo = ComponentFactory.Create <AccountInfo>(); accountInfo._AccountID = message.AccountID; accountInfo._Name = message.Name; accountInfo._BornDate = message.BornDate; accountInfo._IDCardNumber = message.IDCardNumber; accountInfo._Sex = message.Sex; accountInfo._IsFinishIdentify = message.IsFinishIdentify; accountInfo._HeadImage = message.HeadImage; accountInfo._FingerprintCode = message.FingerprintCode; accountInfo._UserImpotentLevel = message.UserImpotentLevel; accountInfo._FaceprintCode = ""; accountInfo._PrintType = 0; response.IsOk = true; response.InfoID = accountInfo.Id; await dBProxyComponent.Save(accountInfo); await dBProxyComponent.SaveLog(accountInfo); reply(response); } catch (Exception e) { response.IsOk = false; response.Message = "数据库异常"; ReplyError(response, e, reply); } }
private static async ETTask LoginAsync(string address, long key) { PopupsHelper.ShowLoading(true); Address = address; Key = key; ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(address); if (ETModel.Game.Scene.GetComponent <ETModel.SessionComponent>() == null) { ETModel.Game.Scene.AddComponent <ETModel.SessionComponent>().Session = gateSession; Game.Scene.AddComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(gateSession); } else { ETModel.Game.Scene.GetComponent <ETModel.SessionComponent>().Session = gateSession; Game.Scene.GetComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(gateSession); } SessionComponent.Instance.Session.AddComponent <PingComponent>(); G2C_CowCowLoginGate g2cLoginGate = (G2C_CowCowLoginGate)await SessionComponent.Instance.Session.Call(new C2G_CowCowLoginGate() { Key = key }); if (g2cLoginGate.Error == 0) { Log.Debug("登录成功!"); Game.EventSystem.Run(CowCowEventIdType.LoginFinish, g2cLoginGate); ClientComponent clientComponent = ETModel.Game.Scene.GetComponent <ClientComponent>(); clientComponent.User = ETModel.ComponentFactory.Create <User, long>(g2cLoginGate.UserID); } else { Log.Debug("登录失败:" + g2cLoginGate.Message); PopupsHelper.ShowPopups($"登录失败:{ g2cLoginGate.Message}"); Game.EventSystem.Run(CowCowEventIdType.LoginFail, g2cLoginGate); } PopupsHelper.ShowLoading(false); }
public void Awake() { var res = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); res.LoadBundle(UIType.UIRankPanel.StringToAB()); var gameObject = res.GetAsset(UIType.UIRankPanel.StringToAB(), UIType.UIRankPanel); this.GameObject = (GameObject)UnityEngine.Object.Instantiate(gameObject); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UIRankPanel, this.GameObject, false); Game.Scene.GetComponent <UIComponent>().Add(ui); _ReferenceCollector = this.GameObject.Get <ReferenceCollector>(); _rankContent = _ReferenceCollector.Get <Transform>("RankContent"); _ReferenceCollector.Get <GameObject>("CloseButton").Get <Button>().onClick.AddListener(OnCloseButtonClicked); _ReferenceCollector.Get <GameObject>("CloseBg").Get <Button>().onClick.AddListener(OnCloseButtonClicked); var profitBtn = _ReferenceCollector.Get <GameObject>("ProfitBtn"); profitBtn.Get <Button>().onClick.AddListener(OnClickProfitBtn); profitBtnImg = profitBtn.Get <Image>(); var richBtn = _ReferenceCollector.Get <GameObject>("RichBtn"); richBtn.Get <Button>().onClick.AddListener(OnClickRichBtn); richBtnImg = richBtn.Get <Image>(); windowAnim = _ReferenceCollector.Get <GameObject>("Root").GetComponent <RectTransform>().DOScale(1, 0.4f).SetEase(Ease.OutBack).Pause().SetAutoKill(false); RankingList = new List <UIRankListsItem>(); TableBtn = _ReferenceCollector.Get <GameObject>("TableBtn"); _NoData = _ReferenceCollector.Get <GameObject>("NOData"); MeNameText = _ReferenceCollector.Get <GameObject>("MeNameText").Get <Text>(); MeRankNumberText = _ReferenceCollector.Get <GameObject>("MeRankNumberText").Get <Text>(); MeGoldText = _ReferenceCollector.Get <GameObject>("MeGoldText").Get <Text>(); MeHeadImage = _ReferenceCollector.Get <GameObject>("MeHeadImage").Get <Image>(); RankLevelImg = _ReferenceCollector.Get <GameObject>("RankLevelImg").Get <Image>(); TipsText = _ReferenceCollector.Get <GameObject>("TipsText").Get <Text>(); }
protected override async void Run(Session session, G2M_CreateUnit message, Action <M2G_CreateUnit> reply) { M2G_CreateUnit response = new M2G_CreateUnit(); try { Unit unit = ComponentFactory.Create <Unit>(); await unit.AddComponent <MailBoxComponent>().AddLocation(); unit.AddComponent <UnitGateComponent, long>(message.GateSessionId); Game.Scene.GetComponent <UnitComponent>().Add(unit); response.UnitId = unit.Id; response.Count = Game.Scene.GetComponent <UnitComponent>().Count; reply(response); //if (response.Count == 2) { Actor_CreateUnits actorCreateUnits = new Actor_CreateUnits(); Unit[] units = Game.Scene.GetComponent <UnitComponent>().GetAll(); foreach (Unit u in units) { //u.Position = new System.Numerics.Vector3(2000, 0, 1500); actorCreateUnits.Units.Add(new UnitInfo() { UnitId = u.Id, X = (int)(u.Position.X * 1000), Z = (int)(u.Position.Z * 1000) }); } MessageHelper.Broadcast(actorCreateUnits); } } catch (Exception e) { ReplyError(response, e, reply); } }
/// <summary> /// 创建房间Item /// </summary> private void CreateRoomItemss(List <FriendRoomInfo> roomInfos) { GameObject obj = null; for (int i = 0; i < roomInfos.Count; ++i) { if (i < roomItems.Count) { obj = roomItems[i]; } else { obj = GameObject.Instantiate(roomItem, FriendGrid.transform); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; roomItems.Add(obj); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIFriendRoomItemComponent>(); uiFList.Add(ui); } uiFList[i].GetComponent <UIFriendRoomItemComponent>().SetItemInfo(roomInfos[i]); } }
public static FiveStarRoomConfig Create(RepeatedField <int> roomConfigs) { FiveStarRoomConfig fiveStarRoom = ComponentFactory.Create <FiveStarRoomConfig>(); if (roomConfigs.Count != CardFiveStarRoomConfig.ConfigCount) { Log.Error("房间配置的条数不一致" + roomConfigs.Count); return(null); } fiveStarRoom.Configs = roomConfigs; fiveStarRoom.EndType = roomConfigs[CardFiveStarRoomConfig.EndTypeId]; fiveStarRoom.MaxJuShu = roomConfigs[CardFiveStarRoomConfig.JuShuId]; fiveStarRoom.TuoDiFen = roomConfigs[CardFiveStarRoomConfig.FenTuoDiId]; fiveStarRoom.PayMoneyType = roomConfigs[CardFiveStarRoomConfig.PayMoneyId]; fiveStarRoom.RoomNumber = roomConfigs[CardFiveStarRoomConfig.NumberId]; fiveStarRoom.BottomScore = roomConfigs[CardFiveStarRoomConfig.BottomScoreId]; fiveStarRoom.MaxPiaoNum = roomConfigs[CardFiveStarRoomConfig.FloatNumId]; fiveStarRoom.MaiMaType = roomConfigs[CardFiveStarRoomConfig.MaiMaId]; fiveStarRoom.WaiShiWuType = roomConfigs[CardFiveStarRoomConfig.WaiShiWuId]; fiveStarRoom.FengDingFanShu = roomConfigs[CardFiveStarRoomConfig.FengDingFanShuId]; fiveStarRoom.IsHaveOverTime = roomConfigs[CardFiveStarRoomConfig.IsHaveOverTimeId] != 0; return(fiveStarRoom); }
public static UIBase Create <T>(string UIName, GameObject uiGameObject, params object[] objs) where T : UIBaseComponent, new() { try { GameObject gameObject = UnityEngine.Object.Instantiate(uiGameObject); UIBase ui = ComponentFactory.CreateWithParent <UIBase, string, GameObject>(Game.Scene.GetComponent <UIManagerComponent>(), UIName, gameObject); ui.paras = objs; ui.UIGuid = System.Guid.NewGuid().ToString(); RectTransform uirecttransform = ui.GameObject.GetComponent <RectTransform>(); uirecttransform.anchorMax = Vector2.one; uirecttransform.pivot = Vector2.one * 0.5f; ui.GameObject.transform.localScale = Vector3.one; uirecttransform.offsetMax = Vector2.zero; uirecttransform.offsetMin = Vector2.zero; ui.AddComponent <T>().Init(gameObject); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
public static async ETVoid CreateJoystickUI(ETTaskCompletionSource <UI> tcs) { try { AssetRequest assetRequest = Assets.LoadAssetAsync("Assets/Bundles/UI/" + UIType.UIJoystick + ".prefab", typeof(GameObject)); //创建一个角色的3D物体 GameObject bundleGameObject = await ETModel.Game.Scene.GetComponent <ResourcesAsyncComponent>().LoadAssetAsync <GameObject>(assetRequest); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject, AssetRequest>(UIType.UIJoystick, gameObject, assetRequest, false); VariableJoystickComponent variableJoystick = ui.AddComponent <VariableJoystickComponent>(); variableJoystick.joystickType = JoystickType.Floating; tcs.SetResult(ui); } catch (Exception e) { Log.Error(e); tcs.SetResult(null); } }
public async Task <UI> CreateAsync(Scene scene, string type, GameObject parent) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); await resourcesComponent.LoadBundleAsync($"{type}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject login = UnityEngine.Object.Instantiate(bundleGameObject); login.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(login); ui.AddUIBaseComponent <UILoginComponent>(); AddSubComponent(ui); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
//---------------对外接口------------------------------ /* 添加一个警告窗口 并 置顶 * param: * strWord:窗口文本 * cb:按钮事件 * strBtn:按钮文本 */ public void CreateAlertWin( string strWord, AlertCallBack cb, string strBtn = "好的" ) { GameObject g = UnityEngine.Object.Instantiate(prefabAlert_); g.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(g); UIAlertWin win = ui.AddComponent <UIAlertWin>(); GameObjectUtil.SetParentToChild(alertsRoot_, ui.GameObject, false); GameObjectUtil.SetZ(ui.GameObject, ZORDER_ALERT); win.SetTextContent(strWord); win.SetCheckCb(cb); win.SetCheckBtnText(strBtn); win.SetCloseCallBack(closeWin); wins_.Add(ui); checkOpenBg(); }
protected override async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response, Action reply) { string account = Game.Scene.GetComponent <SessionKeyComponent>().Get(request.Key).ToString(); if (account == null) { response.Error = ErrorCode.ERR_ConnectGateKeyError; response.Message = "Gate key验证失败!"; reply(); return; } Player player = ComponentFactory.Create <Player, string>(account); Game.Scene.GetComponent <PlayerComponent>().Add(player); session.AddComponent <SessionPlayerComponent>().Player = player; session.AddComponent <MailBoxComponent, string>(MailboxType.GateSession); response.PlayerId = player.Id; reply(); //session.Send(new G2C_TestHotfixMessage() { Info = "recv hotfix message success" }); await ETTask.CompletedTask; }
protected override async void Run(Session session, B1001_CreateRobotMatch5V5_G2M message) { Moba5V5Component moba = Game.Scene.GetComponent <Moba5V5Component>(); //创建玩家Entity Gamer roomCreater = ComponentFactory.Create <Gamer, long>(message.UserID); //设置玩家参数 roomCreater.ActorIDofUser = message.ActorIDofUser; roomCreater.ActorIDofClient = message.ActorIDofClient; await roomCreater.AddComponent <MailBoxComponent>().AddLocation(); moba.AddGamerToMatchingQueue(roomCreater); //需要先设置ActorIDofClient才能使用Actor消息 //创建9个机器人加入匹配 机器人的UserID为0 for (int i = 0; i < 9; i++) { Gamer robot = ComponentFactory.Create <Gamer, long>(0); await robot.AddComponent <MailBoxComponent>().AddLocation(); moba.AddGamerToMatchingQueue(robot); } }
public static async ETTask <FUI> Create() { await ETTask.CompletedTask; // 可以同步或者异步加载,异步加载需要搞个转圈圈,这里为了简单使用同步加载 // await ETModel.Game.Scene.GetComponent<FUIPackageComponent>().AddPackageAsync(FUIType.Login); ETModel.Game.Scene.GetComponent <FUIPackageComponent>().AddPackage(FUIType.Shop); FUI fui = ComponentFactory.Create <FUI, GObject>(UIPackage.CreateObject(FUIType.Shop, FUIType.Shop)); fui.Name = FUIType.Shop; // 挂上窗口组件就成了窗口 FUIWindowComponent fWindow = fui.AddComponent <FUIWindowComponent>(); fWindow.Modal = true; fWindow.Show(); // 这里可以根据UI逻辑的复杂度关联性,拆分成多个小组件来写逻辑,这里逻辑比较简单就只使用一个组件了 fui.AddComponent <FUIShopComponent>(); return(fui); }
public static async ETVoid MoveTo(this UnitPathComponent self, Vector3 target) { if ((self.Target - target).magnitude < 0.1f) { return; } self.Target = target; Unit unit = self.GetParent <Unit>(); PathfindingComponent pathfindingComponent = Game.Scene.GetComponent <PathfindingComponent>(); self.ABPath = ComponentFactory.Create <ABPathWrap, Vector3, Vector3>(unit.Position, new Vector3(target.x, target.y, target.z)); pathfindingComponent.Search(self.ABPath); Log.Debug($"find result: {self.ABPath.Result.ListToString()}"); self.CancellationTokenSource?.Cancel(); self.CancellationTokenSource = new CancellationTokenSource(); await self.MoveAsync(self.ABPath.Result); self.CancellationTokenSource.Dispose(); self.CancellationTokenSource = null; }
public UI Create(Scene scene, string type, GameObject parent) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); resourcesComponent.LoadBundle($"{CardHelper.ATLAS_NAME}.unity3d"); resourcesComponent.LoadBundle($"{HandCardsComponent.HANDCARD_NAME}.unity3d"); resourcesComponent.LoadBundle($"{HandCardsComponent.PLAYCARD_NAME}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject room = UnityEngine.Object.Instantiate(bundleGameObject); room.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(room); ui.AddComponent <LandlordsRoomComponent>(); return(ui); } catch (Exception e) { Log.Error(e.ToStr()); return(null); } }
protected override async void Run(Session session, C2G_FriendApply message, Action <G2C_FriendApply> reply) { G2C_FriendApply response = new G2C_FriendApply(); response.IsSuccess = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); if (message.Type == 1) { RequestInfo relationInfo = ComponentFactory.Create <RequestInfo>(); relationInfo._InvAccountID = message.Account; relationInfo._ByInvAccountID = message.ByAccount; relationInfo._Note = message.Note; relationInfo._ProcessDate = message.ProcessDate; relationInfo._RequestDate = message.RequestDate; relationInfo._RequestMessage = message.RequestMessage; relationInfo._StateCode = message.StateCode; await dBProxyComponent.Save(relationInfo); response.IsSuccess = true; response.Message = "好友申请创建成功"; response.RequestInfoid = relationInfo.Id; Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友申请创建成功"); } reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表获取或创建失败,服务器维护中。"; ReplyError(response, e, reply); } }
/// <summary> /// 文字提示 /// </summary> /// <param name="message"></param> /// <param name="showTime"></param> public async void ShowTips(string message, int showTime = 1) { if (isAct) { return; } GameObject gameObject = LoadUIAsset(UIType.UITip); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UITip, gameObject, false); var tip = ui.AddComponent <UITipCpt>(); Game.Scene.GetComponent <UIComponent>().Add(ui); isAct = true; var _tra = tip.GetParent <UI>().GameObject.transform; _tra.Find("Text").GetComponent <Text>().text = message; _tra.localPosition = new Vector3(0, 300, 0); tipTweener = _tra.DOLocalMoveY(0, 0.3f); tipTweener.Restart(); await Task.Delay(showTime * 1000); _tra.DOLocalMoveY(300, 0.3f); await Task.Delay(300); Game.Scene.GetComponent <UIComponent>().Remove(UIType.UITip); isAct = false; }
private async void RegisterAccount(string account, string code) { ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address); Session realmSession = ComponentFactory.Create <Session, ETModel.Session>(session); G2C_MobileLogin_Res mobileLogin = (G2C_MobileLogin_Res)await realmSession.Call( new C2G_MobileLogin_Req() { Mobile = account, VerifyCode = code, }); if (mobileLogin.Error != 0) { Game.PopupComponent.ShowMessageBox(mobileLogin.Message); return; } if (!PlayerPrefs.HasKey("Account01")) { PlayerPrefs.SetString("Account01", $"{mobileLogin.Account}-{mobileLogin.Token}"); } else { if (!PlayerPrefs.HasKey("Account02")) { PlayerPrefs.SetString("Account02", $"{mobileLogin.Account}-{mobileLogin.Token}"); } else { if (!PlayerPrefs.HasKey("Account03")) { PlayerPrefs.SetString("Account03", $"{mobileLogin.Account}-{mobileLogin.Token}"); } } } LoginRequest(mobileLogin.Account, mobileLogin.Token); }
protected override async void Run(Session session, C2G_AddWalletData message, Action <G2C_AddWalletData> reply) { G2C_AddWalletData response = new G2C_AddWalletData(); response.IsSuccess = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); WalletData WalletData = ComponentFactory.Create <WalletData>(); WalletData._AccountID = message.AccountID; WalletData._PayPassword = message.PayPassword; WalletData._Diamond = message.Diamond; WalletData._Point = message.Point; WalletData._CreateDate = message.CreateDate; WalletData._WalletType = message.WalletType; WalletData._OffList = new List <int>(); WalletData._State = 1; WalletData._WalletTipList = new List <int>(); await dBProxyComponent.Save(WalletData); await dBProxyComponent.SaveLog(WalletData); response.IsSuccess = true; reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "创建钱包数据失败,服务器维护中。"; ReplyError(response, e, reply); } }
private async void OnClickPressTest() { Session sessionWrap = null; try { //IPEndPoint connetEndPoint = NetworkHelper.ToIPEndPoint(GlobalConfigComponent.Instance.GlobalProto.Address); IPEndPoint connetEndPoint = NetworkHelper.ToIPEndPoint("10.224.4.158:10006"); ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint); sessionWrap = ComponentFactory.Create <Session, ETModel.Session>(session); G2C_PressTest g2C_PressTest = (G2C_PressTest)await sessionWrap.Call(new C2G_PressTest()); UINetLoadingComponent.closeNetLoading(); sessionWrap.Dispose(); } catch (Exception e) { sessionWrap?.Dispose(); Log.Error(e); } }
private async ETTask CreateAccount(string PhoneNum, string UserName, string Password) { DBProxyComponent db = Game.Scene.GetComponent <DBProxyComponent>(); Account account = ComponentFactory.Create <Account>(); account.PhoneNum = PhoneNum.ToNum(); account.UserName = UserName; account.Password = Password; await db.Save(account); UserDB userDb = ComponentFactory.Create <UserDB>(); userDb.PhoneNum = PhoneNum.ToNum(); userDb.AddComponent <UserBaseComponent>().UserName = UserName; userDb.AddComponent <SettingInfoComponent>(); await db.Save(userDb); }
private void CreateTaskItem(List <TaskInfo> taskInfoList) { GameObject obj = null; for (int i = 0; i < taskInfoList.Count; ++i) { if (i < taskItemList.Count) { obj = taskItemList[i]; } else { obj = GameObject.Instantiate(taskItem); obj.transform.SetParent(grid.transform); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UITaskItemComponent>(); taskItemList.Add(obj); uiList.Add(ui); } uiList[i].GetComponent <UITaskItemComponent>().SetTaskItemInfo(taskInfoList[i]); } }
/// <summary> /// 显示战绩榜 /// </summary> private void ShowGameRank() { //Grid.transform.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1); GameObject obj = null; SetUIState(1, 0); for (int i = 0; i < gameRankList.Count; ++i) { if (i < gameItemList.Count) { gameItemList[i].SetActive(true); obj = gameItemList[i]; } else { obj = GameObject.Instantiate(RankItem); obj.transform.SetParent(Grid.transform); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; gameItemList.Add(obj); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UIRankItemComponent>(); gameUiList.Add(ui); if (i >= ownGame) { gameUiList[i].GetComponent <UIRankItemComponent>().SetGameItem(gameRankList[i], i + 1); } else { gameUiList[i].GetComponent <UIRankItemComponent>().SetGameItem(gameRankList[i], i); } } } SetMoreHide(gameRankList.Count, gameItemList); }