public static void Init(GameActive gameActive) { _combatProcessList = new DictionaryExtend<int, TeamCombatResult>(); _userList = new DictionaryExtend<string, int>(); _teamList = new DictionaryExtend<int, MorePlotTeam>(); _userTimesList = new DictionaryExtend<string, int>(); }
public CombatStatus GuildBossRefreshStatus() { if (CombatStatus != CombatStatus.NoStart && CombatStatus != CombatStatus.Over) { var cacheSet = new ShareCacheStruct <GameActive>(); DateTime currTime = DateTime.Now; GameActive active = cacheSet.FindKey(ActiveID); if (active != null) { if (GuildBossInfo != null) { BeginTime = GuildBossInfo.EnablePeriod.ToDateTime(DateTime.MinValue); EndTime = BeginTime.AddMinutes(active.Minutes); if (BeginTime > currTime) { lock (this) { CombatStatus = CombatStatus.NoStart; } } else if (EndTime < currTime) { lock (this) { CombatStatus = CombatStatus.Over; } } } } } return(CombatStatus); }
public static void Dispose(GameActive gameActive) { _combatProcessList = null; _userList = null; _teamList = null; _userTimesList = null; }
/// <summary> /// 加载数据 /// </summary> public static void InitBoss(GameActive gameActive) { if (_gameActiveList.ContainsKey(gameActive.ActiveId)) { _gameActiveList[gameActive.ActiveId] = gameActive; } else { _gameActiveList.Add(gameActive.ActiveId, gameActive); } CombatGeneral general = CreateBossGeneral(gameActive); if (!_bossGeneralList.ContainsKey(gameActive.ActiveId)) { _bossGeneralList.Add(gameActive.ActiveId, new BossDictionary { BossGeneral = general }); } else { _bossGeneralList[gameActive.ActiveId].BossGeneral = general; } }
/// <summary> /// 答题奖励 /// </summary> /// <param name="userGuild"></param> /// <param name="gameActive"></param> /// <param name="exuser"></param> /// <param name="user"></param> public static void DoPrize(UserGuild userGuild, GameActive gameActive, ExerciseUser exuser, GameUser user, ref int expNum, ref int Experience) { DateTime dt = DateTime.Now; if (dt < gameActive.BeginTime) { userGuild.GuildExercise.Status = 0; return; } if (exuser.Status == GuildExerciseStatus.All || (userGuild.GuildExercise.QuestionNo == exuser.QuestionNo && exuser.AnswerStatus)) { GuildExercisePrize prize = new ConfigCacheSet<GuildExercisePrize>().FindKey(userGuild.GuildExercise.Level); if (prize == null) return; decimal precent = GetExercisePrecent(userGuild); expNum = (int)Math.Floor((decimal)prize.ExpNum * precent); Experience = (int)Math.Floor((decimal)prize.Experience * precent); user.ExpNum = MathUtils.Addition(user.ExpNum, expNum, int.MaxValue); UserHelper.UserGeneralExp(user.UserID, Experience); } }
private void RefEnableTime(GameActive gameActive, ref DateTime enableTime, ref DateTime endTime, ref short isEnable) { try { gameActive = gameActive ?? new GameActive(); if (gameActive.ActiveType == FunctionEnum.Gonghui && !string.IsNullOrEmpty(ContextUser.MercenariesID)) { if (gameActive.ActiveId == UserGuild.ActiveID) { enableTime = guildBossDate(ContextUser.MercenariesID); endTime = enableTime.AddMinutes(gameActive.Minutes); guild.GuildBossRefreshStatus(); //gameActive.RefreshStatus(); if (guild.CombatStatus == CombatStatus.Wait || guild.CombatStatus == CombatStatus.Combat) { isEnable = 1; } else if (guild.CombatStatus == CombatStatus.Over) { isEnable = 2;//已结束 } else if (guild.CombatStatus == CombatStatus.Killed) { isEnable = 3;//已被击杀 } if (guild.GuildBossInfo != null && !UserHelper.IsCurrentWeek(guild.GuildBossInfo.RefreshDate)) { isEnable = 2; } } else { enableTime = gameActive.BeginTime.ToDateTime(DateTime.MinValue); DateTime intervalDate = gameActive.BeginTime.AddMinutes(gameActive.WaitMinutes); endTime = enableTime.AddMinutes(gameActive.Minutes); if (gameActive.ActiveId == 11 && intervalDate < DateTime.Now && DateTime.Now < endTime) { isEnable = 4; //置灰 } else { if (DateTime.Now < enableTime) { isEnable = 0; } else if (DateTime.Now > endTime) { isEnable = 2; } else { isEnable = 1; } } } } else { endTime = gameActive.EndTime; enableTime = gameActive.BeginTime; gameActive.RefreshStatus(); if (gameActive.CombatStatus == CombatStatus.Wait || gameActive.CombatStatus == CombatStatus.Combat) { isEnable = 1; } else if (gameActive.CombatStatus == CombatStatus.Over) { isEnable = 2;//已结束 } else if (gameActive.CombatStatus == CombatStatus.Killed) { isEnable = 3;//已被击杀 } } } catch (Exception ex) { SaveLog(ex); } }
internal static void Dispose(GameActive gameActive) { isOver = true; CountryGroup mogemaGroup; CountryGroup hashideGroup; if (TryGroup(CountryType.M, out mogemaGroup)) { SendMessage(mogemaGroup.NomarlGroup); SendMessage(mogemaGroup.AdvancedGroup); } if (TryGroup(CountryType.H, out hashideGroup)) { SendMessage(hashideGroup.NomarlGroup); SendMessage(hashideGroup.AdvancedGroup); } FistCountryUser = null; _countryGroupDict.Clear(); _countryGroupDict = null; _combatProcessList = null; _combatTimer.Dispose(); _combatTimer = null; GC.Collect(); }
/// <summary> /// 初始化 /// </summary> internal static void Init(GameActive gameActive) { //Trace.WriteLine("领土战初化"); _gameActive = gameActive; isOver = false; FistCountryUser = new CountryUser(); _countryGroupDict = new Dictionary<CountryType, CountryGroup>(2); var mogemaGroup = new CountryGroup(CountryType.M); var hashideGroup = new CountryGroup(CountryType.H); _countryGroupDict.Add(mogemaGroup.CountryType, mogemaGroup); _countryGroupDict.Add(hashideGroup.CountryType, hashideGroup); CountryCombatProcess.RestVersion(); _combatProcessList = new List<CountryCombatProcess>(); _combatTimer = new Timer(DoCombat, gameActive, 60000, 17 * 1000); //_waitCombatTimer = new Timer(DoWaitCombat, gameActive, 60000, 1 * 1000); }
public static GuildQuestion GetQuestion(UserGuild userGuild, GameActive gameActive, ExerciseUser exUser, ref int ColdTime) { DateTime dt = DateTime.Now; DateTime beginTime = gameActive.BeginTime.AddMinutes(gameActive.WaitMinutes); if (dt < gameActive.BeginTime.AddMinutes(gameActive.WaitMinutes)) { ColdTime = (int)(beginTime - dt).TotalSeconds; userGuild.GuildExercise.UpdateNotify(obj => { userGuild.GuildExercise.Status = 1; return true; }); return null; } GuildQuestion Question = new GuildQuestion(); if (userGuild.GuildExercise.QuesTime != null && dt < userGuild.GuildExercise.QuesTime.AddSeconds(QuestionWaitTime) && userGuild.GuildExercise.QuestionID != 0) { Question = new ConfigCacheSet<GuildQuestion>().FindKey(userGuild.GuildExercise.QuestionID); } else { int questionid = GetID(userGuild.GuildExercise.QuestionIDList.ToList()); userGuild.GuildExercise.QuestionID = questionid; Question = new ConfigCacheSet<GuildQuestion>().FindKey(userGuild.GuildExercise.QuestionID); userGuild.GuildExercise.UpdateNotify(obj => { if (userGuild.GuildExercise.QuesTime < beginTime) userGuild.GuildExercise.QuesTime = beginTime; int count = ((int)(dt - userGuild.GuildExercise.QuesTime).TotalSeconds) / QuestionWaitTime; if (count <= 0) { count = 0; } userGuild.GuildExercise.QuestionNo = MathUtils.Addition(userGuild.GuildExercise.QuestionNo, (count <= 1 ? 1 : count), int.MaxValue); userGuild.GuildExercise.QuesTime = beginTime.AddSeconds((userGuild.GuildExercise.QuestionNo - 1) * QuestionWaitTime); userGuild.GuildExercise.Status = 2; //已开始活动 userGuild.GuildExercise.CheckAllAnswer = 0; return true; });//userGuild.Update(); exUser.QuestionStatus = GuildQuestionStatus.ToAnswer; } ColdTime = QuestionWaitTime - (int)(dt - userGuild.GuildExercise.QuesTime).TotalSeconds; if (userGuild.GuildExercise.CheckAllAnswer == 0) { ColdTime -= 10; } if (ColdTime <= 0) { ColdTime = 0; return null; } return Question; }
public override bool TakeAction() { if (CombatHelper.IsBossKill(_activeId)) { this.ErrorCode = 1; this.ErrorInfo = LanguageManager.GetLang().St5405_BossKilled; return false; } BossCombat bossCombat = new BossCombat(_activeId); _gameActive = bossCombat.GameActive; CombatStatus combatStatus = _gameActive.RefreshStatus(); if (combatStatus == CombatStatus.Wait || combatStatus == CombatStatus.Combat) { bossCombat.Append(ContextUser); BossUser bossUser = bossCombat.GetCombatUser(Uid); if (bossUser != null) { _inspirePercent = bossUser.InspirePercent; _reliveInspirePercent = bossUser.ReliveInspirePercent; _reLiveNum = bossUser.ReliveNum; _combatNum = bossUser.CombatNum; _damageNum = bossUser.DamageNum; _codeTime = bossUser.CodeTime; } } List<BossUser> userList = bossCombat.GetCombatUser(); _regNum = userList.Count; int recordCount = 0; _bossUserList = userList.GetPaging(_pageIndex, _pageSize, out recordCount); CombatGeneral boss = bossCombat.Boss; if (boss != null) { _bossLiftNum = boss.LifeNum; _bossMaxLift = boss.LifeMaxNum; } return true; }
private static void DisposeData(GameActive gameActive) { if (gameActive.LoadSuccess) { gameActive.LoadSuccess = false; if (gameActive.ActiveType == FunctionEnum.Booszhang) { BossCombat.Dispose(gameActive); } else if (gameActive.ActiveType == FunctionEnum.Lintuzhang) { CountryCombat.Dispose(gameActive); } else if (gameActive.ActiveType == FunctionEnum.Multiplot) { PlotTeamCombat.Dispose(gameActive); } else if (gameActive.ActiveType == FunctionEnum.MorePlotCoin) { PlotTeamCombat.Dispose(gameActive); } else if (gameActive.ActiveType == FunctionEnum.MorePlotEnergy) { PlotTeamCombat.Dispose(gameActive); } } }
private static void LoadData(GameActive gameActive) { if ((gameActive.CombatStatus == CombatStatus.Wait || gameActive.CombatStatus == CombatStatus.Combat) && !gameActive.LoadSuccess) { if (!string.IsNullOrEmpty(gameActive.Broadcast)) { var broadcastService = new TjxBroadcastService(null); var msg = broadcastService.Create(NoticeType.Game, gameActive.Broadcast); if (gameActive.ActiveId == 11) { int invertal = (int)new TimeSpan(0, 0, gameActive.WaitMinutes, 0).TotalSeconds / 5; string startTime = DateTime.Now.ToString("HH:mm:ss"); string endTime = DateTime.Now.AddMinutes(gameActive.WaitMinutes).ToString("HH:mm:ss"); broadcastService.SendTimer(msg, startTime, endTime, true, invertal);//秒 } else { broadcastService.Send(msg); } } gameActive.LoadSuccess = true; if (gameActive.ActiveType == FunctionEnum.Booszhang) { BossCombat.InitBoss(gameActive); } else if (gameActive.ActiveType == FunctionEnum.Lintuzhang) { CountryCombat.Init(gameActive); } else if (gameActive.ActiveType == FunctionEnum.Multiplot) { PlotTeamCombat.Init(gameActive); } else if (gameActive.ActiveType == FunctionEnum.MorePlotCoin) { PlotTeamCombat.Init(gameActive); } else if (gameActive.ActiveType == FunctionEnum.MorePlotEnergy) { PlotTeamCombat.Init(gameActive); } } }
/// <summary> /// 初始化BOSS数据 /// </summary> /// <param name="active"></param> /// <returns></returns> private static CombatGeneral CreateBossGeneral(GameActive active) { CombatGeneral boss = null; if (active != null) { var plotNpcInfoList = new ShareCacheStruct<PlotNPCInfo>().FindAll(m => m.PlotID == active.BossPlotID); if (plotNpcInfoList.Count > 0) { var embattleList = new ShareCacheStruct<PlotEmbattleInfo>().FindAll(m => m.PlotNpcID == plotNpcInfoList[0].PlotNpcID); if (embattleList.Count > 0) { int npcId = plotNpcInfoList[0].PlotNpcID; boss = (CombatGeneral)MonsterQueue.Create(embattleList[0]); boss.Lv = (short)MathUtils.Subtraction(active.BossLv, 0, active.BossDefLv); int bossLiftNum = MonsterQueue.BossProperty(embattleList[0].PlotNpcID, AbilityType.ShengMing).ToInt(); int lv = (boss.Lv - active.BossDefLv); int lifeNum = boss.LifeNum + lv * bossLiftNum; //ConfigEnvSet.GetInt("BossCombat.IncreaseLiveNum"); boss.LifeMaxNum = lifeNum; boss.LifeNum = lifeNum; if (lv > 0) { boss.PowerNum = MathUtils.Addition((lv * MonsterQueue.BossProperty(npcId, AbilityType.PowerNum)).ToInt(), boss.PowerNum).ToInt(); boss.SoulNum = MathUtils.Addition((lv * MonsterQueue.BossProperty(npcId, AbilityType.SoulNum).ToInt()), boss.SoulNum).ToInt(); boss.IntellectNum = MathUtils.Addition((lv * MonsterQueue.BossProperty(npcId, AbilityType.IntelligenceNum).ToInt()), boss.IntellectNum).ToInt(); boss.PhyAttackNum = MathUtils.Addition((lv * MonsterQueue.BossProperty(npcId, AbilityType.WuLiGongJi).ToInt()), boss.PhyAttackNum); boss.AbiAttackNum = MathUtils.Addition((lv * MonsterQueue.BossProperty(npcId, AbilityType.HunJiGongJi).ToInt()), boss.AbiAttackNum); boss.MagAttackNum = MathUtils.Addition((lv * MonsterQueue.BossProperty(npcId, AbilityType.MoFaGongJi).ToInt()), boss.MagAttackNum); boss.PhyDefenseNum = MathUtils.Addition((lv * MonsterQueue.BossProperty(npcId, AbilityType.WuLiFangYu).ToInt()), boss.PhyDefenseNum); boss.AbiDefenseNum = MathUtils.Addition((lv * MonsterQueue.BossProperty(npcId, AbilityType.HunJiFangYu).ToInt()), boss.AbiDefenseNum); boss.MagDefenseNum = MathUtils.Addition((lv * MonsterQueue.BossProperty(npcId, AbilityType.MoFaFangYu).ToInt()), boss.MagDefenseNum); } TraceLog.WriteComplement("世界BOSS属性值---血量:{0}、上限血量:{1}、力量:{2}、魂力:{3}、智力:{4}、物理攻击:{5}、魂技攻击:{6}、魔法攻击:{7}、物理防御:{8}、魂技防御:{9}、魔法防御:{10}", boss.LifeNum, boss.LifeMaxNum, boss.PowerNum, boss.SoulNum, boss.IntellectNum, (boss.ExtraAttack.WuliNum + boss.PhyAttackNum), (boss.ExtraAttack.HunjiNum + boss.AbiAttackNum), (boss.ExtraAttack.MofaNum + boss.MagAttackNum), (boss.ExtraDefense.WuliNum + boss.PhyDefenseNum), (boss.ExtraDefense.HunjiNum + boss.AbiDefenseNum), (boss.ExtraDefense.MofaNum + boss.MagDefenseNum)); } } else { throw new Exception(string.Format("公会战未配置BOSS:{0}", active.BossPlotID)); } } if (boss == null) { throw new Exception("Loading boss faild."); } return boss; }
/// <summary> /// 释放 /// </summary> /// <param name="gameActive"></param> public static void Dispose(GameActive gameActive) { if (_bossGeneralList.ContainsKey(gameActive.ActiveId)) { _bossGeneralList[gameActive.ActiveId].Clear(); } }