Esempio n. 1
0
        /// <summary>
        /// 服务器通知添加一个角色信息
        /// </summary>
        /// <param name="kuaFuRoleData"></param>
        /// <returns></returns>
        public int UpdateRoleData(KuaFuRoleData kuaFuRoleData, int roleId = 0)
        {
            int result = (int)KuaFuRoleStates.None;

            if (kuaFuRoleData == null)
            {
                return(result);
            }

            roleId = kuaFuRoleData.RoleId;
            KuaFuRoleData oldKuaFuRoleData, newKuaFuRoleData;

            lock (Mutex)
            {
                if (kuaFuRoleData.State == KuaFuRoleStates.None)
                {
                    RemoveRoleData(kuaFuRoleData.RoleId);
                    return((int)KuaFuRoleStates.None);
                }

                RoleId2RoleDataDict[roleId]   = kuaFuRoleData;
                RoleId2KuaFuStateDict[roleId] = (int)kuaFuRoleData.State;
            }

            return(result);
        }
Esempio n. 2
0
        public int UpdateRoleData(KuaFuRoleData kuaFuRoleData, int roleId = 0)
        {
            int result = 0;
            int result2;

            if (kuaFuRoleData == null)
            {
                result2 = result;
            }
            else
            {
                roleId = kuaFuRoleData.RoleId;
                lock (this.Mutex)
                {
                    if (kuaFuRoleData.State == KuaFuRoleStates.None)
                    {
                        this.RemoveRoleData(kuaFuRoleData.RoleId);
                        return(0);
                    }
                    this.RoleId2RoleDataDict[roleId]   = kuaFuRoleData;
                    this.RoleId2KuaFuStateDict[roleId] = (int)kuaFuRoleData.State;
                }
                result2 = result;
            }
            return(result2);
        }
Esempio n. 3
0
        /// <summary>
        /// 服务器通知添加一个角色信息
        /// </summary>
        /// <param name="kuaFuRoleData"></param>
        /// <returns></returns>
        public int UpdateRoleData(KuaFuRoleData kuaFuRoleData, int roleId = 0)
        {
            int result = (int)KuaFuRoleStates.None;

            if (kuaFuRoleData == null)
            {
                return(result);
            }

            roleId = kuaFuRoleData.RoleId;
            KuaFuRoleData oldKuaFuRoleData, newKuaFuRoleData;
            int           oldRoleId = 0, gameType = 0, groupIndex = 0;
            int           oldServerId = 0;

            lock (Mutex)
            {
                if (kuaFuRoleData.State == KuaFuRoleStates.None)
                {
                    RemoveRoleData(kuaFuRoleData.RoleId);
                    return((int)KuaFuRoleStates.None);
                }

                string userId = kuaFuRoleData.UserId;

                //如果此帐号下其他角色在跨服游戏中,记下相关信息,稍后处理
                if (UserId2RoleDataDict.TryGetValue(userId, out oldKuaFuRoleData) && oldKuaFuRoleData.RoleId != roleId)
                {
                    oldRoleId   = oldKuaFuRoleData.RoleId;
                    gameType    = oldKuaFuRoleData.GameType;
                    groupIndex  = oldKuaFuRoleData.GroupIndex;
                    oldServerId = oldKuaFuRoleData.ServerId;
                }

                if (oldKuaFuRoleData != kuaFuRoleData)
                {
                    newKuaFuRoleData            = (KuaFuRoleData)kuaFuRoleData;
                    UserId2RoleDataDict[userId] = newKuaFuRoleData;
                    RoleId2RoleDataDict[roleId] = newKuaFuRoleData;

                    //更新状态缓存
                    //UserId2KuaFuStateDict[userId] = (int)kuaFuRoleData.State;
                    RoleId2KuaFuStateDict[roleId] = (int)kuaFuRoleData.State;
                }
            }

            if (oldRoleId > 0)
            {
                //如果此帐号下其他角色在跨服游戏中,修改其状态
                RoleChangeState(oldServerId, oldRoleId, (int)KuaFuRoleStates.None);
                RemoveRoleData(oldRoleId);
            }

            return(result);
        }
Esempio n. 4
0
        public KuaFuRoleData GetKuaFuRoleData(int serverId, int roleId)
        {
            KuaFuRoleData kuaFuRoleData = null;

            if (RoleIdKuaFuRoleDataDict.TryGetValue(KuaFuRoleKey.Get(serverId, roleId), out kuaFuRoleData) && kuaFuRoleData.State != KuaFuRoleStates.None)
            {
                return(kuaFuRoleData);
            }

            return(null);
        }
Esempio n. 5
0
        public int NotifyChangeState(KuaFuRoleData kuaFuRoleData)
        {
            try
            {
                EnqueueCacheItem(KuaFuEventTypes.RoleStateChange, kuaFuRoleData);
            }
            catch (System.Exception ex)
            {
                return(-1);
            }

            return(0);
        }
Esempio n. 6
0
        public KuaFuRoleData GetKuaFuRoleData(int serverId, int roleId)
        {
            KuaFuRoleData kuaFuRoleData = null;
            KuaFuRoleData result;

            if (this.RoleIdKuaFuRoleDataDict.TryGetValue(KuaFuRoleKey.Get(serverId, roleId), out kuaFuRoleData) && kuaFuRoleData.State != KuaFuRoleStates.None)
            {
                result = kuaFuRoleData;
            }
            else
            {
                result = null;
            }
            return(result);
        }
Esempio n. 7
0
        public int NotifyAddRole(KuaFuRoleData kuaFuRoleData)
        {
            int result = -1;

            try
            {
                EnqueueCacheItem(KuaFuEventTypes.RoleStateChange, kuaFuRoleData);
            }
            catch (System.Exception ex)
            {
                return(-1);
            }

            return(result);
        }
