예제 #1
0
        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);
            }
        }
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        /// <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;
        }
예제 #5
0
        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);
        }
예제 #6
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);
            }
        }
예제 #7
0
        public static async ETVoid CreateJoystickUI(ETTaskCompletionSource <UI> tcs)
        {
            try
            {
                AssetRequest assetRequest = Assets.LoadAssetAsync("Assets/Bundles/UI/" + UIType.UIAttackDirstick + ".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.UIAttackDirstick, 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 static async Task SaveTotalMiltary(this FiveStarRoom fiveStarRoom)
        {
            //只有房卡才记录 如果一局小局信息都没有 就不用保存大局录像了
            if (fiveStarRoom.RoomType != RoomType.RoomCard || fiveStarRoom.ParticularMiltarys.Count == 0)
            {
                return;
            }
            Miltary miltary = ComponentFactory.Create <Miltary>();

            miltary.MiltaryId      = FiveStarRoomComponent.Ins.GetMiltaryVideoId(); //大局录像Id
            miltary.RoomNumber     = fiveStarRoom.RoomId;                           //房号
            miltary.FriendCircleId = fiveStarRoom.FriendsCircleId;                  //所属亲友ID
            miltary.ToyGameId      = ToyGameId.CardFiveStar;                        //游戏类型
            miltary.Time           = TimeTool.GetCurrenTimeStamp();                 //当前时间
            miltary.PlayerInofs    = fiveStarRoom.GetMiltaryPlayerInfo();           //玩家信息
            for (int i = 0; i < miltary.PlayerInofs.Count; i++)
            {
                miltary.PlayerUserIds.Add(miltary.PlayerInofs[i].UserId);
            }
            fiveStarRoom.SaveMiltarySmallInfo(miltary.MiltaryId);
            await FiveStarRoomComponent.Ins.SaveVideo(miltary);//存储大局战绩到数据库

            miltary.Dispose();
        }
예제 #9
0
        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 <GamerComponent>();
                ui.AddComponent <UIRoomComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e.ToStr());
                return(null);
            }
        }
        protected override async void Run(Session session, C2G_AddWalletRecord message, Action <G2C_AddWalletRecord> reply)
        {
            G2C_AddWalletRecord response = new G2C_AddWalletRecord();

            response.IsSuccess = false;
            try
            {
                DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>();


                WalletRecord WalletData = ComponentFactory.Create <WalletRecord>();

                WalletData._Amount      = message.Amount;
                WalletData._CreateDate  = message.CreateDate;
                WalletData._DealDate    = message.DealDate;
                WalletData._Info        = message.Info;
                WalletData._SpeiaclInfo = message.SpeiaclInfo;
                WalletData._State       = message.State;
                WalletData._Type        = message.Type;
                WalletData._WalletID    = message.WalletID;

                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);
            }
        }
예제 #11
0
        public static ChessPlayer CopySerialize(ChessPlayer player)
        {
            ChessPlayer newPlayer;

            if (_playerPool.Count > 0)
            {
                newPlayer = _playerPool[0];
                _playerPool.RemoveAt(0);
            }
            else
            {
                newPlayer = ComponentFactory.Create <ChessPlayer>();
            }
            newPlayer.SeatIndex    = player.SeatIndex;
            newPlayer.User         = player.User;
            newPlayer.PlayCards    = player.PlayCards;
            newPlayer.OperateInfos = player.OperateInfos;
            newPlayer.HandCards    = player.HandCards;
            newPlayer.NowHP        = player.NowHP;
            newPlayer.WinCount     = player.WinCount;
            newPlayer.DefeatCount  = player.DefeatCount;

            return(newPlayer);
        }
예제 #12
0
        public static async ETVoid MoveTo(this MapPathComponent 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);

            self.CancellationTokenSource?.Cancel();
            self.CancellationTokenSource = new CancellationTokenSource();

            //ToTo 同步到服务端 本身坐标和向量坐标
            await self.MoveAsync(self.ABPath.Result);

            self.CancellationTokenSource.Dispose();
            self.CancellationTokenSource = null;
        }
