private void Awake() { if (current != null && current != this) { Destroy(this); return; } current = this; fightStart = new UnityEvent(); fightEnd = new UnityEvent(); fightBegan = false; if (_bossLevel == false) { if (defendersLeft > 0) { _defendersCount = defendersLeft; } else { _defendersCount += LevelManager.LevelNumber / 2; } } else { _defendersCount = 1; } }
public override void Dead(bool destroy) { if (destroy) { if (State == State.Dead) { Instantiate(_destroyParticle, transform.position, Quaternion.identity); AudioManager.PlayClipAtPosition(_destroyClip, transform.position, 1f, 1f, Random.Range(.5f, 1f)); Destroy(gameObject); } else { _target = null; FightStage.DefenderDied(); SwitchState(State.Dead); _rigidBody.useGravity = false; GetComponent <Collider>().isTrigger = true; //AudioManager.PlayClipAtPosition(_deadClip, transform.position); Invoke(nameof(SelfDestroy), 1.5f); } } else { SwitchState(State.Dead); AudioManager.PlayClipAtPosition(_deadClip, transform.position); Destroy(gameObject, 5f); } gameObject.tag = "Dead"; }
IEnumerator HealthCounter() { while (currentState != State.Dead) { if (currentHealth >= 2 * (startingHealth / 3)) { currentFightStage = FightStage.Beginning; } else if (currentHealth >= (startingHealth / 3)) { currentFightStage = FightStage.StartProjectiles; } else if (currentHealth > 0) { currentFightStage = FightStage.HeatUp; } //hit counter to make sure player doesnt abuse the stun if (hitCounter >= 3) { StartCoroutine(BackStep(player.transform)); } yield return(new WaitForEndOfFrame()); } yield return(null); }
public float DurationOfStage(FightStage fs) { float dur = 0; switch (fs) { case FightStage.Opening: // Switch this up to a custom set openning duration. dur = BossOpts.BerserkTimer * PercTimeForOpening; break; case FightStage.Below35: dur += BossOpts.BerserkTimer * (float)(BossOpts.Under35Perc + BossOpts.Under20Perc); break; case FightStage.Below20: dur += BossOpts.BerserkTimer * (float)BossOpts.Under20Perc; break; default: dur = BossOpts.BerserkTimer - (BossOpts.BerserkTimer * (float)(BossOpts.Under35Perc + BossOpts.Under20Perc)); break; } return(dur); }
IEnumerator AngryStageCoroutine() { _stage = FightStage.Angry; _animator.SetTrigger("Angry"); _animator.SetBool("IsFinal", false); yield return(new WaitForSeconds(.5f)); _multipleAttack.Fire(); }
public void OnLevelStart() { _animator = GetComponentInChildren <Animator>(); _health = GetComponent <BossHealth>(); _multipleAttack = GetComponent <BossMultipleAttack>(); _health.OnTakeDamage += HandleTakeDamage; _stage = FightStage.Start; }
IEnumerator FinalStageCoroutine() { _stage = FightStage.Final; _animator.SetTrigger("Angry"); _animator.SetBool("IsFinal", true); yield return(new WaitForSeconds(.5f)); _multipleAttack.Fire(2); while (true) { yield return(new WaitForSeconds(2f)); _multipleAttack.Fire(); } }
public static bool GuildIsLead(string guildID, FightStage stage, int fastID) { var fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == fastID && s.Stage == stage && (s.GuildIDA == guildID || s.GuildIDB == guildID)); if (fightGroupList.Count > 0) { ServerFightGroup fightGroup = fightGroupList[0]; if (fightGroup.GuildIDA == guildID && fightGroup.Awin >= fightGroup.Bwin) { return true; } else if (fightGroup.GuildIDB == guildID && fightGroup.Bwin >= fightGroup.Awin) { return true; } } return false; }
public static bool GuildIsLead(string guildID, FightStage stage, int fastID) { var fightGroupList = new ShareCacheStruct <ServerFightGroup>().FindAll(s => s.FastID == fastID && s.Stage == stage && (s.GuildIDA == guildID || s.GuildIDB == guildID)); if (fightGroupList.Count > 0) { ServerFightGroup fightGroup = fightGroupList[0]; if (fightGroup.GuildIDA == guildID && fightGroup.Awin >= fightGroup.Bwin) { return(true); } else if (fightGroup.GuildIDB == guildID && fightGroup.Bwin >= fightGroup.Awin) { return(true); } } return(false); }
protected override void DoExecute(object obj) { try { DateTime nextDate; FightStage stage = GuildFightCombat.GetStage(out nextDate); GuildFightCombat.GetCombatPrize(); GuildFightCombat.ChangStage(stage); if (stage == FightStage.quarter_final || stage == FightStage.semi_final || stage == FightStage.final) { GuildFightCombat.ServerFinal(stage); new BaseLog().SaveLog("公会争斗战正在运行!"); } GuildFightCombat.RemoveGuildFight(); } catch (Exception ex) { TraceLog.WriteError("GuildFightCombatTaskError-->{0}", ex); } }
public virtual void Dead(bool destroy) { if (gameObject.tag == "Defender") { FightStage.DefenderDied(); } if (destroy) { Instantiate(_destroyParticle, transform.position, Quaternion.identity); AudioManager.PlayClipAtPosition(_destroyClip, transform.position, 1f, 1f, Random.Range(.5f, 1f)); Destroy(gameObject); } else { SwitchState(State.Dead); AudioManager.PlayClipAtPosition(_deadClip, transform.position); Destroy(gameObject, 5f); } gameObject.tag = "Dead"; }
/// <summary> /// 结果 /// </summary> public bool GetResult(FightStage stage) { switch (stage) { case FightStage.Close: case FightStage.Apply: return(true); case FightStage.quarter_final: return(LostCount >= 1); case FightStage.semi_final: return(LostCount >= 2); case FightStage.final: return(LostCount >= 3); default: break; } return(true); }
public override bool TakeAction() { status = ContextUser.UserStatus; if (!string.IsNullOrEmpty(sportID)) { MemberGroup memberGroup = new ShareCacheStruct <MemberGroup>().FindKey(sportID); if (memberGroup != null && !memberGroup.IsRemove) { isWin = memberGroup.Win ? (short)1 : (short)0; processList.Add(memberGroup.CombatProcess); } } else { DateTime nextDate; FightStage stage = GuildFightCombat.GetStage(out nextDate); if (stage == FightStage.quarter_final || stage == FightStage.semi_final || stage == FightStage.final) { processList = GuildFightCombat.GetCombatProcess(ContextUser.UserID, stage); } } return(true); }
/// <summary> /// 触发战斗 /// </summary> private static void TriggerNomarlCombat(FightStage state) { try { var fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == info.FastID && s.Stage == state); if (fightGroupList.Count == 0) { FightStage fightStage = state - 1; fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == info.FastID && s.Stage == fightStage); } Stopwatch watck = new Stopwatch(); watck.Start(); foreach (ServerFightGroup fightGroup in fightGroupList) { if (string.IsNullOrEmpty(fightGroup.GuildIDA) || string.IsNullOrEmpty(fightGroup.GuildIDB)) { if (!string.IsNullOrEmpty(fightGroup.WinGuildID)) { continue; } string guildID = string.Empty; if (!string.IsNullOrEmpty(fightGroup.GuildIDA)) { guildID = fightGroup.GuildIDA; fightGroup.Awin = MathUtils.Addition(fightGroup.Awin, 1); } else { guildID = fightGroup.GuildIDB; fightGroup.Bwin = MathUtils.Addition(fightGroup.Bwin, 1); } fightGroup.WinGuildID = guildID; var serverfight = new ShareCacheStruct<ServerFight>().FindKey(info.FastID, guildID); if (serverfight != null) { serverfight.LostCount = MathUtils.Addition(serverfight.LostCount, (short)1); } continue; } var mogemaUserList = _fightUserList.FindAll(m => !m.IsRemove && m.GuildID == fightGroup.GuildIDA); var hashideUserList = _fightUserList.FindAll(m => !m.IsRemove && m.GuildID == fightGroup.GuildIDB); TriggeerMemberNumNotEnouth(mogemaUserList, hashideUserList, fightGroup); if (mogemaUserList.Count > 0 && hashideUserList.Count > 0 && string.IsNullOrEmpty(fightGroup.WinGuildID)) { TriggerPairCombat(mogemaUserList, hashideUserList, fightGroup); TraceLog.ReleaseWriteFatal("触发战斗A公会:{0}人数{1},B公会:{2}人数{3}", fightGroup.GuildIDA, mogemaUserList.Count, fightGroup.GuildIDB, hashideUserList.Count); } } if (state == FightStage.final) { info.GuildEndTime = DateTime.Now; } watck.Stop(); } catch (Exception ex) { _log.SaveLog("领土战普通组配对", ex); } }
/// <summary> /// 改变当前阶段 /// </summary> public static void ChangStage(FightStage stage) { var currStage = info.CurStage.ToEnum<FightStage>(); /**************************************************************************** Copyright (c) 2013-2015 scutgame.com http://www.scutgame.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ if (currStage != stage) { if (stage == FightStage.Close) return; if (stage == FightStage.Apply) { info.FastID++; info.IsGuildPrize = 0; info.CurStage = stage.ToInt(); info.Round = 0; NextGuildBattleDate(); RemoveCombatUserList(); TraceLog.WriteInfo("当前第{0}届公会争夺战", info.FastID); return; } if (stage == FightStage.Ready) { GuildFightCombatUserList(); } UserListFatigue(); RaceLevel(info.CurStage.ToEnum<FightStage>()); info.CurStage = stage.ToInt(); info.Round = 0; TraceLog.WriteInfo("目前阶段{0},开始分组!", info.FastID); var fightInfoList = new ConfigCacheSet<GuildFightInfo>().FindAll(); foreach (var fightInfo in fightInfoList) { Grouping(info.FastID, info.Lenght, stage, info.Round, fightInfo.CityID); } } }
protected override object this[string index] { get { #region switch (index) { case "ID": return ID; case "FastID": return FastID; case "CityID": return CityID; case "Stage": return Stage; case "NO": return NO; case "Round": return Round; case "GuildIDA": return GuildIDA; case "Awin": return Awin; case "GuildIDB": return GuildIDB; case "Bwin": return Bwin; case "WinGuildID": return WinGuildID; case "IsRemove": return IsRemove; default: throw new ArgumentException(string.Format("ServerFightGroup index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "ID": _ID = value.ToNotNullString(); break; case "FastID": _FastID = value.ToInt(); break; case "CityID": _CityID = value.ToInt(); break; case "Stage": _Stage = value.ToEnum<FightStage>(); break; case "NO": _NO = value.ToInt(); break; case "Round": _Round = value.ToInt(); break; case "GuildIDA": _GuildIDA = value.ToNotNullString(); break; case "Awin": _Awin = value.ToInt(); break; case "GuildIDB": _GuildIDB = value.ToNotNullString(); break; case "Bwin": _Bwin = value.ToInt(); break; case "WinGuildID": _WinGuildID = value.ToNotNullString(); break; case "IsRemove": _IsRemove = value.ToBool(); break; default: throw new ArgumentException(string.Format("ServerFightGroup index[{0}] isn't exist.", index)); } #endregion } }
protected override object this[string index] { get { #region switch (index) { case "FastID": return(FastID); case "GuildID": return(GuildID); case "CityID": return(CityID); case "GuildBanner": return(GuildBanner); case "RankID": return(RankID); case "ApplyDate": return(ApplyDate); case "CombatMember": return(CombatMember); case "Stage": return(Stage); case "LostCount": return(LostCount); case "IsRemove": return(IsRemove); case "IsBanner": return(IsBanner); default: throw new ArgumentException(string.Format("ServerFight index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "FastID": _FastID = value.ToInt(); break; case "GuildID": _GuildID = value.ToNotNullString(); break; case "CityID": _CityID = value.ToInt(); break; case "GuildBanner": _GuildBanner = value.ToNotNullString(); break; case "RankID": _RankID = value.ToShort(); break; case "ApplyDate": _ApplyDate = value.ToDateTime(); break; case "CombatMember": _CombatMember = value.ToNotNullString(); break; case "Stage": _Stage = value.ToEnum <FightStage>(); break; case "LostCount": _LostCount = value.ToShort(); break; case "IsRemove": _IsRemove = value.ToBool(); break; case "IsBanner": _IsBanner = value.ToBool(); break; default: throw new ArgumentException(string.Format("ServerFight index[{0}] isn't exist.", index)); } #endregion } }
/// <summary> /// 获得战斗过程 /// </summary> /// <param name="isSelf"></param> /// <returns></returns> public static List<FightCombatProcess> GetCombatProcess(string userID, FightStage stage) { List<FightCombatProcess> list = new List<FightCombatProcess>(); int version = 0; FightUser fightUser = _fightUserList.Find(m => m.UserId == userID); if (fightUser != null) { version = fightUser.Version; if (_combatProcessList != null) { list = _combatProcessList.FindAll(m => m.FastID == info.FastID && m.stage == stage && (m.WinUserId == userID || m.FailUserId == userID) && m.Version > version); } else if (_combatProcessList != null) { list = _combatProcessList.FindAll(m => m.FastID == info.FastID && m.stage == stage && m.Version > version); } foreach (var process in list) { if (process.Version > fightUser.Version) { fightUser.Version = process.Version; } } } return list; }
/// <summary> /// 分组 /// </summary> /// <param name="FastID"></param> /// <param name="Lenght"></param> /// <param name="Stage"></param> /// <param name="Round"></param> public static void Grouping(int FastID, int Lenght, FightStage Stage, int Round, int cityID) { switch (Stage) { case FightStage.Close: case FightStage.Apply: return; case FightStage.Ready: finalskonckout(FastID, Lenght, Round, cityID); break; case FightStage.semi_Wait: case FightStage.final_Wait: Grouping(FastID, Stage, cityID); break; default: break; } }
protected override object this[string index] { get { #region switch (index) { case "FastID": return FastID; case "GuildID": return GuildID; case "CityID": return CityID; case "GuildBanner": return GuildBanner; case "RankID": return RankID; case "ApplyDate": return ApplyDate; case "CombatMember": return CombatMember; case "Stage": return Stage; case "LostCount": return LostCount; case "IsRemove": return IsRemove; case "IsBanner": return IsBanner; default: throw new ArgumentException(string.Format("ServerFight index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "FastID": _FastID = value.ToInt(); break; case "GuildID": _GuildID = value.ToNotNullString(); break; case "CityID": _CityID = value.ToInt(); break; case "GuildBanner": _GuildBanner = value.ToNotNullString(); break; case "RankID": _RankID = value.ToShort(); break; case "ApplyDate": _ApplyDate = value.ToDateTime(); break; case "CombatMember": _CombatMember = value.ToNotNullString(); break; case "Stage": _Stage = value.ToEnum<FightStage>(); break; case "LostCount": _LostCount = value.ToShort(); break; case "IsRemove": _IsRemove = value.ToBool(); break; case "IsBanner": _IsBanner = value.ToBool(); break; default: throw new ArgumentException(string.Format("ServerFight index[{0}] isn't exist.", index)); } #endregion } }
public void SetFightStage(FightStage _fightStage) { switch(_fightStage) { case FightStage.StandBy: activeCommands = standByCommands; break; case FightStage.Attack: activeCommands = attackCommands; break; case FightStage.Move: activeCommands = moveCommands; break; case FightStage.Skill: activeCommands = skillCommands; break; case FightStage.EndFightStage: break; } }
public override bool TakeAction() { if (string.IsNullOrEmpty(ContextUser.MercenariesID)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6203_GuildMemberNotEnough; return(false); } string guildFight = string.Empty; DateTime nextDate; stage = GuildFightCombat.GetStage(out nextDate); if (stage != FightStage.Apply) { codeTime = (int)(nextDate - DateTime.Now).TotalSeconds; } ServerFight fight = new ShareCacheStruct <ServerFight>().FindKey(fightCombat.FastID, ContextUser.MercenariesID); if (fight != null) { CityInfo cityInfo = new ConfigCacheSet <CityInfo>().FindKey(fight.CityID); if (cityInfo != null) { cityName = cityInfo.CityName; } FightStage fightStage; if (stage <= FightStage.quarter_final) { fightStage = FightStage.quarter_final; } else if (stage > FightStage.quarter_final && stage < FightStage.final_Wait) { fightStage = FightStage.semi_final; } else { fightStage = FightStage.final; } var fightGroupList = new ShareCacheStruct <ServerFightGroup>().FindAll(s => s.FastID == fightCombat.FastID && s.Stage == fightStage); if (fightGroupList.Count == 0) { fightGroupList = new ShareCacheStruct <ServerFightGroup>().FindAll(s => s.FastID == fightCombat.FastID && s.Stage < fightStage); if (fightGroupList.Count == 0) { fightGroupList = new ShareCacheStruct <ServerFightGroup>().FindAll(s => s.FastID == fightCombat.FastID && s.Stage >= fightStage); } } foreach (var fightGroup in fightGroupList) { if (!string.IsNullOrEmpty(fightGroup.WinGuildID) && fightGroup.WinGuildID == ContextUser.MercenariesID) { guildFight = fightGroup.WinGuildID; continue; } if (fightGroup.GuildIDA == ContextUser.MercenariesID || fightGroup.GuildIDB == ContextUser.MercenariesID) { guildFight = fightGroup.GuildIDA + "," + fightGroup.GuildIDB; } } if (!string.IsNullOrEmpty(guildFight)) { guildStr = guildFight.Split(','); } TraceLog.ReleaseWriteFatal("6409公会争斗战配对城市{0} 阶段:{1},公会:{2}。", fight.CityID, stage, guildFight.ToNotNullString()); } var totalfatigue = ContextUser.Fatigue * GameConfigSet.Fatigue; int tfatigue = (int)(totalfatigue * 100); fatigue = string.Format(LanguageManager.GetLang().St6409_fatigueDesc, ContextUser.Fatigue, tfatigue); if (guildStr.Length == 0) { guildFight = ContextUser.MercenariesID + ","; guildStr = guildFight.Split(','); } return(true); }
/// <summary> /// 结果 /// </summary> public bool GetResult(FightStage stage) { switch (stage) { case FightStage.Close: case FightStage.Apply: return true; case FightStage.quarter_final: return LostCount >= 1; case FightStage.semi_final: return LostCount >= 2; case FightStage.final: return LostCount >= 3; default: break; } return true; }
public void PrintHealLog(FightableActor target, int heal) { FightStage.InsertLog($"{Performer.Name}가 {target.Name}을(를) {heal} 만큼 회복시켰습니다."); }
public void PrintAttackLog(FightableActor target, int damage) { FightStage.InsertLog($"{Performer.Name}가 {target.Name}에게 {damage} 만큼의 데미지를 입혔습니다."); }
public override bool TakeAction() { if (string.IsNullOrEmpty(ContextUser.MercenariesID)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6203_GuildMemberNotEnough; return(false); } GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID); if (member == null || member.PostType == PostType.Member) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6404_OrdinaryMemberNotCompetence; return(false); } UserGuild guild = new ShareCacheStruct <UserGuild>().FindKey(ContextUser.MercenariesID); if (guild == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } FightCombat fightCombat = new FightCombat(); var cacheSet = new ShareCacheStruct <ServerFight>(); ServerFight fight = cacheSet.FindKey(fightCombat.FastID, ContextUser.MercenariesID); if (fight != null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6404_HaveSignedUp; return(false); } DateTime nextDate; FightStage stage = GuildFightCombat.GetStage(out nextDate); if (GuildFightCombat.IsFightDate()) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6404_CityABattleTime; return(false); } if (stage != FightStage.Apply) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6404_CityABattleTime; return(false); } //if (DateTime.Now > fightCombat.GuildEndTime && DateTime.Now < fightCombat.GuildStartTime) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St6404_OutRegistrationTime; // return false; //} GuildFightInfo fightInfo = new ShareCacheStruct <GuildFightInfo>().FindKey(cityID); if (fightInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } if (guild.GuildLv < fightInfo.GuildLv) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6404_GuildLvNotEnough; return(false); } if (guild.CurrDonateNum < fightInfo.SkillNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6404_CurrDonateNumNotEnough; return(false); } guild.CurrDonateNum = MathUtils.Subtraction(guild.CurrDonateNum, fightInfo.SkillNum); fight = new ServerFight(fightCombat.FastID, ContextUser.MercenariesID); fight.GuildBanner = string.Empty; fight.CityID = cityID; fight.RankID = 0; fight.ApplyDate = DateTime.Now; fight.IsRemove = false; fight.IsBanner = false; cacheSet.Add(fight); ErrorCode = 0; ErrorInfo = LanguageManager.GetLang().St6401_SuccessfulRegistration; return(true); }
/// <summary> /// 公会排名 /// </summary> /// <param name="stage"></param> /// <param name="guildID"></param> /// <param name="isWin"></param> public static void FightRankID(FightStage stage, string guildID) { ServerFight serverFight = new ShareCacheStruct<ServerFight>().FindKey(info.FastID, guildID); if (serverFight != null) { if (stage == FightStage.quarter_final) { serverFight.RankID = 4; } else if (stage == FightStage.semi_final) { serverFight.RankID = 3; } else if (stage == FightStage.final) { serverFight.RankID = 2; } } }
public void StartFight(InputObject _inputObject) { stage = GameStage.Fight; fightStage = FightStage.StandBy; CommandManager.Instance.StartFight(); ExecuteAllCommand(); }
/// <summary> /// 晋级公会 /// </summary> /// <returns></returns> public static ServerFight[] GetApply(FightStage stage, int cityID) { int fastID = info.FastID; FightStage fightStage = FightStage.Ready; if (stage == FightStage.Apply && info.FastID > 1) { fastID = MathUtils.Subtraction(fastID, 1); fightStage = FightStage.final; } if (stage == FightStage.semi_Wait) { fightStage = FightStage.quarter_final; } else if (stage == FightStage.final_Wait) { fightStage = FightStage.semi_final; } var fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == fastID && s.Stage == fightStage); foreach (var fightgroup in fightGroupList) { if (string.IsNullOrEmpty(fightgroup.WinGuildID)) { ServerFightGroupWinGuildID(fightgroup, fastID); } } var applyList = new ShareCacheStruct<ServerFight>().FindAll(s => s.FastID == info.FastID && s.Stage == stage && s.CityID == cityID); applyList.QuickSort((x, y) => { int result; if (x == null && y == null) return 0; if (x != null && y == null) return 1; if (x == null) return -1; result = (int)y.GetResult(stage).CompareTo(x.GetResult(stage)); if (result == 0) { var userGuildA = new ShareCacheStruct<UserGuild>().FindKey(x.GuildID); var userGuildB = new ShareCacheStruct<UserGuild>().FindKey(y.GuildID); if (userGuildA != null && userGuildB != null) { result = userGuildB.GuildLv.CompareTo(userGuildA.GuildLv); if (result == 0) { result = userGuildB.CurrExperience.CompareTo(userGuildA.CurrExperience); } } } return result; }); var apply = new CacheList<ServerFight>(); for (int i = 0; i < info.Lenght && i < applyList.Count; i++) { apply.Add(applyList[i]); } return apply.ToArray(); }
protected override object this[string index] { get { #region switch (index) { case "ID": return(ID); case "FastID": return(FastID); case "CityID": return(CityID); case "Stage": return(Stage); case "NO": return(NO); case "Round": return(Round); case "GuildIDA": return(GuildIDA); case "Awin": return(Awin); case "GuildIDB": return(GuildIDB); case "Bwin": return(Bwin); case "WinGuildID": return(WinGuildID); case "IsRemove": return(IsRemove); default: throw new ArgumentException(string.Format("ServerFightGroup index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "ID": _ID = value.ToNotNullString(); break; case "FastID": _FastID = value.ToInt(); break; case "CityID": _CityID = value.ToInt(); break; case "Stage": _Stage = value.ToEnum <FightStage>(); break; case "NO": _NO = value.ToInt(); break; case "Round": _Round = value.ToInt(); break; case "GuildIDA": _GuildIDA = value.ToNotNullString(); break; case "Awin": _Awin = value.ToInt(); break; case "GuildIDB": _GuildIDB = value.ToNotNullString(); break; case "Bwin": _Bwin = value.ToInt(); break; case "WinGuildID": _WinGuildID = value.ToNotNullString(); break; case "IsRemove": _IsRemove = value.ToBool(); break; default: throw new ArgumentException(string.Format("ServerFightGroup index[{0}] isn't exist.", index)); } #endregion } }
/// <summary> /// 获取当前时间所在阶段 /// </summary> /// <returns></returns> public static FightStage GetStage(out DateTime nextDate) { FightStage fstage = new FightStage(); DateTime endDate; DateTime begintime = FightCombatStartDate(out endDate); DateTime dt = DateTime.Now; nextDate = MathUtils.SqlMinDate; DateTime applyEnd = begintime.AddMinutes(-GameConfigSet.BattleEndBeforeDate); //DateTime endchampion = endDate.AddMinutes(2); //if (endDate < DateTime.Now && DateTime.Now < endchampion) //{ // fstage = FightStage.champion; //} if (dt < applyEnd) { fstage = FightStage.Apply; nextDate = applyEnd; } else if (dt > applyEnd && dt < begintime) { fstage = FightStage.Ready; nextDate = begintime; } else if (dt > begintime) { int waitDate = GameConfigSet.BattleWaitDateTime; if (dt < begintime.AddMinutes(waitDate)) { fstage = FightStage.Wait; nextDate = begintime.AddMinutes(waitDate); } else if (dt > begintime.AddMinutes(waitDate) && dt < BattleIntervalDate(begintime, 1, 0)) { fstage = FightStage.quarter_final; nextDate = BattleIntervalDate(begintime, 1, 0); } else if (dt > BattleIntervalDate(begintime, 1, 0) && dt < BattleIntervalDate(begintime, 1, waitDate)) { fstage = FightStage.semi_Wait; nextDate = BattleIntervalDate(begintime, 1, waitDate); } else if (dt > BattleIntervalDate(begintime, 1, waitDate) && dt < BattleIntervalDate(begintime, 2, 0)) { fstage = FightStage.semi_final; nextDate = BattleIntervalDate(begintime, 2, 0); } else if (dt > BattleIntervalDate(begintime, 2, 0) && dt < BattleIntervalDate(begintime, 2, waitDate)) { fstage = FightStage.final_Wait; nextDate = BattleIntervalDate(begintime, 2, waitDate); } else if (dt > BattleIntervalDate(begintime, 2, waitDate) && dt < BattleIntervalDate(begintime, 3, waitDate)) { fstage = FightStage.final; nextDate = BattleIntervalDate(begintime, 3, 0); } } return fstage; }
/// <summary> /// 升级 /// </summary> public static void RaceLevel(FightStage stage) { TraceLog.WriteInfo("目前阶段{0}升级中", stage); var fightInfoList = new ConfigCacheSet<GuildFightInfo>().FindAll(); foreach (var fightInfo in fightInfoList) { ServerFight[] applyList = GetApply(stage, fightInfo.CityID); foreach (var item in applyList) { item.Stage = RaceLevelStage(stage); } } }
/// <summary> /// 决赛对阵 /// </summary> public static void Grouping(int FastID, FightStage Stage, int cityID) { int gstage = (int)Stage - 1; FightStage Rstage = (FightStage)gstage; if (Stage == FightStage.semi_Wait) { Rstage = FightStage.quarter_final; } else if (Stage == FightStage.final_Wait) { Rstage = FightStage.semi_final; } var againstList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == FastID && s.Stage == Rstage && s.CityID == cityID); againstList.QuickSort((x, y) => { return x.NO.CompareTo(y.NO); }); if (againstList.Count < 4 && Stage == FightStage.semi_Wait) { if (againstList.Count == 2) { AppendServerFightGroup(1, againstList[0].WinGuildID, string.Empty, againstList[0].CityID); AppendServerFightGroup(2, againstList[1].WinGuildID, string.Empty, againstList[1].CityID); } else if (againstList.Count == 3) { AppendServerFightGroup(1, againstList[0].WinGuildID, againstList[1].WinGuildID, againstList[0].CityID); AppendServerFightGroup(2, againstList[2].WinGuildID, string.Empty, againstList[2].CityID); } } else { for (int i = 0; i < againstList.Count / 2; i++) { ServerFightGroup againstA = againstList[i * 2]; ServerFightGroup againstB = againstList[(i * 2) + 1]; ServerFightGroup against = new ServerFightGroup(Guid.NewGuid().ToString()); against.NO = i + 1; against.Stage = Rstage; if (Stage == FightStage.semi_Wait) { against.Stage = FightStage.semi_final; } else if (Stage == FightStage.final_Wait) { against.Stage = FightStage.final; } against.Round = 1; against.FastID = FastID; against.CityID = cityID; if (againstA.Result == 1) { against.GuildIDA = againstA.GuildIDA; } else { against.GuildIDA = againstA.GuildIDB; } if (againstB.Result == 1) { against.GuildIDB = againstB.GuildIDA; } else { against.GuildIDB = againstB.GuildIDB; } against.IsRemove = false; new ShareCacheStruct<ServerFightGroup>().Add(against, GameEnvironment.CacheGlobalPeriod); } } }
/// <summary> /// 升级的公会争斗战状态 /// </summary> /// <param name="stage"></param> /// <returns></returns> public static FightStage RaceLevelStage(FightStage stage) { FightStage fightStage = stage; if (stage == FightStage.Apply || stage == FightStage.Ready) { fightStage = FightStage.quarter_final; } else if (stage == FightStage.quarter_final) { fightStage = FightStage.semi_final; } else if (stage == FightStage.semi_final) { fightStage = FightStage.final; } else if (stage == FightStage.final) { fightStage = FightStage.champion; } return fightStage; }
public override bool TakeAction() { short currMaxLv = ConfigEnvSet.GetInt("User.CurrMaxLv").ToShort(); //NoviceHelper.CheckFestival(ContextUser); NoviceHelper.GetFunctionEnum(Uid); //默认开启金币,精力大作战功能 if (!string.IsNullOrEmpty(ContextUser.MercenariesID)) { UserHelper.ChecheDailyContribution(ContextUser.MercenariesID, ContextUser.UserID); } PaymentService.Trigger(ContextUser); if (ContextUser.UserLv > currMaxLv) { genlv = currMaxLv; } else { genlv = ContextUser.UserLv; } var cacheSetGeneralEscalate = new ConfigCacheSet <GeneralEscalateInfo>(); GeneralEscalateHelper.AddUserLv(ContextUser, 0); _honourNum = ContextUser.HonourNum; int lv = ContextUser.UserLv; lv = lv < 0 ? 1 : lv + 1; var generalEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv); if (generalEscalate != null) { _nextHonourNum = generalEscalate.UpExperience; } guildID = ContextUser.MercenariesID; var userGeneralList = new GameDataCacheSet <UserGeneral>().FindAll(ContextUser.UserID); if (userGeneralList.Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } userGeneralInfo = userGeneralList[0]; //UserGeneral.GetMainGeneral(ContextUser.UserID); if (userGeneralInfo != null) { //wuzf 去掉刷新血量,其它改变血量接口有触发刷新 //userGeneralInfo.RefreshMaxLife(); generalID = userGeneralInfo.GeneralID; //careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(userGeneralInfo.CareerID); headID = userGeneralInfo.HeadID; //ContextUser.Sex ? careerInfo.HeadID2 : careerInfo.HeadID; escalateInfo = new ConfigCacheSet <GeneralEscalateInfo>().FindKey(genlv); lifeNum = userGeneralInfo.LifeNum; careerID = userGeneralInfo.CareerID; } lifeMaxNum = UserHelper.GetMaxLife(ContextUser.UserID, generalID); maxEnergyNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum"); sex = ContextUser.Sex ? 1 : 0; //道具图标 _blessingList = UserHelper.BlessingInfoList(ContextUser); //变身卡图标 List <UserProps> userPropsList = new GameDataCacheSet <UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 3 && u.ItemID != 5200 && u.ItemID != 7003); if (userPropsList.Count > 0) { UserProps props = userPropsList[0]; int pTime = props.DoRefresh(); ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(props.ItemID); if (itemInfo != null && pTime > pictureTime) { pictureID = itemInfo.PictrueID; pictureTime = pTime; } } //兼容客户端上已版本血量图标 List <UserProps> userPropsList2 = new GameDataCacheSet <UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1); if (userPropsList2.Count > 0) { UserProps props = userPropsList2[0]; int pTime = props.DoRefresh(); ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(props.ItemID); if (itemInfo != null && pTime > pictureTime) { _itemLiveNum = props.SurplusNum; _itemLiveMaxNum = itemInfo.EffectNum; } } //加量,领土战不能加血wuzf) if (ContextUser.UserStatus != UserStatus.CountryCombat) { UserHelper.GetGeneralLife(ContextUser.UserID); } //精力恢复 List <UserQueue> energyQueueArray = new GameDataCacheSet <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.EnergyHuiFu); if (energyQueueArray.Count > 0) { UserQueue energyQueue = energyQueueArray[0]; short energyMaxNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum"); int restorationDate = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationDate"); //半小时 int restorationNum = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationNum"); //恢复5点 if (energyQueue.Timing > DateTime.Now) { energyQueue.Timing = DateTime.Now; } //原因:玩家满精力时,精力恢复累加 int timeCount = (int)(DateTime.Now - energyQueue.Timing).TotalSeconds / restorationDate; if (timeCount > 0) { short energyNum = (short)(timeCount * restorationNum); if (ContextUser.EnergyNum < energyMaxNum) { ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, energyNum, energyMaxNum); } energyQueue.Timing = DateTime.Now; } else { if (energyMaxNum > ContextUser.EnergyNum) { rstore = (int)(energyQueue.Timing.AddSeconds(restorationDate) - DateTime.Now).TotalSeconds; totalRstore = (energyQueue.Timing.AddSeconds((energyMaxNum - ContextUser.EnergyNum) * restorationDate) - DateTime.Now).TotalSeconds.ToInt(); } } } else { UserQueue queue = new UserQueue() { QueueID = Guid.NewGuid().ToString(), UserID = ContextUser.UserID, QueueType = QueueType.EnergyHuiFu, QueueName = QueueType.EnergyHuiFu.ToString(), Timing = DateTime.Now, ColdTime = 0, TotalColdTime = 0, IsSuspend = false, StrengNum = 0 }; new GameDataCacheSet <UserQueue>().Add(queue, GameEnvironment.CacheUserPeriod); } VipLvInfo lvInfo = new ConfigCacheSet <VipLvInfo>().FindKey(MathUtils.Addition(ContextUser.VipLv, 1, int.MaxValue)); if (lvInfo != null) { demandGold = MathUtils.Subtraction(lvInfo.PayGold, ContextUser.PayGold, 0); demandGold = MathUtils.Subtraction(demandGold, ContextUser.ExtGold, 0); } UserHelper.GetGameUserCombat(ContextUser.UserID); if ((int)(DateTime.Now - ContextUser.DailyLoginTime).TotalSeconds <= 5 && ContextUser.UserLv > 10) { isHelper = 1; } FestivalHelper.DoFestival(ContextUser); if (ContextUser.UserExtend != null) { if ((plotstatucID > 0 || ContextUser.TempEnergyNum == 0) && !ContextUser.UserExtend.IsBoss) { ContextUser.TempEnergyNum = 1; } if ((plotstatucID == 0 && ContextUser.TempEnergyNum == 0) || ContextUser.UserExtend.IsBoss) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 0; ContextUser.UserExtend.IsBoss = false; return(true); }); } plotstatucID = ContextUser.UserExtend.PlotStatusID; mercenarySeq = ContextUser.UserExtend.MercenarySeq; cardUserID = ContextUser.UserExtend.CardUserID; } //公会晨练结束,退出公会晨练 int activeID = 11; GameActive active = new ShareCacheStruct <GameActive>().FindKey(activeID); if (active != null) { DateTime stratTime = active.BeginTime; DateTime endTime = active.BeginTime.AddMinutes(active.Minutes); if (ContextUser.UserLocation == Location.GuildExercise && (DateTime.Now < stratTime || DateTime.Now > endTime)) { ContextUser.UserLocation = Location.Guid; } } DateTime nextDate; FightStage stage = GuildFightCombat.GetStage(out nextDate); //公会战结束后 if (stage == FightStage.Apply && ContextUser.UserStatus == UserStatus.FightCombat) { ContextUser.UserStatus = UserStatus.Normal; } battleNum = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true).Count; totalBattle = EmbattleHelper.CurrEmbattle(ContextUser.UserID, false).Count; var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); foreach (var userEmbattle in userEmbattleList) { _talPriority = MathUtils.Addition(_talPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID)); } functionList = new GameDataCacheSet <UserFunction>().FindAll(ContextUser.UserID); // 精灵祝福 if (ContextUser != null) { if (MathUtils.SqlMinDate == ContextUser.WizardDate) // 玩家第一次进入 { ContextUser.WizardDate = DateTime.Now; ContextUser.WizardNum = 1; } else { double diffHours = (DateTime.Now - ContextUser.WizardDate).TotalHours; if (diffHours >= 1) { ContextUser.WizardNum = MathUtils.Addition(ContextUser.WizardNum, Convert.ToInt32(diffHours), 3); ContextUser.WizardDate = DateTime.Now; } } } // 未读信件的数量 TjxMailService tjxMailService = new TjxMailService(ContextUser); tjxMailService.GetMail(out unReadCount); return(true); }
/// <summary> /// 循环比赛 /// </summary> /// <param name="stage"></param> public static bool ServerFinal(FightStage stage) { if (stage == FightStage.Close) return false; int round = MathUtils.Subtraction(info.Round, 1); DateTime endDate; DateTime combatDate = FightCombatStartDate(out endDate).AddMinutes(round); if (IsCurrentWeek(combatDate) && DateTime.Now > combatDate) { TriggerNomarlCombat(stage); info.Round++; return true; } return false; }
public override void Interact() { _fightStage = FightStage.Started; }
public override bool TakeAction() { if (string.IsNullOrEmpty(ContextUser.MercenariesID)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St6203_GuildMemberNotEnough; return false; } string guildFight = string.Empty; DateTime nextDate; stage = GuildFightCombat.GetStage(out nextDate); if (stage != FightStage.Apply) { codeTime = (int)(nextDate - DateTime.Now).TotalSeconds; } ServerFight fight = new ShareCacheStruct<ServerFight>().FindKey(fightCombat.FastID, ContextUser.MercenariesID); if (fight != null) { CityInfo cityInfo = new ConfigCacheSet<CityInfo>().FindKey(fight.CityID); if (cityInfo != null) { cityName = cityInfo.CityName; } FightStage fightStage; if (stage <= FightStage.quarter_final) { fightStage = FightStage.quarter_final; } else if (stage > FightStage.quarter_final && stage < FightStage.final_Wait) { fightStage = FightStage.semi_final; } else { fightStage = FightStage.final; } var fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == fightCombat.FastID && s.Stage == fightStage); if (fightGroupList.Count == 0) { fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == fightCombat.FastID && s.Stage < fightStage); if (fightGroupList.Count == 0) { fightGroupList = new ShareCacheStruct<ServerFightGroup>().FindAll(s => s.FastID == fightCombat.FastID && s.Stage >= fightStage); } } foreach (var fightGroup in fightGroupList) { if (!string.IsNullOrEmpty(fightGroup.WinGuildID) && fightGroup.WinGuildID == ContextUser.MercenariesID) { guildFight = fightGroup.WinGuildID; continue; } if (fightGroup.GuildIDA == ContextUser.MercenariesID || fightGroup.GuildIDB == ContextUser.MercenariesID) { guildFight = fightGroup.GuildIDA + "," + fightGroup.GuildIDB; } } if (!string.IsNullOrEmpty(guildFight)) { guildStr = guildFight.Split(','); } TraceLog.ReleaseWriteFatal("6409公会争斗战配对城市{0} 阶段:{1},公会:{2}。", fight.CityID, stage, guildFight.ToNotNullString()); } var totalfatigue = ContextUser.Fatigue * GameConfigSet.Fatigue; int tfatigue = (int)(totalfatigue * 100); fatigue = string.Format(LanguageManager.GetLang().St6409_fatigueDesc, ContextUser.Fatigue, tfatigue); if (guildStr.Length == 0) { guildFight = ContextUser.MercenariesID + ","; guildStr = guildFight.Split(','); } return true; }