Esempio n. 8
0
        public int ChangeRoleState(int roleId, KuaFuRoleStates state, bool noWait = false)
        {
            int result = StdErrorCode.Error_Operation_Faild;

            ITianTiService kuaFuService  = null;
            KuaFuRoleData  kuaFuRoleData = null;
            int            serverId      = ClientInfo.ServerId;

            lock (Mutex)
            {
                if (RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData))
                {
                    serverId = kuaFuRoleData.ServerId;
                }
            }

            kuaFuService = GetKuaFuService(noWait);
            if (null != kuaFuService)
            {
                try
                {
                    result = kuaFuService.RoleChangeState(serverId, roleId, (int)state);
                    if (result >= 0)
                    {
                        lock (Mutex)
                        {
                            if (RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData))
                            {
                                kuaFuRoleData.State = (KuaFuRoleStates)result;
                            }
                        }

                        if (null != kuaFuRoleData)
                        {
                            UpdateRoleData(kuaFuRoleData);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    result = StdErrorCode.Error_Server_Internal_Error;
                }
            }

            return(result);
        }
Esempio n. 9
0
        public int UpdateRoleData(KuaFuRoleData kuaFuRoleData, int roleId = 0)
        {
            int result = 0;
            int result2;

            if (kuaFuRoleData == null)
            {
                result2 = result;
            }
            else
            {
                roleId = kuaFuRoleData.RoleId;
                int oldRoleId   = 0;
                int oldServerId = 0;
                lock (this.Mutex)
                {
                    if (kuaFuRoleData.State == KuaFuRoleStates.None)
                    {
                        this.RemoveRoleData(kuaFuRoleData.RoleId);
                        return(0);
                    }
                    string        userId = kuaFuRoleData.UserId;
                    KuaFuRoleData oldKuaFuRoleData;
                    if (this.UserId2RoleDataDict.TryGetValue(userId, out oldKuaFuRoleData) && oldKuaFuRoleData.RoleId != roleId)
                    {
                        oldRoleId = oldKuaFuRoleData.RoleId;
                        int gameType   = oldKuaFuRoleData.GameType;
                        int groupIndex = oldKuaFuRoleData.GroupIndex;
                        oldServerId = oldKuaFuRoleData.ServerId;
                    }
                    if (oldKuaFuRoleData != kuaFuRoleData)
                    {
                        this.UserId2RoleDataDict[userId]   = kuaFuRoleData;
                        this.RoleId2RoleDataDict[roleId]   = kuaFuRoleData;
                        this.RoleId2KuaFuStateDict[roleId] = (int)kuaFuRoleData.State;
                    }
                }
                if (oldRoleId > 0)
                {
                    this.RoleChangeState(oldServerId, oldRoleId, 0);
                    this.RemoveRoleData(oldRoleId);
                }
                result2 = result;
            }
            return(result2);
        }
Esempio n. 10
0
        public KuaFuRoleData GetKuaFuRoleDataFromServer(int serverId, int roleId)
        {
            KuaFuRoleData kuaFuRoleData = null;
            IKuaFuService kuaFuService  = this.GetKuaFuService(false);

            if (null != kuaFuService)
            {
                try
                {
                    kuaFuRoleData = kuaFuService.GetKuaFuRoleData(serverId, roleId);
                    this.UpdateRoleData(kuaFuRoleData, 0);
                }
                catch (Exception ex)
                {
                    kuaFuRoleData = null;
                }
            }
            return(kuaFuRoleData);
        }
Esempio n. 11
0
        public int ChangeRoleState(int roleId, KuaFuRoleStates state, bool noWait = false)
        {
            int           result        = -11;
            KuaFuRoleData kuaFuRoleData = null;
            int           serverId      = this.ClientInfo.ServerId;

            lock (this.Mutex)
            {
                if (this.RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData))
                {
                    serverId = kuaFuRoleData.ServerId;
                }
            }
            IKuaFuService kuaFuService = this.GetKuaFuService(noWait);

            if (null != kuaFuService)
            {
                try
                {
                    result = kuaFuService.RoleChangeState(serverId, roleId, (int)state);
                    if (result >= 0)
                    {
                        lock (this.Mutex)
                        {
                            if (this.RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData))
                            {
                                kuaFuRoleData.State = (KuaFuRoleStates)result;
                            }
                        }
                        if (null != kuaFuRoleData)
                        {
                            this.UpdateRoleData(kuaFuRoleData, 0);
                        }
                    }
                }
                catch (Exception ex)
                {
                    result = -11003;
                }
            }
            return(result);
        }
