private List <UnitAttackingData> CreateUnitToUnitDatas(Team team, Team toTeam, TeamSummaryData teamsum, TeamSummaryData toTeamsum, BattleData battleData) { List <UnitAttackingData> teamDatas = new List <UnitAttackingData>(); foreach (var unit in team.units) { foreach (var tounit in toTeam.units) { if (unit == null || tounit == null) { continue; } UnitAttackingData data = new UnitAttackingData(); data.data.UnitName = unit.Setting.Name; data.toData.UnitName = tounit.Setting.Name; UnitSummaryData untisum = unit.GetSummary(); UnitSummaryData tountisum = tounit.GetSummary(); data.data.DoDamger = (int)(untisum.Ad * ((float)tountisum.Count / (float)toTeamsum.Count)); data.toData.DoDamger = (int)(tountisum.Ad * ((float)untisum.Count / (float)teamsum.Count)); data.data.DoDamger = Mathf.Clamp(data.data.DoDamger, 0, int.MaxValue); data.toData.DoDamger = Mathf.Clamp(data.toData.DoDamger, 0, int.MaxValue); data.data.Unit = unit; data.toData.Unit = tounit; teamDatas.Add(data); } } return(teamDatas); }
private void SetTeamToTeamData(TeamAttackingData teamData) { TeamSummaryData team_dic = teamData.Team_dic; TeamSummaryData toteam_dic = teamData.ToTeam_dic; List <UnitAttackingData> unitDatas = teamData.UnitAttackingDatas; //buff1 例如调整特定单位对特定单位的伤害 调整伤害的BUFF Time_1 foreach (var item in unitDatas) { BattleTools.DoUnitBuff(item, EffectTimeType.Time_1); } int all_damger = BattleTools.GetDameger(unitDatas); //造成总伤害 int all_t_damger = BattleTools.GetByDameger(unitDatas); //对方的造成总伤害 // 此处调整受伤率 // 根据各种因素调整伤害 SetDamager(all_damger, all_t_damger, team_dic, toteam_dic, unitDatas); //buff3 例如调整特定单位对特定单位的保护效果 真实伤害 调整受到伤害的BUFF Time_2 foreach (var item in unitDatas) { BattleTools.DoUnitBuff(item, EffectTimeType.Time_2); } teamData.DoDamger = BattleTools.GetDameger(unitDatas); //总实际伤害 teamData.ByDamger = BattleTools.GetByDameger(unitDatas); }
public static void SetDamager(int all_damger, int all_t_damger, TeamSummaryData team_dic, TeamSummaryData toteam_dic, List <UnitAttackingData> teamDatas) { float injpr = BattleTools.GetInjurePr(all_t_damger, team_dic, toteam_dic); float t_injpr = BattleTools.GetInjurePr(all_damger, toteam_dic, team_dic); int all_Ed_damger = 0, avg_Ed_damger = 0, all_t_Ed_damger = 0, avg_t_Ed_damger = 0; if (team_dic != null) { all_Ed_damger = BattleTools.GetEdDamager(all_t_damger, team_dic); //减少的总伤害 avg_Ed_damger = (int)((float)all_Ed_damger / (float)team_dic.UnitCount); //平均减少的伤害 所有单位共享防御 } if (toteam_dic != null) { all_t_Ed_damger = BattleTools.GetEdDamager(all_damger, toteam_dic); avg_t_Ed_damger = (int)((float)all_t_Ed_damger / (float)toteam_dic.UnitCount); } foreach (var item in teamDatas) //更新伤害 { item.data.DoDamger = Mathf.Clamp(item.data.DoDamger - avg_t_Ed_damger, 0, int.MaxValue); item.toData.DoDamger = Mathf.Clamp(item.toData.DoDamger - avg_Ed_damger, 0, int.MaxValue); item.data.InjuryPr = injpr; item.toData.InjuryPr = t_injpr; } }
public static void SetRankText(Rank rank, Team team, Action <Rank, Team> RegistTeamButton) { rank.Hero_1_Text.text = ""; rank.Hero_2_Text.text = ""; rank.Army_Text_0.text = ""; rank.Army_Text_1.text = ""; if (team != null) { if (team.MainHero != null) { rank.Hero_1_Text.text = team.MainHero.ShowName; } if (team.MinorHero != null) { rank.Hero_2_Text.text = team.MinorHero.ShowName; } TeamSummaryData dic = team.GetSummary(); if (dic.Maxhp == 0) { return; } string str; str = string.Format("Hp:{0}/{1}\n攻击:{2}\n人数:{3}", dic.Hp, dic.Maxhp, dic.Ad, dic.Count); rank.Army_Text_0.text = str; str = string.Format("士气:{0}\n防御:{1}\n受伤:{2}", dic.Morale, dic.Ed, dic.Injury); rank.Army_Text_1.text = str; RegistTeamButton(rank, team); } }
public override void DoEffect(string skillName, King king, King toking, BattleData battleData) { int damager = int.Parse(Values[0]); List <TeamAttackingData> team_attack_datas = new List <TeamAttackingData>(); foreach (var team in toking.army.team) { if (team == null) { continue; } if (team.GetBattleCount() == 0) { continue; } TeamAttackingData teamData = new TeamAttackingData(); List <UnitAttackingData> list = new List <UnitAttackingData>(); TeamSummaryData data = team.GetSummary(); list = BattleContorl.CreateSkillToUnitData(skillName, damager, team, data, battleData); //调整伤亡率 BattleContorl.SetDamager(damager, 0, null, data, list); //buff3 例如调整特定单位对特定单位的保护效果 真实伤害 调整受到伤害的BUFF Time_2 foreach (var unitdata in list) { BattleTools.DoUnitBuff(unitdata, EffectTimeType.Time_2); } teamData.DoDamger = BattleTools.GetDameger(list); team_attack_datas.Add(teamData); teamData.UnitAttackingDatas = list; } foreach (var item in team_attack_datas) { BattleContorl.DoingUnitAttackData(item); } //BUFF 战后BUFF Time_4 foreach (var item in team_attack_datas) { BattleTools.DoTeamBuff(king, toking, item, EffectTimeType.Time_4); } }
TeamAttackingData CeateAttackingData(Team team, Team toTeam, int disdent, int round, BattleContorl battle) { if (team == null || toTeam == null) { return(null); } TeamAttackingData teamData = new TeamAttackingData(); TeamSummaryData team_dic = team.GetSummary(); teamData.Team_dic = team_dic; TeamSummaryData toteam_dic = toTeam.GetSummary(); teamData.ToTeam_dic = toteam_dic; if (team_dic.UnitCount == 0 || toteam_dic.UnitCount == 0) { return(null); } if (team_dic.Count == 0 || toteam_dic.Count == 0) { return(null); } BattleData battleData = new BattleData(); battleData.Disdent = disdent; battleData.Round = round; battleData.Battle = battle; teamData.Team = team; teamData.ToTeam = toTeam; teamData.battleData = battleData; List <UnitAttackingData> unitDatas = CreateUnitToUnitDatas(team, toTeam, team_dic, toteam_dic, battleData); teamData.UnitAttackingDatas = unitDatas; foreach (var item in unitDatas) { item.teamData = teamData; } //SetTeamToTeamData(teamData); return(teamData); }
public TeamSummaryData GetSummary() { //int maxhp = 0, hp = 0, ad = 0, ed = 0, count = 0, injury = 0, Morale = 0; TeamSummaryData data = new TeamSummaryData(); data.Maxhp = 0; data.Hp = 0; data.Ad = 0; data.Ed = 0; data.Count = 0; data.AllCount = 0; data.Injury = 0; data.Morale = 0; data.UnitCount = 0; foreach (var unit in units) { if (unit == null) { continue; } UnitSummaryData ddic = unit.GetSummary(); data.Maxhp += ddic.Maxhp; data.Hp += ddic.Hp; data.Ad += ddic.Ad; data.Ed += ddic.Ed; data.Count += ddic.Count; data.AllCount = ddic.AllCount; data.Injury += ddic.Injury; data.Morale += ddic.Morale; data.UnitCount++; } /*. (hp ; 0) * str = string.Format("HP:{0}/{1}\t士气:{2}\n" + "攻击:{3}\t防御:{4}\n" + "人数:{5}\t受伤:{6}", * hp, maxhp, Morale, ad, ed, count, injury);*/ return(data); }
IEnumerator LoadingFinishedJSON() { // show loader and get the season LoadingAlert.Present(); yield return(StartCoroutine(OnlineManager.Instance.StartGetSeason())); yield return(StartCoroutine(OnlineManager.Instance.StartGetPreviousGame())); // remove loader LoadingAlert.FinishLoading(); // set team data int blueWins = 0; int redWins = 0; for (int i = 0; i < OnlineManager.Instance.SeasonSyncData.team_summaries.Count; i++) { TeamSummaryData teamData = OnlineManager.Instance.SeasonSyncData.team_summaries[i]; if (teamData.team_name == "blue") { blueWins = teamData.captures; } else { redWins = teamData.captures; } } RedWins.Text = redWins.ToString(); BlueWins.Text = blueWins.ToString(); // red in the lead if (redWins > blueWins) { BannerImage.Image.color = Colors.RedBannerColor; } // blue in the lead else if (blueWins > redWins) { LeadTitleImage.Image.sprite = BlueLeadTitle; BannerImage.Image.color = Colors.BlueBannerColor; } // tie else if (blueWins == redWins) { LeadTitleImage.Image.sprite = TieTitle; BannerImage.Image.color = Colors.PurpleBannerColor; } BannerImage.Activate(); LeadTitleImage.Activate(); //LeaderboardTitleImage.Activate(); // set player data for (int i = 0; i < OnlineManager.Instance.SeasonSyncData.player_summaries.Count; i++) { PlayerSummaryData playerData = OnlineManager.Instance.SeasonSyncData.player_summaries[i]; if (OnlineManager.Instance.PlayerID == playerData.player_id.ToString()) { AMVP.Text = playerData.attack_mvp.ToString(); DMVP.Text = playerData.defend_mvp.ToString(); } } if (AMVP.Text == "") { AMVP.Text = "0"; } if (DMVP.Text == "") { DMVP.Text = "0"; } GemCountText.Text = "x " + Avatar.Instance.GemsAvailable; if (Avatar.Instance.GemsAvailable > 0) { if (Avatar.Instance.GemsAvailable > 1) { ActivityClaimButton.ButtonIconImage.sprite = AssetLookUp.Instance.ClaimGemsButton; } ActivityClaimButton.Enable(); } // play fill sound effect if (_stepsShown < Avatar.Instance.Steps || _activityMinShown < Avatar.Instance.ActiveMins) { SoundManager.Instance.PlaySoundEffect(SoundType.COINS_TALLY); } // activate battle button if there is a battle to watch if (OnlineManager.Instance.PreviousGameData != null && OnlineManager.Instance.PreviousGameData.id != "") { BattleButton.Activate(); } }
public static List <UnitAttackingData> CreateSkillToUnitData(string name, int damager, Team toTeam, TeamSummaryData toTeamsum, BattleData battledata) { List <UnitAttackingData> teamDatas = new List <UnitAttackingData>(); foreach (var tounit in toTeam.units) { if (tounit == null) { continue; } UnitAttackingData data = new UnitAttackingData(); data.toData.UnitName = tounit.Setting.Name; UnitSummaryData tountisum = tounit.GetSummary(); data.data.UnitName = name; data.data.DoDamger = (int)(damager * ((float)tountisum.Count / (float)toTeamsum.Count)); data.data.DoDamger = Mathf.Clamp(data.data.DoDamger, 0, int.MaxValue); data.toData.Unit = tounit; data.battleData = battledata; teamDatas.Add(data); } return(teamDatas); }
public static float GetInjurePr(int Dameger, TeamSummaryData data, TeamSummaryData todata) { // data==null skill return(0.5f); }
public static int GetEdDamager(int Dameger, TeamSummaryData data) { return(data.Ed); }