예제 #13
0
        //连接网关
        public async ETTask <G2C_GateLogin> ConnectGate(string gateAddress, long key, int loginType)
        {
            try
            {
                // 创建一个ETModel层的Session,并且保存到ETModel.SessionComponent中
                ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(gateAddress); //连接网关
                ETModel.Game.Scene.GetComponent <ETModel.SessionComponent>().Session = gateSession;
                // 创建一个ETHotfix层的Session, 并且保存到ETHotfix.SessionComponent中
                Game.Scene.GetComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(gateSession);
                gateSession.GetComponent <SessionCallbackComponent>().DisposeCallback += GateSessionDisposeCallback;
                G2C_GateLogin g2CLoginGate = (G2C_GateLogin)await SessionComponent.Instance.Session.Call(new C2G_GateLogin()
                {
                    Key = key
                });

                Log.Debug(SessionComponent.Instance.Session.Id.ToString());
                return(g2CLoginGate);
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
        //创建房卡匹房间
        public static MatchRoom Create(RepeatedField <int> roomConfigLists, long toyGameId, int roomId, int friendsCircleId, long userJewelNum, IResponse iResponse)
        {
            int  needJeweNumCount = 0;
            int  number           = 0;
            bool isAADeductJewel  = false;

            //效验房间配置正不正确 不正确的值会修改为默认值  会赋值 需要的钻石数 和房间配置人数
            if (!RoomConfigIntended.IntendedRoomConfigParameter(roomConfigLists, toyGameId, ref needJeweNumCount,
                                                                ref number, ref isAADeductJewel))
            {
                iResponse.Message = "房间配置表错误";
                return(null);
            }

            //如果是亲友圈房间亲友圈的 圈主钻石数要大于100
            if (friendsCircleId > 0 && userJewelNum < 100)
            {
                iResponse.Message = "亲友圈主人钻石不足100";
                return(null);
            }
            if (userJewelNum < needJeweNumCount)
            {
                iResponse.Message = "钻石不足";
                return(null);
            }
            MatchRoom       matchRoom  = ComponentFactory.Create <MatchRoom>();
            MatchRoomConfig roomConfig = MatchRoomConfigFactory.Create(number, roomId, toyGameId, roomConfigLists);

            matchRoom.RoomId           = roomId;
            matchRoom.FriendsCircleId  = friendsCircleId;
            matchRoom.RoomConfig       = roomConfig;
            matchRoom.RoomType         = RoomType.RoomCard;
            matchRoom.NeedJeweNumCount = needJeweNumCount;
            matchRoom.IsAADeductJewel  = isAADeductJewel;
            return(matchRoom);
        }
예제 #16
0
        /// <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);
        }
예제 #17
0
        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]);
            }
        }
예제 #18
0
        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 > 0)
                {
                    Actor_CreateUnits actorCreateUnits = new Actor_CreateUnits();
                    Unit[]            units            = Game.Scene.GetComponent <UnitComponent>().GetAll();
                    foreach (Unit u in units)
                    {
                        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);
            }
        }
예제 #19
0
        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);
        }
예제 #20
0
        public void Awake()
        {
            var res = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            res.LoadBundle(UIType.UserCenterWin.StringToAB());

            var gameObject = res.GetAsset(UIType.UserCenterWin.StringToAB(), UIType.UserCenterWin);

            this.panelGo = (GameObject)UnityEngine.Object.Instantiate(gameObject, this.Parent.Parent.GameObject.transform);

            UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UserCenterWin, this.panelGo, false);

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

            _panelTweener = panelGo.transform.GetChild(1).DOScale(Vector3.one, 0.3f).Pause().SetEase(Ease.OutBack)
                            .SetAutoKill(false);

            this.ReferenceCollector = this.panelGo.GetComponent <ReferenceCollector>();

            this.ReferenceCollector.Get <GameObject>("CloseBtn").Get <Button>().onClick.AddListener(Close);
            this.ReferenceCollector.Get <GameObject>("mask").Get <Button>().onClick.AddListener(Close);
            ButtonGroup = AddComponent <ButtonGroup>();

            UserInfoCpt = AddComponent <UserCenter_UserInfoCpt>();
            var userInfoBtn = ReferenceCollector.Get <GameObject>("PersonInfoToggle");

            UserInfoCpt.Awake(userInfoBtn, ReferenceCollector.Get <GameObject>("PersonView"), ButtonGroup);

            ReportCpt = AddComponent <Setting_ReportCpt>();
            var reportBtn = ReferenceCollector.Get <GameObject>("ReportToggle");

            ReportCpt.Awake(reportBtn, ReferenceCollector.Get <GameObject>("ReportView"), ButtonGroup);


            ButtonGroup.OnButtonClick(UserInfoCpt);
        }