Esempio n. 12
0
        public bool KuaFuLogin(KuaFuServerLoginData kuaFuServerLoginData)
        {
            HuanYingSiYuanFuBenData huanYingSiYuanFuBenData = this.GetKuaFuFuBenData((int)kuaFuServerLoginData.GameId);

            if (huanYingSiYuanFuBenData != null && huanYingSiYuanFuBenData.State < GameFuBenState.End)
            {
                if (huanYingSiYuanFuBenData.ServerId == GameManager.ServerId)
                {
                    if (huanYingSiYuanFuBenData.RoleDict.ContainsKey(kuaFuServerLoginData.RoleId))
                    {
                        KuaFuRoleData kuaFuRoleData = this.GetKuaFuRoleDataFromServer(kuaFuServerLoginData.ServerId, kuaFuServerLoginData.RoleId);
                        if (kuaFuRoleData.GameId == huanYingSiYuanFuBenData.GameId)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 13
0
        /// <summary>
        /// 从服务器获取角色数据
        /// </summary>
        /// <param name="serverId"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public KuaFuRoleData GetKuaFuRoleDataFromServer(int serverId, int roleId)
        {
            KuaFuRoleData  kuaFuRoleData = null;
            ITianTiService kuaFuService  = GetKuaFuService();

            if (null != kuaFuService)
            {
                try
                {
                    kuaFuRoleData = (KuaFuRoleData)kuaFuService.GetKuaFuRoleData(serverId, roleId);
                    UpdateRoleData(kuaFuRoleData); //更新
                }
                catch (System.Exception ex)
                {
                    kuaFuRoleData = null;
                }
            }

            return(kuaFuRoleData);
        }
Esempio n. 14
0
        public int GetRoleExtendData(int serverId, int roleId, int dataType)
        {
            KuaFuRoleData kuaFuRoleData = null;
            int           result;

            if (!this.RoleIdKuaFuRoleDataDict.TryGetValue(KuaFuRoleKey.Get(serverId, roleId), out kuaFuRoleData))
            {
                result = 0;
            }
            else if (dataType == 0)
            {
                int roleCount = 0;
                if (kuaFuRoleData.State == KuaFuRoleStates.SignUp)
                {
                    roleCount = 1;
                }
                if (kuaFuRoleData.GameId > 0)
                {
                    TianTiFuBenData tianTiFuBenData;
                    if (this.TianTiFuBenDataDict.TryGetValue(kuaFuRoleData.GameId, out tianTiFuBenData))
                    {
                        if (tianTiFuBenData.State < GameFuBenState.Start)
                        {
                            roleCount = tianTiFuBenData.GetFuBenRoleCount();
                        }
                        else
                        {
                            this.RemoveRoleFromFuBen(kuaFuRoleData.GameId, roleId);
                            this.RoleChangeState(serverId, roleId, 0);
                            roleCount = 0;
                        }
                    }
                }
                result = roleCount;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Esempio n. 15
0
        /// <summary>
        /// 验证角色是否有本服务器的跨服活动
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="gameType"></param>
        /// <param name="gameId"></param>
        /// <returns>是否有效</returns>
        public bool KuaFuLogin(KuaFuServerLoginData kuaFuServerLoginData)
        {
            TianTiFuBenData TianTiFuBenData = GetKuaFuFuBenData((int)kuaFuServerLoginData.GameId);

            if (null != TianTiFuBenData && TianTiFuBenData.State < GameFuBenState.End)
            {
                if (TianTiFuBenData.ServerId == ClientInfo.ServerId)
                {
                    if (TianTiFuBenData.RoleDict.ContainsKey(kuaFuServerLoginData.RoleId))
                    {
                        KuaFuRoleData kuaFuRoleData = GetKuaFuRoleDataFromServer(kuaFuServerLoginData.ServerId, kuaFuServerLoginData.RoleId);
                        if (kuaFuRoleData.GameId == TianTiFuBenData.GameId)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Esempio n. 16
0
        public bool KuaFuLogin(KuaFuServerLoginData kuaFuServerLoginData)
        {
            YongZheZhanChangFuBenData YongZheZhanChangFuBenData = this.GetKuaFuFuBenData((int)kuaFuServerLoginData.GameId);

            if (YongZheZhanChangFuBenData != null && YongZheZhanChangFuBenData.State < GameFuBenState.End)
            {
                if (YongZheZhanChangFuBenData.ServerId == GameManager.ServerId)
                {
                    if (YongZheZhanChangFuBenData.RoleDict.ContainsKey(kuaFuServerLoginData.RoleId))
                    {
                        kuaFuServerLoginData.FuBenSeqId = YongZheZhanChangFuBenData.SequenceId;
                        KuaFuRoleData kuaFuRoleData = this.GetKuaFuRoleDataFromServer(kuaFuServerLoginData.ServerId, kuaFuServerLoginData.RoleId);
                        if (kuaFuRoleData.GameId == YongZheZhanChangFuBenData.GameId)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 17
0
        /// <summary>
        /// 获取角色相关的扩展数据
        /// </summary>
        /// <param name="serverId"></param>
        /// <param name="roleId"></param>
        /// <param name="dataType"></param>
        /// <returns></returns>
        public object GetRoleExtendData(int serverId, int roleId, int dataType)
        {
            KuaFuRoleData kuaFuRoleData = null;

            if (!RoleIdKuaFuRoleDataDict.TryGetValue(KuaFuRoleKey.Get(serverId, roleId), out kuaFuRoleData))
            {
                return(null);
            }

            if (dataType == (int)KuaFuRoleExtendDataTypes.GameFuBenRoleCount)
            {
                int roleCount = 0;
                if (kuaFuRoleData.State == KuaFuRoleStates.SignUp)
                {
                    roleCount = 1;
                }

                if (kuaFuRoleData.GameId > 0)
                {
                    TianTiFuBenData tianTiFuBenData;
                    if (TianTiFuBenDataDict.TryGetValue(kuaFuRoleData.GameId, out tianTiFuBenData))
                    {
                        if (tianTiFuBenData.State < GameFuBenState.Start)
                        {
                            roleCount = tianTiFuBenData.GetFuBenRoleCount();
                        }
                        else
                        {
                            RemoveRoleFromFuBen(kuaFuRoleData.GameId, roleId);
                            RoleChangeState(serverId, roleId, (int)KuaFuRoleStates.None);
                            roleCount = 0;
                        }
                    }
                }

                return(roleCount);
            }

            return(null);
        }
Esempio n. 18
0
        private int ChangeRoleState(KuaFuRoleData kuaFuRoleData, KuaFuRoleStates state)
        {
            int result = -1;

            try
            {
                IKuaFuClient  kuaFuClient = null;
                KuaFuRoleData roleData    = null;
                int           oldGameId   = 0;
                lock (kuaFuRoleData)
                {
                    kuaFuRoleData.Age++;
                    kuaFuRoleData.State = state;
                    if (state == KuaFuRoleStates.None && kuaFuRoleData.GameId > 0)
                    {
                        oldGameId = kuaFuRoleData.GameId;
                    }

                    roleData = (KuaFuRoleData)kuaFuRoleData;
                }

                if (oldGameId > 0)
                {
                    RemoveRoleFromFuBen(oldGameId, kuaFuRoleData.RoleId);
                }

                if (null != roleData)
                {
                    AsyncDataItem evItem = new AsyncDataItem(KuaFuEventTypes.RoleStateChange, kuaFuRoleData);
                    ClientAgentManager.Instance().PostAsyncEvent(kuaFuRoleData.ServerId, GameType, evItem);
                }
            }
            catch (System.Exception ex)
            {
                return(-1);
            }

            return(result);
        }
Esempio n. 19
0
        private int ChangeRoleState(HuanYingSiYuanAgent huanYingSiYuanAgent, KuaFuRoleData kuaFuRoleData, KuaFuRoleStates state)
        {
            int result = -1;

            try
            {
                IKuaFuClient  kuaFuClient = null;
                KuaFuRoleData roleData    = null;
                int           oldGameId   = 0;
                lock (kuaFuRoleData)
                {
                    kuaFuRoleData.Age++;
                    kuaFuRoleData.State = state;
                    if (state == KuaFuRoleStates.None && kuaFuRoleData.GameId > 0)
                    {
                        oldGameId = kuaFuRoleData.GameId;
                    }

                    kuaFuClient = huanYingSiYuanAgent.KuaFuClient;
                    roleData    = (KuaFuRoleData)kuaFuRoleData;
                }

                if (oldGameId > 0)
                {
                    RemoveRoleFromFuBen(oldGameId, kuaFuRoleData.RoleId);
                }

                if (null != kuaFuClient && null != roleData)
                {
                    result = huanYingSiYuanAgent.NotifyChangeState(kuaFuRoleData);
                }
            }
            catch (System.Exception ex)
            {
                return(-1);
            }

            return(result);
        }
Esempio n. 20
0
        private bool CanAddFuBenRole(TianTiFuBenData tianTiFuBenData, KuaFuRoleData kuaFuRoleData)
        {
            if (tianTiFuBenData.RoleDict.Count == 0)
            {
                return(true);
            }

            KuaFuFuBenRoleData existRole = tianTiFuBenData.RoleDict.Values.FirstOrDefault();
            long rolePairKey             = MakeRolePairKey(kuaFuRoleData.RoleId, existRole.RoleId);

            int fightCount;

            lock (RolePairFightCountDict)
            {
                if (!RolePairFightCountDict.TryGetValue(rolePairKey, out fightCount) || fightCount < Persistence.MaxRolePairFightCount)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 21
0
        private bool CanAddFuBenRole(TianTiFuBenData tianTiFuBenData, KuaFuRoleData kuaFuRoleData)
        {
            bool result;

            if (tianTiFuBenData.RoleDict.Count == 0)
            {
                result = true;
            }
            else
            {
                KuaFuFuBenRoleData existRole = tianTiFuBenData.RoleDict.Values.FirstOrDefault <KuaFuFuBenRoleData>();
                long rolePairKey             = this.MakeRolePairKey(kuaFuRoleData.RoleId, existRole.RoleId);
                lock (this.RolePairFightCountDict)
                {
                    int fightCount;
                    if (!this.RolePairFightCountDict.TryGetValue(rolePairKey, out fightCount) || fightCount < this.Persistence.MaxRolePairFightCount)
                    {
                        return(true);
                    }
                }
                result = false;
            }
            return(result);
        }
Esempio n. 22
0
        private bool AssignGameFuben(KuaFuRoleData kuaFuRoleData, RangeKey range, DateTime now)
        {
            DateTime           stateEndTime       = now.AddSeconds((double)this.EnterGameSecs);
            TianTiFuBenData    tianTiFuBenData    = null;
            KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData
            {
                ServerId = kuaFuRoleData.ServerId,
                RoleId   = kuaFuRoleData.RoleId
            };
            List <KuaFuRoleData> updateRoleDataList = new List <KuaFuRoleData>();

            if (!this.ProcessTianTiFuBenDataDict.TryGetValue(range, out tianTiFuBenData))
            {
                tianTiFuBenData = new TianTiFuBenData();
                this.ProcessTianTiFuBenDataDict.Add(range, tianTiFuBenData);
            }
            else if (!this.CanAddFuBenRole(tianTiFuBenData, kuaFuRoleData))
            {
                return(true);
            }
            int  roleCount = tianTiFuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData);
            bool result;

            if (roleCount < Consts.TianTiRoleCountTotal)
            {
                result = true;
            }
            else
            {
                try
                {
                    int  kfSrvId       = 0;
                    int  gameId        = this.Persistence.GetNextGameId();
                    bool createSuccess = ClientAgentManager.Instance().AssginKfFuben(this.GameType, (long)gameId, roleCount, out kfSrvId);
                    if (createSuccess)
                    {
                        tianTiFuBenData.ServerId = kfSrvId;
                        tianTiFuBenData.GameId   = gameId;
                        tianTiFuBenData.EndTime  = Global.NowTime.AddMinutes(8.0);
                        this.AddGameFuBen(tianTiFuBenData);
                        this.Persistence.LogCreateTianTiFuBen(tianTiFuBenData.GameId, tianTiFuBenData.ServerId, 0, roleCount);
                        foreach (KuaFuFuBenRoleData role in tianTiFuBenData.RoleDict.Values)
                        {
                            KuaFuRoleKey  key = KuaFuRoleKey.Get(role.ServerId, role.RoleId);
                            KuaFuRoleData kuaFuRoleDataTemp;
                            if (this.RoleIdKuaFuRoleDataDict.TryGetValue(key, out kuaFuRoleDataTemp))
                            {
                                kuaFuRoleDataTemp.UpdateStateTime(tianTiFuBenData.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                            }
                        }
                        tianTiFuBenData.State = GameFuBenState.Start;
                        this.NotifyFuBenRoleEnterGame(tianTiFuBenData);
                        this.ProcessTianTiFuBenDataDict.Remove(range);
                        return(true);
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                }
                result = false;
            }
            return(result);
        }
Esempio n. 23
0
        public void EventCallBackHandler(AsyncDataItem item)
        {
            try
            {
                int      eventType = (int)item.EventType;
                object[] args      = item.Args;
                int      num       = eventType;
                switch (num)
                {
                case 0:
                case 1:
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                        }
                    }
                    break;

                case 2:
                case 4:
                case 5:
                    break;

                case 3:
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                            YongZheZhanChangFuBenData fuBenData = this.GetKuaFuFuBenData(kuaFuRoleData.GameId);
                            if (fuBenData != null && fuBenData.State == GameFuBenState.Start)
                            {
                                KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData
                                {
                                    RoleId   = kuaFuRoleData.RoleId,
                                    GameType = kuaFuRoleData.GameType,
                                    GameId   = (long)kuaFuRoleData.GameId,
                                    EndTicks = kuaFuRoleData.StateEndTicks
                                };
                                kuaFuServerLoginData.ServerId = this.ClientInfo.ServerId;
                                KuaFuServerInfo kuaFuServerInfo;
                                if (KuaFuManager.getInstance().TryGetValue(fuBenData.ServerId, out kuaFuServerInfo))
                                {
                                    kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                                    kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                                }
                                GameTypes gameType = (GameTypes)kuaFuRoleData.GameType;
                                switch (gameType)
                                {
                                case GameTypes.YongZheZhanChang:
                                    this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 27);
                                    break;

                                case GameTypes.KuaFuBoss:
                                    this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 31);
                                    break;

                                default:
                                    if (gameType == GameTypes.KingOfBattle)
                                    {
                                        this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 39);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    break;

                case 6:
                    if (args.Length == 1)
                    {
                        LangHunLingYuBangHuiDataEx data = args[0] as LangHunLingYuBangHuiDataEx;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyBangHuiDataGameEvent(data), 35);
                    }
                    break;

                case 7:
                    if (args.Length == 1)
                    {
                        LangHunLingYuCityDataEx data2 = args[0] as LangHunLingYuCityDataEx;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityDataGameEvent(data2), 35);
                    }
                    break;

                case 8:
                    if (args.Length == 1)
                    {
                        Dictionary <int, List <int> > data3 = args[0] as Dictionary <int, List <int> >;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyOtherCityListGameEvent(data3), 35);
                    }
                    break;

                case 9:
                    if (args.Length == 1)
                    {
                        List <LangHunLingYuKingHist> data4 = args[0] as List <LangHunLingYuKingHist>;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerHistGameEvent(data4), 35);
                    }
                    break;

                case 10:
                    if (args.Length == 2)
                    {
                        int rid         = (int)args[0];
                        int admirecount = (int)args[1];
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerAdmireGameEvent(rid, admirecount), 35);
                    }
                    break;

                default:
                    if (num == 9997)
                    {
                        if (GMCommands.EnableGMSetAllServerTime && item.Args.Length == 4)
                        {
                            string[] a = new string[item.Args.Length];
                            for (int i = 0; i < a.Length; i++)
                            {
                                a[i] = (item.Args[i] as string);
                                if (string.IsNullOrEmpty(a[i]))
                                {
                                    return;
                                }
                            }
                            if (a[0] == "-settime")
                            {
                                GMCommands.GMSetTime(null, a, false);
                            }
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
        }
Esempio n. 24
0
        private bool AssignGameFuben(KuaFuRoleData kuaFuRoleData, ServerLoadContext context, long waitSecs1, long waitSecs2, DateTime now)
        {
            int                     roleCount               = 0;
            DateTime                stateEndTime            = now.AddSeconds(EnterGameSecs);
            HuanYingSiYuanAgent     huanYingSiYuanAgent     = null;
            HuanYingSiYuanFuBenData huanYingSiYuanFuBenData = null;
            IKuaFuClient            kuaFuClient             = null;

            KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData()
            {
                ServerId  = kuaFuRoleData.ServerId,
                RoleId    = kuaFuRoleData.RoleId,
                ZhanDouLi = HuanYingSiYuanGameData.GetZhanDouLi(kuaFuRoleData.GameData),
            };

            List <KuaFuRoleData> updateRoleDataList = new List <KuaFuRoleData>();

            try
            {
                //先检测是否有需要补充人的队伍
                foreach (var fuBenData in ShotOfRolesFuBenDataDict.Values)
                {
                    //分组编号要相等
                    if (fuBenData.CanRemove())
                    {
                        RemoveGameFuBen(fuBenData);
                    }
                    else if (fuBenData.CanEnter(kuaFuRoleData.GroupIndex, waitSecs1, waitSecs2))
                    {
                        if (ServerId2KuaFuClientAgent.TryGetValue(fuBenData.ServerId, out huanYingSiYuanAgent) && huanYingSiYuanAgent.IsAlive)
                        {
                            roleCount = fuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, GameFuBenRoleCountChangedHandler);
                            if (roleCount > 0)
                            {
                                huanYingSiYuanFuBenData = fuBenData;
                                break;
                            }
                        }
                    }
                }

                if (null == huanYingSiYuanFuBenData)
                {
                    //按负载状态在一个跨服活动服务器上分配一个新的游戏副本,并加入
                    LinkedListNode <KuaFuServerGameConfig> node = context.IdelActiveServerQueue.First;
                    int count = context.IdelActiveServerQueue.Count;
                    for (int i = 0; i < count && node != null; i++)
                    {
                        KuaFuServerGameConfig srv = node.Value;
                        LinkedListNode <KuaFuServerGameConfig> next = node.Next;

                        if (ServerId2KuaFuClientAgent.TryGetValue(srv.ServerId, out huanYingSiYuanAgent) && huanYingSiYuanAgent.IsAlive)
                        {
                            int serverLoad = huanYingSiYuanAgent.GetAliveGameFuBenCount();
                            if (serverLoad < srv.Capacity && serverLoad <= context.ServerLoadAvg)
                            {
                                try
                                {
                                    huanYingSiYuanFuBenData = Persistence.CreateHysyGameFuBen(huanYingSiYuanAgent, kuaFuRoleData.GroupIndex, 1);
                                    if (huanYingSiYuanFuBenData != null)
                                    {
                                        AddGameFuBen(huanYingSiYuanFuBenData, huanYingSiYuanAgent);
                                        roleCount = huanYingSiYuanFuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, GameFuBenRoleCountChangedHandler);
                                        if (roleCount > 0)
                                        {
                                            context.AlivedGameFuBenCount++;
                                            context.CalcServerLoadAvg();
                                            break;
                                        }
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                    huanYingSiYuanAgent.MaxActiveTicks = 0;
                                }
                            }
                            else
                            {
                                context.IdelActiveServerQueue.Remove(node);
                                if (serverLoad < srv.Capacity)
                                {
                                    context.IdelActiveServerQueue.AddLast(node);
                                }
                            }
                        }

                        node = next;
                    }
                }

                if (huanYingSiYuanFuBenData != null && roleCount > 0)
                {
                    if (roleCount == 1)
                    {
                        huanYingSiYuanFuBenData.EndTime = now; //第一个人进入时,重置副本创建时间
                    }

                    if (huanYingSiYuanFuBenData.State == GameFuBenState.Wait)
                    {
                        if (roleCount == Consts.HuanYingSiYuanRoleCountTotal)
                        {
                            List <KuaFuFuBenRoleData> roleList = huanYingSiYuanFuBenData.SortFuBenRoleList();
                            foreach (var role in roleList)
                            {
                                KuaFuRoleData kuaFuRoleDataTemp;
                                KuaFuRoleKey  key = KuaFuRoleKey.Get(role.ServerId, role.RoleId);
                                if (RoleIdKuaFuRoleDataDict.TryGetValue(key, out kuaFuRoleDataTemp))
                                {
                                    kuaFuRoleDataTemp.UpdateStateTime(huanYingSiYuanFuBenData.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                                }
                            }

                            huanYingSiYuanFuBenData.State = GameFuBenState.Start;
                            NotifyFuBenRoleEnterGame(huanYingSiYuanFuBenData);
                        }
                        else
                        {
                            kuaFuRoleData.UpdateStateTime(huanYingSiYuanFuBenData.GameId, KuaFuRoleStates.SignUpWaiting, kuaFuRoleData.StateEndTicks);
                            NotifyFuBenRoleCount(huanYingSiYuanFuBenData);
                        }
                    }
                    else if (huanYingSiYuanFuBenData.State == GameFuBenState.Start)
                    {
                        kuaFuRoleData.UpdateStateTime(huanYingSiYuanFuBenData.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                        NotifyFuBenRoleEnterGame(huanYingSiYuanFuBenData);
                    }
                }
                else
                {
                    //如果分配失败,则返回false,本轮不在尝试分配
                    return(false);
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }

            return(false);
        }
Esempio n. 25
0
        public void EventCallBackHandler(AsyncDataItem item)
        {
            try
            {
                int      eventType = (int)item.EventType;
                object[] args      = item.Args;
                int      num       = eventType;
                if (num <= 9996)
                {
                    switch (num)
                    {
                    case 0:
                    case 1:
                        if (args.Length == 1)
                        {
                            KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                            if (null != kuaFuRoleData)
                            {
                                this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                            }
                        }
                        break;

                    case 2:
                        if (args.Length == 2)
                        {
                            int rid   = (int)args[0];
                            int count = (int)args[1];
                            this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuFuBenRoleCountEvent(rid, count), this.SceneType);
                        }
                        break;

                    case 3:
                        if (args.Length == 1)
                        {
                            KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                            if (null != kuaFuRoleData)
                            {
                                this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                                HuanYingSiYuanFuBenData huanYingSiYuanFuBenData = this.GetKuaFuFuBenData(kuaFuRoleData.GameId);
                                if (huanYingSiYuanFuBenData != null && huanYingSiYuanFuBenData.State == GameFuBenState.Start)
                                {
                                    KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData
                                    {
                                        RoleId   = kuaFuRoleData.RoleId,
                                        GameType = kuaFuRoleData.GameType,
                                        GameId   = (long)kuaFuRoleData.GameId,
                                        EndTicks = kuaFuRoleData.StateEndTicks
                                    };
                                    kuaFuServerLoginData.ServerId = this.ClientInfo.ServerId;
                                    KuaFuServerInfo kuaFuServerInfo;
                                    if (KuaFuManager.getInstance().TryGetValue(huanYingSiYuanFuBenData.ServerId, out kuaFuServerInfo))
                                    {
                                        kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                                        kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                                    }
                                    else
                                    {
                                        LogManager.WriteLog(LogTypes.Error, string.Format("服务器列表中无法找到serverid={0}的IP和端口信息", huanYingSiYuanFuBenData.ServerId), null, true);
                                    }
                                    this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), this.SceneType);
                                }
                            }
                        }
                        break;

                    default:
                        if (num == 9996)
                        {
                            if (args.Length == 1)
                            {
                                GMCmdData data = args[0] as GMCmdData;
                                GVoiceManager.getInstance().UpdateGVoicePriority(data, true);
                            }
                        }
                        break;
                    }
                }
                else if (num != 10015)
                {
                    if (num == 10029)
                    {
                        KuaFuLueDuoNtfEnterData data2 = args[0] as KuaFuLueDuoNtfEnterData;
                        KuaFuLueDuoManager.getInstance().HandleNtfEnterEvent(data2);
                    }
                }
                else if (args != null && args.Length == 2)
                {
                    KuaFuManager.getInstance().UpdateServerInfoList(args[1] as List <KuaFuServerInfo>);
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
        }
Esempio n. 26
0
        private bool AssignGameFuben(KuaFuRoleData kuaFuRoleData, RangeKey range, DateTime now)
        {
            int             roleCount       = 0;
            DateTime        stateEndTime    = now.AddSeconds(EnterGameSecs);
            TianTiFuBenData tianTiFuBenData = null;

            KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData()
            {
                ServerId = kuaFuRoleData.ServerId,
                RoleId   = kuaFuRoleData.RoleId,
            };

            List <KuaFuRoleData> updateRoleDataList = new List <KuaFuRoleData>();

            if (!ProcessTianTiFuBenDataDict.TryGetValue(range, out tianTiFuBenData))
            {
                tianTiFuBenData = new TianTiFuBenData();
                ProcessTianTiFuBenDataDict.Add(range, tianTiFuBenData);
            }
            else if (!CanAddFuBenRole(tianTiFuBenData, kuaFuRoleData))
            {
                return(true);
            }

            roleCount = tianTiFuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData);
            if (roleCount < Consts.TianTiRoleCountTotal)
            {
                return(true);
            }

            try
            {
                int  kfSrvId       = 0;
                int  gameId        = Persistence.GetNextGameId();
                bool createSuccess = ClientAgentManager.Instance().AssginKfFuben(GameType, gameId, roleCount, out kfSrvId);
                if (createSuccess)
                {
                    tianTiFuBenData.ServerId = kfSrvId;
                    tianTiFuBenData.GameId   = gameId;
                    tianTiFuBenData.EndTime  = Global.NowTime.AddMinutes(Consts.TianTiGameFuBenMaxExistMinutes);
                    AddGameFuBen(tianTiFuBenData);

                    Persistence.LogCreateTianTiFuBen(tianTiFuBenData.GameId, tianTiFuBenData.ServerId, 0, roleCount);

                    foreach (var role in tianTiFuBenData.RoleDict.Values)
                    {
                        KuaFuRoleData kuaFuRoleDataTemp;
                        KuaFuRoleKey  key = KuaFuRoleKey.Get(role.ServerId, role.RoleId);
                        if (RoleIdKuaFuRoleDataDict.TryGetValue(key, out kuaFuRoleDataTemp))
                        {
                            kuaFuRoleDataTemp.UpdateStateTime(tianTiFuBenData.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                        }
                    }

                    tianTiFuBenData.State = GameFuBenState.Start;
                    NotifyFuBenRoleEnterGame(tianTiFuBenData);

                    ProcessTianTiFuBenDataDict.Remove(range);
                }
                else
                {
                    //如果分配失败,则返回false,本轮不在尝试分配
                    return(false);
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }

            return(false);
        }
Esempio n. 27
0
        private bool AssignGameFuben(KuaFuRoleData kuaFuRoleData, long waitSecs1, long waitSecs2, DateTime now)
        {
            int      roleCount    = 0;
            DateTime stateEndTime = now.AddSeconds((double)this.EnterGameSecs);
            HuanYingSiYuanFuBenData selectFuben        = null;
            KuaFuFuBenRoleData      kuaFuFuBenRoleData = new KuaFuFuBenRoleData
            {
                ServerId  = kuaFuRoleData.ServerId,
                RoleId    = kuaFuRoleData.RoleId,
                ZhanDouLi = kuaFuRoleData.GameData.ZhanDouLi
            };

            try
            {
                foreach (HuanYingSiYuanFuBenData tmpFuben in this.ShotOfRolesFuBenDataDict.Values)
                {
                    if (tmpFuben.CanRemove())
                    {
                        this.RemoveGameFuBen(tmpFuben);
                    }
                    else if (tmpFuben.CanEnter(kuaFuRoleData.GroupIndex, waitSecs1, waitSecs2))
                    {
                        if (ClientAgentManager.Instance().IsAgentAlive(tmpFuben.ServerId))
                        {
                            roleCount = tmpFuben.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, new GameFuBenRoleCountChanged(this.GameFuBenRoleCountChangedHandler));
                            if (roleCount > 0)
                            {
                                selectFuben = tmpFuben;
                                break;
                            }
                        }
                    }
                }
                if (null == selectFuben)
                {
                    int gameId  = this.Persistence.GetNextGameId();
                    int kfSrvId = 0;
                    if (ClientAgentManager.Instance().AssginKfFuben(this.GameType, (long)gameId, 1, out kfSrvId))
                    {
                        selectFuben            = new HuanYingSiYuanFuBenData();
                        selectFuben.ServerId   = kfSrvId;
                        selectFuben.GameId     = gameId;
                        selectFuben.GroupIndex = kuaFuRoleData.GroupIndex;
                        selectFuben.EndTime    = Global.NowTime.AddMinutes(15.0);
                        this.AddGameFuBen(selectFuben);
                        roleCount = selectFuben.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, new GameFuBenRoleCountChanged(this.GameFuBenRoleCountChangedHandler));
                        this.Persistence.LogCreateHysyFuben(gameId, kfSrvId, 0, 1);
                    }
                }
                if (selectFuben != null && roleCount > 0)
                {
                    if (roleCount == 1)
                    {
                        selectFuben.EndTime = now;
                    }
                    if (selectFuben.State == GameFuBenState.Wait)
                    {
                        if (roleCount == Consts.HuanYingSiYuanRoleCountTotal)
                        {
                            List <KuaFuFuBenRoleData> roleList = selectFuben.SortFuBenRoleList();
                            foreach (KuaFuFuBenRoleData role in roleList)
                            {
                                KuaFuRoleKey  key = KuaFuRoleKey.Get(role.ServerId, role.RoleId);
                                KuaFuRoleData kuaFuRoleDataTemp;
                                if (this.RoleIdKuaFuRoleDataDict.TryGetValue(key, out kuaFuRoleDataTemp))
                                {
                                    kuaFuRoleDataTemp.UpdateStateTime(selectFuben.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                                }
                            }
                            selectFuben.State = GameFuBenState.Start;
                            this.NotifyFuBenRoleEnterGame(selectFuben);
                        }
                        else
                        {
                            kuaFuRoleData.UpdateStateTime(selectFuben.GameId, KuaFuRoleStates.SignUpWaiting, kuaFuRoleData.StateEndTicks);
                            this.NotifyFuBenRoleCount(selectFuben);
                        }
                    }
                    else if (selectFuben.State == GameFuBenState.Start)
                    {
                        kuaFuRoleData.UpdateStateTime(selectFuben.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                        this.NotifyFuBenRoleEnterGame(selectFuben);
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
            return(false);
        }
Esempio n. 28
0
        public void EventCallBackHandler(int eventType, params object[] args)
        {
            try
            {
                switch (eventType)
                {
                case (int)KuaFuEventTypes.NotifyWaitingRoleCount:
                {
                    if (args.Length == 2)
                    {
                        int rid   = (int)args[0];
                        int count = (int)args[1];
                        CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuFuBenRoleCountEvent(rid, count), SceneType);
                    }
                }
                break;

                case (int)KuaFuEventTypes.RoleSignUp:
                case (int)KuaFuEventTypes.RoleStateChange:
                {
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                        }
                    }
                }
                break;

                case (int)KuaFuEventTypes.UpdateAndNotifyEnterGame:
                {
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);

                            TianTiFuBenData TianTiFuBenData = GetKuaFuFuBenData(kuaFuRoleData.GameId);
                            if (null != TianTiFuBenData && TianTiFuBenData.State == GameFuBenState.Start)
                            {
                                KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData()
                                {
                                    RoleId   = kuaFuRoleData.RoleId,
                                    GameType = kuaFuRoleData.GameType,
                                    GameId   = kuaFuRoleData.GameId,
                                    EndTicks = kuaFuRoleData.StateEndTicks,
                                };

                                kuaFuServerLoginData.ServerId = ClientInfo.ServerId;
                                lock (Mutex)
                                {
                                    KuaFuServerInfo kuaFuServerInfo;
                                    if (ServerIdServerInfoDict.TryGetValue(TianTiFuBenData.ServerId, out kuaFuServerInfo))
                                    {
                                        kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                                        kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                                    }
                                }

                                CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), SceneType);
                            }
                        }
                    }
                }
                break;

                case (int)KuaFuEventTypes.ZhengBaSupport:
                {
                    ZhengBaSupportLogData data = args[0] as ZhengBaSupportLogData;
                    if (null != data && data.FromServerId != ClientInfo.ServerId)
                    {
                        CoreInterface.GetEventSourceInterface().fireEvent(new KFZhengBaSupportEvent(data), (int)SceneUIClasses.KFZhengBa);
                    }
                }
                break;

                case (int)KuaFuEventTypes.ZhengBaPkLog:
                {
                    if (args.Length == 1)
                    {
                        ZhengBaPkLogData log = args[0] as ZhengBaPkLogData;
                        if (log != null)
                        {
                            CoreInterface.GetEventSourceInterface().fireEvent(new KFZhengBaPkLogEvent(log), (int)SceneUIClasses.KFZhengBa);
                        }
                    }
                }
                break;

                case (int)KuaFuEventTypes.ZhengBaNtfEnter:
                {
                    ZhengBaNtfEnterData data = args[0] as ZhengBaNtfEnterData;
                    lock (Mutex)
                    {
                        KuaFuServerInfo kuaFuServerInfo;
                        if (ServerIdServerInfoDict.TryGetValue(data.ToServerId, out kuaFuServerInfo))
                        {
                            data.ToServerIp   = kuaFuServerInfo.Ip;
                            data.ToServerPort = kuaFuServerInfo.Port;
                        }
                        else
                        {
                            LogManager.WriteLog(LogTypes.Error, string.Format("KuaFuEventTypes.ZhengBaNtfEnter not find kfserver={0}", data.ToServerId));
                        }
                    }
                    CoreInterface.GetEventSourceInterface().fireEvent(new KFZhengBaNtfEnterEvent(data), (int)SceneUIClasses.KFZhengBa);
                }
                break;

                case (int)KuaFuEventTypes.ZhengBaMirrorFight:
                {
                    ZhengBaMirrorFightData data = args[0] as ZhengBaMirrorFightData;
                    CoreInterface.GetEventSourceInterface().fireEvent(new KFZhengBaMirrorFightEvent(data), (int)SceneUIClasses.KFZhengBa);
                }
                break;

                case (int)KuaFuEventTypes.ZhengBaButtetinJoin:
                {
                    ZhengBaBulletinJoinData data = args[0] as ZhengBaBulletinJoinData;
                    CoreInterface.GetEventSourceInterface().fireEvent(new KFZhengBaBulletinJoinEvent(data), (int)SceneUIClasses.KFZhengBa);
                }
                break;

                case (int)KuaFuEventTypes.CoupleArenaCanEnter:
                {
                    CoreInterface.GetEventSourceInterface().fireEvent(
                        new CoupleArenaCanEnterEvent(args[0] as CoupleArenaCanEnterData), (int)SceneUIClasses.CoupleArena);
                }
                break;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
        }
Esempio n. 29
0
 public int UpdateRoleData(KuaFuRoleData kuaFuRoleData, int roleId = 0)
 {
     return(0);
 }
Esempio n. 30
0
        public void EventCallBackHandler(int eventType, params object[] args)
        {
            try
            {
                switch (eventType)
                {
                case (int)KuaFuEventTypes.RoleSignUp:
                case (int)KuaFuEventTypes.RoleStateChange:
                {
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                        }
                    }
                }
                break;

                case (int)KuaFuEventTypes.UpdateAndNotifyEnterGame:
                {
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);

                            YongZheZhanChangFuBenData fuBenData = GetKuaFuFuBenData(kuaFuRoleData.GameId);
                            if (null != fuBenData && fuBenData.State == GameFuBenState.Start)
                            {
                                KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData()
                                {
                                    RoleId   = kuaFuRoleData.RoleId,
                                    GameType = kuaFuRoleData.GameType,
                                    GameId   = kuaFuRoleData.GameId,
                                    EndTicks = kuaFuRoleData.StateEndTicks,
                                };

                                kuaFuServerLoginData.ServerId = ClientInfo.ServerId;
                                lock (Mutex)
                                {
                                    KuaFuServerInfo kuaFuServerInfo;
                                    if (ServerIdServerInfoDict.TryGetValue(fuBenData.ServerId, out kuaFuServerInfo))
                                    {
                                        kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                                        kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                                    }
                                }

                                switch ((GameTypes)kuaFuRoleData.GameType)
                                {
                                case GameTypes.YongZheZhanChang:
                                    CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), (int)SceneUIClasses.YongZheZhanChang);
                                    break;

                                case GameTypes.KuaFuBoss:
                                    CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), (int)SceneUIClasses.KuaFuBoss);
                                    break;

                                case GameTypes.KingOfBattle:
                                    CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), (int)SceneUIClasses.KingOfBattle);
                                    break;
                                }
                            }
                        }
                    }
                }
                break;

                case (int)KuaFuEventTypes.UpdateLhlyBhData:
                {
                    if (args.Length == 1)
                    {
                        LangHunLingYuBangHuiDataEx data = args[0] as LangHunLingYuBangHuiDataEx;
                        CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyBangHuiDataGameEvent(data), (int)SceneUIClasses.LangHunLingYu);
                    }
                }
                break;

                case (int)KuaFuEventTypes.UpdateLhlyCityData:
                {
                    if (args.Length == 1)
                    {
                        LangHunLingYuCityDataEx data = args[0] as LangHunLingYuCityDataEx;
                        CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityDataGameEvent(data), (int)SceneUIClasses.LangHunLingYu);
                    }
                }
                break;

                case (int)KuaFuEventTypes.UpdateLhlyOtherCityList:
                {
                    if (args.Length == 1)
                    {
                        Dictionary <int, List <int> > data = args[0] as Dictionary <int, List <int> >;
                        CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyOtherCityListGameEvent(data), (int)SceneUIClasses.LangHunLingYu);
                    }
                }
                break;

                case (int)KuaFuEventTypes.UpdateLhlyCityOwnerList:
                {
                    if (args.Length == 1)
                    {
                        List <LangHunLingYuKingHist> data = args[0] as List <LangHunLingYuKingHist>;
                        CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerHistGameEvent(data), (int)SceneUIClasses.LangHunLingYu);
                    }
                }
                break;

                case (int)KuaFuEventTypes.UpdateLhlyCityOwnerAdmire:
                {
                    if (args.Length == 2)
                    {
                        int rid         = (int)args[0];
                        int admirecount = (int)args[1];
                        CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerAdmireGameEvent(rid, admirecount),
                                                                          (int)SceneUIClasses.LangHunLingYu);
                    }
                }
                break;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
        }