Exemplo n.º 1
0
 /// <summary>
 /// 玩家成员分组表
 /// </summary>
 /// <param name="cuser1"></param>
 /// <param name="cuser2"></param>
 /// <param name="isWin"></param>
 /// <param name="process"></param>
 public static void MemberGroupProcess(FightUser cuser1, FightUser cuser2, bool isWin, FightCombatProcess process)
 {
     GameUser user1 = new GameDataCacheSet<GameUser>().FindKey(cuser1.UserId);
     GameUser user2 = new GameDataCacheSet<GameUser>().FindKey(cuser2.UserId);
     if (user1 == null || user2 == null)
     {
         return;
     }
     var cacheSet = new ShareCacheStruct<MemberGroup>();
     MemberGroup memberGroup = new MemberGroup(Guid.NewGuid().ToString())
                                   {
                                       FastID = info.FastID,
                                       GuildIDA = cuser1.GuildID,
                                       GuildIDB = cuser2.GuildID,
                                       UserIDA = cuser1.UserId,
                                       UserIDB = cuser2.UserId,
                                       Win = isWin,
                                       CombatProcess = process,
                                       IsRemove = false,
                                   };
     cacheSet.Add(memberGroup, GameEnvironment.CacheGlobalPeriod);
 }
Exemplo n.º 2
0
        private static void AsyncDoCombat(FightUser cuser1, FightUser cuser2, FightCombatProcess process)
        {
            GameUser user1 = UserCacheGlobal.LoadOffline(cuser1.UserId); //new GameDataCacheSet<GameUser>().FindKey();
            GameUser user2 = UserCacheGlobal.LoadOffline(cuser2.UserId); // new GameDataCacheSet<GameUser>().FindKey(cuser2.UserId);
            if (user1 == null || user2 == null)
            {
                return;
            }
            decimal victory = 0;
            decimal failure = 0;
            var fightInfo = new ConfigCacheSet<GuildFightInfo>().FindKey(cuser1.CityID);
            if (fightInfo != null)
            {
                victory = fightInfo.Victory;
                failure = fightInfo.Failure;
            }
            ISingleCombat combater = CombatFactory.TriggerTournament(user1, user2);
            bool isWin = combater.Doing();
            if (isWin)
            {
                FightUserListCombat(cuser1, cuser2, true);
                process.WinUserId = user1.UserID;
                process.WinUserName = user1.NickName;
                process.FailUserId = user2.UserID;
                process.FailUserName = user2.NickName;
                process.WinObtainNum = (user1.UserLv * victory).ToInt();
                user1.ObtainNum = MathUtils.Addition(user1.ObtainNum, process.WinObtainNum);
                process.FailObtainNum = (user2.UserLv * failure).ToInt();
                user2.ObtainNum = MathUtils.Addition(user2.ObtainNum, process.FailObtainNum);
                user2.UserStatus = UserStatus.Normal;
            }
            else
            {
                FightUserListCombat(cuser2, cuser1, true);
                process.WinUserId = user2.UserID;
                process.WinUserName = user2.NickName;
                process.FailUserId = user1.UserID;
                process.FailUserName = user1.NickName;

                process.WinObtainNum = (user2.UserLv * victory).ToInt();
                user2.ObtainNum = MathUtils.Addition(user2.ObtainNum, process.WinObtainNum);
                process.FailObtainNum = (user1.UserLv * failure).ToInt();
                user1.ObtainNum = MathUtils.Addition(user1.ObtainNum, process.FailObtainNum);

                user1.UserStatus = UserStatus.Normal;
            }

            process.ProcessContainer = (CombatProcessContainer)combater.GetProcessResult();

            MemberGroupProcess(cuser1, cuser2, isWin, process);

            if (_combatProcessList != null) _combatProcessList.Add(process);
            //日志
            UserCombatLog log = new UserCombatLog();
            log.CombatLogID = Guid.NewGuid().ToString();
            log.UserID = cuser1.UserId;
            log.CityID = 0;
            log.PlotID = 0;
            log.NpcID = 0;
            log.CombatType = CombatType.Country;
            log.HostileUser = cuser2.UserId;
            log.IsWin = isWin;
            log.CombatProcess = JsonUtils.Serialize(process);
            log.CreateDate = DateTime.Now;
            var sender = DataSyncManager.GetDataSender();
            sender.Send(log);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 配对战斗
 /// </summary>
 private static void TriggerPairCombat(List<FightUser> mogemaUserList, List<FightUser> hashideUserList, ServerFightGroup fightGroup)
 {
     int combatCount = 0;
     if (mogemaUserList.Count > hashideUserList.Count)
     {
         combatCount = hashideUserList.Count;
     }
     else
     {
         combatCount = mogemaUserList.Count;
     }
     for (int i = 0; i < combatCount; i++)
     {
         FightCombatProcess process = new FightCombatProcess();
         process.stage = fightGroup.Stage;
         process.FastID = info.FastID;
         FightUser cuser1 = mogemaUserList[i];
         int toIndex = i + 1;
         FightUser cuser2 = toIndex < hashideUserList.Count ? hashideUserList[toIndex] : hashideUserList[0];
         if (cuser1 == null || cuser2 == null) continue;
         if (cuser1.UserId.Equals(cuser2.UserId)) continue;
         //cuser1.IsRemove = true;
         //cuser2.IsRemove = true;
         //配对状态
         TraceLog.ReleaseWriteFatal("触发战斗A公会:{0}名称:{1},B公会:{2}名称:{3}", cuser1.GuildID, cuser1.UserName, cuser2.GuildID, cuser2.UserName);
         AsyncDoCombat(cuser1, cuser2, process);
     }
     ServerFightGroupWinGuildID(fightGroup, info.FastID);
 }
Exemplo n.º 4
0
        protected override object this[string index]
		{
			get
			{
                #region
				switch (index)
				{
                    case "ID": return ID;
                    case "FastID": return FastID;
                    case "GuildIDA": return GuildIDA;
                    case "GuildIDB": return GuildIDB;
                    case "UserIDA": return UserIDA;
                    case "UserIDB": return UserIDB;
                    case "Win": return Win;
                    case "CombatProcess": return CombatProcess;
                    case "IsRemove": return IsRemove;
					default: throw new ArgumentException(string.Format("MemberGroup index[{0}] isn't exist.", index));
				}
                #endregion
			}
			set
			{
                #region
				switch (index)
				{
                    case "ID": 
                        _ID = value.ToNotNullString(); 
                        break; 
                    case "FastID": 
                        _FastID = value.ToInt(); 
                        break; 
                    case "GuildIDA": 
                        _GuildIDA = value.ToNotNullString(); 
                        break; 
                    case "GuildIDB": 
                        _GuildIDB = value.ToNotNullString(); 
                        break; 
                    case "UserIDA": 
                        _UserIDA = value.ToNotNullString(); 
                        break; 
                    case "UserIDB": 
                        _UserIDB = value.ToNotNullString(); 
                        break; 
                    case "Win": 
                        _Win = value.ToBool(); 
                        break; 
                    case "CombatProcess":
                        _CombatProcess = value as FightCombatProcess;
                        break;
                    case "IsRemove":
                        _IsRemove = value.ToBool();
                        break;
					default: throw new ArgumentException(string.Format("MemberGroup index[{0}] isn't exist.", index));
				}
                #endregion
			}
		}