예제 #21
0
        protected override async void Run(Session session, C2G_AddGroup message, Action <G2C_AddGroup> reply)
        {
            G2C_AddGroup response = new G2C_AddGroup();

            response.IsSuccess = false;
            try
            {
                DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>();

                var acounts = await dBProxyComponent.Query <RelationInfo>("{'_Account' : '" + message.Account + "'}");

                if (acounts.Count > 0)
                {
                    RelationInfo info = acounts[0] as RelationInfo;
                    if (message.Type == 1)
                    {
                        //添加群组信息
                        GroupInfo relationInfo = ComponentFactory.Create <GroupInfo>();
                        relationInfo._UseState      = 1;
                        relationInfo._Name          = message.Name;
                        relationInfo._InvAccountID  = message.Account;
                        relationInfo._GroupPassword = message.GroupPassword;
                        relationInfo._GroupNumber   = relationInfo.Id;
                        relationInfo._CreateDate    = message.CreateDate;
                        relationInfo._ColorCode     = message.ColorCode;

                        await dBProxyComponent.Save(relationInfo);

                        info._GroupList.Insert(0, relationInfo.Id);

                        response.IsSuccess = true;
                        response.Message   = "添加群组信息成功";
                    }
                    else if (message.Type == 2)
                    {
                        var acountsG = await dBProxyComponent.Query <GroupInfo>("{'_id' : '" + message.DGroupid + "'}");

                        //改变群组信息的UserState 如果这个群组内有好友,则将好友群组编号设为0
                        GroupInfo groupInfo = acountsG[0] as GroupInfo;
                        groupInfo._UseState = 2;

                        var acountsF = await dBProxyComponent.Query <FriendInfo>("{'_GroupNumber' : '" + message.DGroupNumber + "'}");

                        foreach (FriendInfo item in acountsF)
                        {
                            item._GroupNumber = 0;

                            await dBProxyComponent.Save(item);
                        }

                        response.IsSuccess = true;
                        response.Message   = "删除群组信息成功";
                    }
                    await dBProxyComponent.Save(info);
                }
                else
                {
                    response.IsSuccess = false;
                    response.Message   = "好友列表数据库异常";
                    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);
            }
        }
 public static SkillSmallProBar Create(GObject go)
 {
     return(ComponentFactory.Create <SkillSmallProBar, GObject>(go));
 }
 public static SkillSmallProBar CreateInstance()
 {
     return(ComponentFactory.Create <SkillSmallProBar, GObject>(CreateGObject()));
 }
예제 #24
0
        protected override async void Run(Session session, C2G_FriendList message, Action <G2C_FriendList> reply)
        {
            G2C_FriendList response = new G2C_FriendList();

            response.IsSuccess = false;
            try
            {
                DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>();


                var acounts = await dBProxyComponent.Query <RelationInfo>("{'_Account' : '" + message.Account + "'}");

                if (message.Type == 1)
                {
                    if (acounts.Count < 1)
                    {
                        RelationInfo relationInfo = ComponentFactory.Create <RelationInfo>();
                        relationInfo._InfoID       = message.InfoID;
                        relationInfo._AccountID    = message.Account;
                        relationInfo._BlackIDList  = new List <long>();
                        relationInfo._ChatRoomList = new List <long>();
                        relationInfo._FriendIDList = new List <long>();
                        relationInfo._GroupList    = new List <long>();

                        await dBProxyComponent.Save(relationInfo);

                        response.IsSuccess = true;
                        response.Message   = "好友列表创建成功";

                        Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表创建成功");
                    }
                }
                else if (message.Type == 2)
                {
                    if (acounts.Count > 0)
                    {
                        RelationInfo item = acounts[0] as RelationInfo;
                        response.BlackIDList  = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._BlackIDList);
                        response.ChatRoomList = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._ChatRoomList);
                        response.FriendIDList = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._FriendIDList);
                        response.GroupList    = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._GroupList);

                        response.IsSuccess = true;
                        response.Message   = "好友列表获取成功";
                    }
                    else
                    {
                        response.IsSuccess = false;
                        response.Message   = "好友列表数据库异常";
                        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);
            }
        }
예제 #25
0
        public async Task OnLoginPhone(string phone, string code, string token)
        {
            Session sessionWrap = null;

            try
            {
                UINetLoadingComponent.showNetLoading();

                //IPEndPoint connetEndPoint = NetworkHelper.ToIPEndPoint(GlobalConfigComponent.Instance.GlobalProto.Address);

                IPEndPoint      connetEndPoint = ToIPEndPointWithYuMing(NetConfig.getInstance().getServerPort());
                ETModel.Session session        = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
                sessionWrap = ComponentFactory.Create <Session, ETModel.Session>(session);
                R2C_PhoneLogin r2CLogin = (R2C_PhoneLogin)await sessionWrap.Call(new C2R_PhoneLogin()
                {
                    Phone = phone, Code = code, Token = token, MachineId = PlatformHelper.GetMacId(), ChannelName = PlatformHelper.GetChannelName(), ClientVersion = PlatformHelper.GetVersionName()
                });

                //R2C_PhoneLogin r2CLogin = (R2C_PhoneLogin)await sessionWrap.Call(new C2R_PhoneLogin() { Phone = phone, Code = code, Token = token, MachineId = "1234", ChannelName = "jav", ClientVersion = "1.1.0" });
                sessionWrap.Dispose();

                UINetLoadingComponent.closeNetLoading();

                if (r2CLogin.Error != ErrorCode.ERR_Success)
                {
                    ToastScript.createToast(r2CLogin.Message);

                    if (r2CLogin.Error == ErrorCode.ERR_TokenError)
                    {
                        PlayerPrefs.SetString("Phone", "");
                        PlayerPrefs.SetString("Token", "");

                        panel_phoneLogin.transform.localScale = new Vector3(1, 1, 1);
                    }

                    if (r2CLogin.Message.CompareTo("用户不存在") == 0)
                    {
                        panel_phoneLogin.transform.localScale = new Vector3(1, 1, 1);
                    }

                    return;
                }

                UINetLoadingComponent.showNetLoading();


                //connetEndPoint = NetworkHelper.ToIPEndPoint(r2CLogin.Address);
                //connetEndPoint = NetConfig.getInstance().ToIPEndPointWithYuMing();
                string[] temp = r2CLogin.Address.Split(':');
                connetEndPoint = ToIPEndPointWithYuMing(Convert.ToInt32(temp[1]));
                ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
                Game.Scene.GetComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(session);
                ETModel.Game.Scene.GetComponent <ETModel.SessionComponent>().Session = gateSession;

                G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate()
                {
                    Key = r2CLogin.Key
                });

                UINetLoadingComponent.closeNetLoading();

                ToastScript.createToast("登录成功");
                //挂心跳包
                Game.Scene.GetComponent <SessionComponent>().Session.AddComponent <HeartBeatComponent>();
                UINetLoadingComponent.closeNetLoading();
                await getAllData();

                isLoginSuccess = true;

                {
                    // 保存Phone
                    PlayerPrefs.SetString("Phone", phone);

                    // 保存Token
                    PlayerPrefs.SetString("Token", r2CLogin.Token);
                }

                Game.Scene.GetComponent <PlayerInfoComponent>().uid = g2CLoginGate.Uid;

                PlayerInfoComponent.Instance.SetShopInfoList(g2CLoginGate.ShopInfoList);
                PlayerInfoComponent.Instance.SetBagInfoList(g2CLoginGate.BagList);
                PlayerInfoComponent.Instance.ownIcon = g2CLoginGate.ownIcon;

                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"UIMain.unity3d");

                await resourcesComponent.LoadBundleAsync($"Image_Main.unity3d");

                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIMain);
                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UILogin);
            }
            catch (Exception e)
            {
                sessionWrap?.Dispose();
                Log.Error(e);
            }
        }
예제 #26
0
        public async void OnLogin()
        {
            try
            {
                //
                IPEndPoint connetEndPoint = NetworkHelper.ToIPEndPoint(GlobalConfigComponent.Instance.GlobalProto.Address);


                // 创建一个ETModel层的Session
                ETModel.Session session      = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
                Session         realmSession = ComponentFactory.Create <Session, ETModel.Session>(session);

                /*
                 * 请求登录
                 */
                R2C_Login r2CLogin = (R2C_Login)await realmSession.Call(new C2R_Login()
                {
                    Account  = this.account.GetComponent <InputField>().text,
                    Password = this.password.GetComponent <InputField>().text
                }
                                                                        );

                realmSession.Dispose();

                /*
                 * 处理登录结果
                 */
                if (r2CLogin.Error == ErrorCode.ERR_Success)
                {
                    connetEndPoint = NetworkHelper.ToIPEndPoint(r2CLogin.Address);
                    // 创建一个ETModel层的Session,并且保存到ETModel.SessionComponent中"111.230.133.20:10002"
                    ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
                    ETModel.Game.Scene.AddComponent <ETModel.SessionComponent>().Session = gateSession;

                    // 创建一个ETHotfix层的Session, 并且保存到ETHotfix.SessionComponent中
                    Game.Scene.AddComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(gateSession);

                    G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate()
                    {
                        Key = r2CLogin.Key
                    });

                    Log.Info("登陆gate成功!");

                    // 创建Player
                    Player          player          = ETModel.ComponentFactory.CreateWithId <Player>(g2CLoginGate.PlayerId);
                    PlayerComponent playerComponent = ETModel.Game.Scene.GetComponent <PlayerComponent>();
                    playerComponent.MyPlayer = player;

                    Game.Scene.GetComponent <UIComponent>().Create(UIType.UILobby);
                    Game.Scene.GetComponent <UIComponent>().Remove(UIType.UILogin);
                }
                else if (r2CLogin.Error == ErrorCode.ERR_AccountInvaild)
                {
                    Game.Scene.GetComponent <UIAlertsGrayComponent>().CreateAlertWin("账号中有不法字符~", onAlertCbLoginFail, "好的~");
                }
                else if (r2CLogin.Error == ErrorCode.ERR_PasswordInvaild)
                {
                    Game.Scene.GetComponent <UIAlertsGrayComponent>().CreateAlertWin("密码中有不法字符~", onAlertCbLoginFail, "好的~");
                }
                else if (r2CLogin.Error == ErrorCode.ERR_PasswordIncorrect)
                {
                    Game.Scene.GetComponent <UIAlertsGrayComponent>().CreateAlertWin("密码不正确~", onAlertCbLoginFail, "好的~");
                }
                else if (r2CLogin.Error == ErrorCode.ERR_AccountNotExist)
                {
                    UIAlertsGrayComponent l = Game.Scene.GetComponent <UIAlertsGrayComponent>();
                    Game.Scene.GetComponent <UIAlertsGrayComponent>().CreateAlertWin("账号不存在~", onAlertCbLoginFail, "好的~");
                }
                else if (r2CLogin.Error == ErrorCode.ERR_DataBaseRead)
                {
                    Game.Scene.GetComponent <UIAlertsGrayComponent>().CreateAlertWin("网络异常~", onAlertCbLoginFail, "好的~");
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #27
0
        public async Task OnThirdLogin(string third_id, string name, string head)
        {
            //加锁
            if (isLogining)
            {
                return;
            }
            isLogining = true;

            Session sessionWrap = null;

            try
            {
                UINetLoadingComponent.showNetLoading();

                // IPEndPoint connetEndPoint = NetworkHelper.ToIPEndPoint(GlobalConfigComponent.Instance.GlobalProto.Address);
                IPEndPoint connetEndPoint = NetConfig.getInstance().ToIPEndPointWithYuMing();
#if Localhost
                connetEndPoint = NetworkHelper.ToIPEndPoint("10.224.5.74:10002");
#endif
                ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
                sessionWrap = ComponentFactory.Create <Session, ETModel.Session>(session);

                name = name.Replace("'", "*");
                R2C_ThirdLogin r2CLogin = (R2C_ThirdLogin)await sessionWrap.Call(new C2R_ThirdLogin()
                {
                    Third_Id = third_id, MachineId = PlatformHelper.GetMacId(), ChannelName = PlatformHelper.GetChannelName(), ClientVersion = PlatformHelper.GetVersionName(), Name = name, Head = head
                });

                sessionWrap.Dispose();

                UINetLoadingComponent.closeNetLoading();

                if (r2CLogin.Error != ErrorCode.ERR_Success)
                {
                    ToastScript.createToast(r2CLogin.Message);
                    return;
                }

                UINetLoadingComponent.showNetLoading();

                // connetEndPoint = NetworkHelper.ToIPEndPoint(r2CLogin.Address);
//                connetEndPoint = NetConfig.getInstance().ToIPEndPointWithYuMing();
                string[] temp = r2CLogin.Address.Split(':');
                connetEndPoint = ToIPEndPointWithYuMing(Convert.ToInt32(temp[1]));

                // connetEndPoint = NetworkHelper.ToIPEndPoint(r2CLogin.Address);

#if Localhost
                connetEndPoint = NetworkHelper.ToIPEndPoint("10.224.5.74:10002");
#endif

                ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
                Game.Scene.GetComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(session);
                ETModel.Game.Scene.GetComponent <ETModel.SessionComponent>().Session = gateSession;

                // Log.Info("gateSession:"+ connetEndPoint.ToString());
                G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate()
                {
                    Key = r2CLogin.Key
                });

                ToastScript.createToast("登录成功");
                //挂心跳包
                Game.Scene.GetComponent <SessionComponent>().Session.AddComponent <HeartBeatComponent>();
                UINetLoadingComponent.closeNetLoading();

                await getAllData();

                isLoginSuccess = true;

                Game.Scene.GetComponent <PlayerInfoComponent>().uid = g2CLoginGate.Uid;

                PlayerInfoComponent.Instance.SetShopInfoList(g2CLoginGate.ShopInfoList);
                PlayerInfoComponent.Instance.SetBagInfoList(g2CLoginGate.BagList);
                PlayerInfoComponent.Instance.ownIcon = g2CLoginGate.ownIcon;

                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIMain);
                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UILogin);
                isLogining = false;
            }
            catch (Exception e)
            {
                sessionWrap?.Dispose();
                Log.Error("OnThirdLogin:" + e);
                isLogining = false;
            }
        }
예제 #28
0
 public static one_confirm CreateInstance()
 {
     return(ComponentFactory.Create <one_confirm, GObject>(CreateGObject()));
 }
예제 #29
0
        public static async ETVoid OnLoginAsync(string account, string password)
        {
            try
            {
                // 显示加载UI
                ETModel.Game.EventSystem.Run(ETModel.EventIdType.ShowLoadingUI);
                // 如果正在登录,就驳回登录请求,为了双重保险,点下登录按钮后,收到服务端响应之前将不能再点击
                if (isLogining)
                {
                    FinalRun();
                    return;
                }

                isLogining = true;

                if (account == "" || password == "")
                {
                    Game.EventSystem.Run(EventIdType.ShowLoginInfo, "账号或密码不能为空");
                    FinalRun();
                    return;
                }

                // 创建一个ETModel层的Session
                ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>()
                                          .Create(GlobalConfigComponent.Instance.GlobalProto.Address);
                // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息
                Session realmSession = ComponentFactory.Create <Session, ETModel.Session>(session);

                Game.EventSystem.Run(EventIdType.ShowLoginInfo, "登陆中。。。");
                // 发送登录请求,账号,密码均为传来的参数
                R2C_Login r2CLogin = (R2C_Login)await realmSession.Call(new C2R_Login()
                {
                    Account = account, Password = password
                });

                if (r2CLogin.Error == ErrorCode.ERR_LoginError)
                {
                    Game.EventSystem.Run(EventIdType.ShowLoginInfo, "登录失败,账号或密码错误");
                    FinalRun();
                    return;
                }

                //释放realmSession
                realmSession.Dispose();

                // 创建一个ETModel层的Session,并且保存到ETModel.SessionComponent中
                ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(r2CLogin.Address);
                ETModel.Game.Scene.AddComponent <ETModel.SessionComponent>().Session = gateSession;

                // 创建一个ETHotfix层的Session, 并且保存到ETHotfix.SessionComponent中
                Game.Scene.AddComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(gateSession);

                // 增加客户端断线处理组件
                Game.Scene.GetComponent <SessionComponent>().Session.AddComponent <SessionOfflineComponent>();

                // 增加心跳组件
                ETModel.Game.Scene.GetComponent <ETModel.SessionComponent>().Session.AddComponent <HeartBeatComponent>();

                await SessionComponent.Instance.Session.Call(new C2G_LoginGate()
                {
                    Key = r2CLogin.Key
                });

                Game.EventSystem.Run(EventIdType.ShowLoginInfo, "登录成功");

                // 创建Player(抽象化的玩家),这里的id是数据库里的账号id
                Player          player          = ETModel.ComponentFactory.CreateWithId <Player>(r2CLogin.PlayerId);
                PlayerComponent playerComponent = ETModel.Game.Scene.GetComponent <PlayerComponent>();
                playerComponent.MyPlayer = player;

                // 登录完成
                Game.EventSystem.Run(EventIdType.LoginFinish);

                // 测试消息有成员是class类型
                // G2C_PlayerInfo g2CPlayerInfo = (G2C_PlayerInfo) await SessionComponent.Instance.Session.Call(new C2G_PlayerInfo());
                // Debug.Log("测试玩家信息为" + g2CPlayerInfo.Message);
                FinalRun();
            }
            catch (Exception e)
            {
                Log.Error(e);
                FinalRun();
            }
        }
예제 #30
0
 public static one_confirm Create(GObject go)
 {
     return(ComponentFactory.Create <one_confirm, GObject>(go));
 }