public static List <PropIdGroup> GetPropListC() { if (_listC == null) { AtkGroup.cInit = InitBattleForce; AtkGroup.cInitPer = InitBattleForcePer; AtkGroup.cAdd = BattleForceAdd; AtkGroup.cPer = BattleForcePer; AtkGroup.cFinal = BattleForce; AtkGroup.cRate = ConstConfig.GetFloat(ConstConfig.ID.War_DV_BattleForce2Atk_Ratio); DefGroup.cInit = InitBattleForce; DefGroup.cInitPer = InitBattleForcePer; DefGroup.cAdd = BattleForceAdd; DefGroup.cPer = BattleForcePer; DefGroup.cFinal = BattleForce; DefGroup.cRate = ConstConfig.GetFloat(ConstConfig.ID.War_DV_BattleForce2Defence_Ratio); MoveSpeedGroup.cInit = InitSpeedAtk; MoveSpeedGroup.cInitPer = InitSpeedAtkPer; MoveSpeedGroup.cAdd = SpeedAtkAdd; MoveSpeedGroup.cPer = SpeedAtkPer; MoveSpeedGroup.cFinal = SpeedAtk; MoveSpeedGroup.cRate = ConstConfig.GetFloat(ConstConfig.ID.War_DV_SpeedAtk2MoveSpeed_Ratio); _listC = new List <PropIdGroup>(); _listC.Add(AtkGroup); _listC.Add(DefGroup); _listC.Add(MoveSpeedGroup); } return(_listC); }
/** 防守损兵比 * 防守损兵比 = 参数A*(参数B*城池模块--战中防御/(参数B*城池模块--战中防御+士兵模块--战中攻击)); * 参数C≤防守损兵比≤参数D; * //参数A 默认为2.2 * //参数B 默认为1.2 * //参数C 默认为0.5 * //参数D 默认为4 * //假设防守损兵比为0.8,则意味着防守方每1个士兵可以抵消攻击方0.8个士兵 */ public static float WD_DefCostRate(float d_def, float a_atk) { //高方损兵比=(高/低-A)*B+C float r = d_def > a_atk ? d_def / a_atk : a_atk / d_def; if (r < 0) { if (Application.isEditor) { Debug.LogErrorFormat("hpbug WD_DefCostRate r={0}, a_atk={1}, d_def={2}", r, a_atk, d_def); } } float a = ConstConfig.GetFloat(ConstConfig.ID.War_DV_DefCostRate_RatioA); float b = ConstConfig.GetFloat(ConstConfig.ID.War_DV_DefCostRate_RatioB); float c = ConstConfig.GetFloat(ConstConfig.ID.War_DV_DefCostRate_RatioC); float d = ConstConfig.GetFloat(ConstConfig.ID.War_DV_DefCostRate_RatioD); float val = (r - a) * b + c; if (a_atk >= d_def) { val = 1 / val; } // float val = a * (b * d_def / (b * d_def + a_atk)); // if(val < c) val = c; // else if(val > d) val = d; return(val); }
/** 战前兵营--初始兵力: * 有武将驻守 * 初始兵力=(战前--玩家城池--速攻值+战前--玩家武将--速攻值*参数A)*参数B; * //参数A=武将城池额外附加最大兵力比例 * //参数B=有武将城池初始兵力比例 * * * 无武将驻守 * 初始兵力=战前--玩家城池--速攻值*参数C; * //参数C=无武将城池初始兵力比例 */ public static float WF_Casern_Hp2(float configHp, float casern_InitSpeedAtk, bool hasHero, float hero_InitSpeedAtk) { if (configHp != -1) { return(configHp); } if (hasHero) { return((casern_InitSpeedAtk + hero_InitSpeedAtk * ConstConfig.GetFloat(ConstConfig.ID.War_DV_Casern_Hp_RatioA)) * ConstConfig.GetFloat(ConstConfig.ID.War_DV_Casern_Hp_RatioB) + ConstConfig.GetFloat(ConstConfig.ID.War_DV_Casern_Hp_RatioD)); } else { return(casern_InitSpeedAtk * ConstConfig.GetFloat(ConstConfig.ID.War_DV_Casern_Hp_RatioC) + ConstConfig.GetFloat(ConstConfig.ID.War_DV_Casern_Hp_RatioD)); } }
public void Init() { if (isInit) { return; } isInit = true; buildUplevel_RequireMinHp = ConstConfig.GetFloat(ConstConfig.ID.War_BuildUplevel_RequireMinHp); buildUplevel_RequireMaxHp = ConstConfig.GetFloat(ConstConfig.ID.War_BuildUplevel_RequireMaxHp); buildUplevel_RequireMaxTime = ConstConfig.GetFloat(ConstConfig.ID.War_BuildUplevel_RequireMaxTime); buildUplevel_Hp2Time = ConstConfig.GetFloat(ConstConfig.ID.War_BuildUplevel_Hp2Time); skillChangeBuildTime = ConstConfig.GetFloat(ConstConfig.ID.War_SkillChangeBuildTime); skillSnap = Setting.SkillSnapSwitch; }
/** 生成数据--兵营 */ public void GenerationBuilds() { Dictionary <int, float[]> legionHeroTotals = new Dictionary <int, float[]>(); Dictionary <int, int> legionHeroCounts = new Dictionary <int, int>(); foreach (KeyValuePair <int, LegionData> legionKVP in legionDict) { LegionData legionData = legionKVP.Value; float[] heroTotals = new float[PropId.MAX]; int heroCount = 0; foreach (KeyValuePair <int, float[]> heroKVP in legionData.heroInitProp) { heroCount++; heroTotals.PropAdd(heroKVP.Value); } legionHeroTotals.Add(legionData.legionId, heroTotals); legionHeroCounts.Add(legionData.legionId, heroCount); } foreach (KeyValuePair <int, StageLegionConfig> kvp in stageConfig.legionDict) { StageLegionConfig legionConfig = kvp.Value; LegionData legionData = legionDict[legionConfig.legionId]; float[] soliderInitProp_Final = new float[PropId.MAX]; soliderInitProp_Final.PropAdd(legionData.soliderInitProp); soliderInitProp_Final.Calculate(); legionHeroTotals[legionData.legionId].Calculate(); //------------------ 生成势力 士兵属性(士兵模块提供攻击+参战武将战前攻击之和) -----------------------// // Debug.Log(legionData.legionId + " <color=green>F legionData.soliderData.Props</color>" + legionData.soliderInitProp.ToStrProp()); // legionData.soliderInitProp[PropId.InitAtk] = WarFormula.WF_Solider_Atk(legionData.levelData.intBattleForce, legionHeroTotals[legionData.legionId][PropId.Atk]); legionData.soliderInitProp[PropId.InitBattleForce] = WarFormula.WF_Solider_BattleForce(legionData.levelData.intBattleForce); legionData.soliderInitProp[PropId.InitMoveSpeed] = WarFormula.WF_Solider_MoveSpeed(legionData.levelData.intMoveSpeed, legionHeroTotals[legionData.legionId][PropId.MoveSpeed]); // Debug.Log(legionData.legionId + " <color=green>B legionData.soliderData.Props=</color>" + legionData.soliderInitProp.ToStrProp()); //------------------ 生成势力 兵营属性(产兵速度, 防御, 兵力上限) -----------------------// float[] props = new float[PropId.MAX]; // 战前兵营--产兵速度 props[PropId.InitProduceSpeed] = WarFormula.WF_Casern_ProduceSpeed(legionData.levelData.intProduceSpeed, legionHeroTotals[legionData.legionId][PropId.ProduceSpeed]); // 战前兵营--防御 // props[PropId.InitDef] = WarFormula.WF_Casern_Def(legionData.levelData.intBattleForce, legionHeroTotals[legionData.legionId][PropId.Def]); props[PropId.InitBattleForce] = WarFormula.WF_Casern_BattleForce(legionData.levelData.intBattleForce); // 战前兵营--兵力上限 props[PropId.InitMaxHp] = WarFormula.WF_Casern_MaxHP(legionHeroTotals[legionData.legionId][PropId.MaxHp]); // // 战前兵营--速攻 // props[PropId.InitSpeedAtk] = WarFormula.WF_Casern_SpeedAtk(legionData.levelData.intBattleForce, legionHeroTotals[legionData.legionId][PropId.SpeedAtk]); //Debug.Log ("legionData.legionId=" + legionData.legionId + " " + props.ToStrProp()); // 设置势力--兵营战前属性 legionData.buildInitProp = props; } // 兵营初始兵力(血量Hp) foreach (KeyValuePair <int, StagePositionConfig> kvp in stageConfig.buildDict) { StagePositionConfig buildConfig = kvp.Value; LegionData legionData = legionDict[buildConfig.legionId]; float[] full = new float[PropId.MAX]; full.PropAdd(legionData.buildInitProp); float hero_InitSpeedAtk = 0f; // HeroData heroData; // if(herosByBuild.TryGetValue(buildConfig.index, out heroData)) // { // hero_InitSpeedAtk = legionData.heroInitProp[heroData.heroId][PropId.InitSpeedAtk]; // } // 初始兵力--计算 // Debug.Log(string.Format("<color=yellow>buildConfig.index={0}, buildConfig.hp={1}</color>, full[PropId.MaxHp]={2}, hasHero={3} heroMaxHp={4}", buildConfig.index, buildConfig.hp, full[PropId.MaxHp],herosByBuild.ContainsKey(buildConfig.index), heroMaxHp)); // float hp = WarFormula.WF_Casern_Hp(buildConfig.hp, legionData.buildInitProp[PropId.InitMaxHp], herosByBuild.ContainsKey(buildConfig.index), heroMaxHp); float hp = WarFormula.WF_Casern_Hp(buildConfig.hp, legionData.levelData.initHP); float[] firstProp = new float[PropId.MAX]; firstProp[PropId.HpAdd] = hp; // 兵营初始属性[Hp] float[] initProp = new float[PropId.MAX]; initProp[PropId.InitHp] = hp; buildFirstProp.Add(buildConfig.index, firstProp); buildInitProp.Add(buildConfig.index, initProp); } int casernCount = 0; int turretCount = 0; int spotCount = 0; // 生成兵营UnitData foreach (KeyValuePair <int, StagePositionConfig> kvp in stageConfig.buildDict) { StagePositionConfig positionConfig = kvp.Value; UnitData unitData = new UnitData(); unitData.id = positionConfig.index; unitData.legionId = positionConfig.legionId; unitData.unitType = UnitType.Build; unitData.buildType = positionConfig.buildType; unitData.level = positionConfig.level; unitData.position = positionConfig.position; unitData.buildConfig = positionConfig.buildConfig; unitData.we_BuildConfigData = new WE_BuildConfigData(); unitData.we_BuildConfigData.hp = (int)positionConfig.hp; unitData.we_BuildConfigData.settledPriority = positionConfig.settledPriority; unitData.we_BuildConfigData.buildConfig = unitData.buildConfig; buildDict.Add(positionConfig.index, unitData); switch (unitData.buildType) { case BuildType.Casern: casernCount++; break; case BuildType.Turret: turretCount++; break; case BuildType.Spot: spotCount++; break; } } legionTotalMaxHP = casernCount * ConstConfig.GetFloat(ConstConfig.ID.War_StageLegionTotalMaxHP_Ratio_Casern) + turretCount * ConstConfig.GetFloat(ConstConfig.ID.War_StageLegionTotalMaxHP_Ratio_Turret) + spotCount * ConstConfig.GetFloat(ConstConfig.ID.War_StageLegionTotalMaxHP_Ratio_Spot); foreach (KeyValuePair <int, LegionData> kvp in legionDict) { kvp.Value.totalMaxHP = legionTotalMaxHP; } }
/** 生成数据--势力 */ public void GenerationLegions() { // 占用自己颜色的势力 LegionData occupyMainLegionData = null; War.realPlayerCount = 0; // 创建势力数据LegionData foreach (KeyValuePair <int, StageLegionConfig> kvp in stageConfig.legionDict) { StageLegionConfig legionConfig = kvp.Value; LegionData legionData; if (legionConfig.type == LegionType.Player) { legionData = new LegionData(legionConfig.legionId, "Player-" + legionConfig.legionId, LegionType.Player, legionConfig.aiSendArm, legionConfig.aiUplevel, legionConfig.aiSkill, legionConfig.produce); if (enterData.vsmode == VSMode.PVP && legionData.legionId != ownLegionID) { legionData.aiSendArm = false; legionData.aiSkill = false; legionData.aiUplevel = false; } } else if (legionConfig.type == LegionType.Computer) { legionData = new LegionData(legionConfig.legionId, "Player-" + legionConfig.legionId, LegionType.Computer, legionConfig.aiSendArm, legionConfig.aiUplevel, legionConfig.aiSkill, legionConfig.produce); if (enterData.vsmode == VSMode.PVP && !War.isMainLegion) { legionData.aiSendArm = false; legionData.aiSkill = false; legionData.aiUplevel = false; } } else { legionData = new LegionData(legionConfig.legionId, "Player-" + legionConfig.legionId, LegionType.Neutral, legionConfig.aiSendArm, legionConfig.aiUplevel, legionConfig.aiSkill, legionConfig.produce); if (enterData.vsmode == VSMode.PVP && !War.isMainLegion) { legionData.aiSendArm = false; legionData.aiSkill = false; legionData.aiUplevel = false; } } legionData.produceLimit = legionConfig.produceLimit; legionData.colorId = legionConfig.color; legionDict.Add(legionData.legionId, legionData); if (legionData.colorId == War.config.ownDefaultColor) { occupyMainLegionData = legionData; } legionData.roleId = enterData.GetRoleId(legionData.legionId); if (!roleDict.ContainsKey(legionData.roleId)) { roleDict.Add(legionData.roleId, legionData); } legionData.expeditionTotalMaxHP = enterData.GetTotalMaxHP(legionData.legionId); legionData.expeditionTotalHP = enterData.GetTotalHP(legionData.legionId); legionData.expeditionInitHP = legionData.expeditionTotalHP; legionData.expeditionLeftHP = legionData.expeditionTotalHP; WarEnterLegionData enterLegionData = enterData.GetEnterLegionData(legionData.legionId); if (enterLegionData != null) { legionData.name = enterLegionData.name; legionData.headAvatarId = enterLegionData.headAvatarId; legionData.levelData.intBattleForce = enterLegionData.totalAtk; legionData.levelData.intProduceSpeed = enterLegionData.totalProduceSpeed; legionData.levelData.intMoveSpeed = enterLegionData.totalMoveSpeed; legionData.levelData.initHP = enterLegionData.initHP; legionData.levelData.maxBattleForce = enterLegionData.maxAtk; legionData.levelData.maxProduceSpeed = enterLegionData.maxProduceSpeed; legionData.levelData.maxMoveSpeed = enterLegionData.maxMovespeed; legionData.levelData.subBattleForce = enterLegionData.subAtk; legionData.levelData.subProduceSpeed = enterLegionData.subProduceSpeed; legionData.levelData.subMoveSpeed = enterLegionData.subMoveSpeed; legionData.sendArmRate = enterLegionData.sendArmRate; if (enterLegionData.isRobot) { if (enterData.vsmode == VSMode.PVP && War.isMainLegion && legionData.colorId != 0) { legionData.aiSendArm = true; legionData.aiSkill = true; legionData.aiUplevel = true; } legionData.type = LegionType.Computer; if (legionData.colorId == 0) { legionData.type = LegionType.Neutral; } } else { legionData.type = LegionType.Player; legionData.aiSendArm = false; legionData.aiSkill = false; legionData.aiUplevel = false; } if (enterLegionData.ai > 0) { legionData.aiConfig = War.model.GetAIConfig(enterLegionData.ai);; } } else { NeutralExpConfig roleExpConfig = War.model.GetNeutralExpConfig(stageConfig.neutralRoleLevel); legionData.levelData.intBattleForce = roleExpConfig.props[PropId.BattleForceAdd]; legionData.levelData.intProduceSpeed = roleExpConfig.props[PropId.ProduceSpeedAdd]; legionData.levelData.intMoveSpeed = roleExpConfig.props[PropId.MoveSpeedAdd]; legionData.levelData.initHP = roleExpConfig.props[PropId.HpAdd]; if (legionData.colorId == 0) { legionData.type = LegionType.Neutral; } else { legionData.type = LegionType.Computer; } } if (legionConfig.type == LegionType.Player) { War.realPlayerCount++; } if (War.isEditor) { legionData.aiSendArm = false; legionData.aiSkill = false; legionData.produce = false; legionData.aiUplevel = false; } if (War.isTest) { if (legionData.type == LegionType.Computer || (legionData.type == LegionType.Player && legionData.legionId != War.ownLegionID)) { legionData.aiSendArm = true; legionData.aiSkill = true; legionData.produce = true; legionData.aiUplevel = true; legionData.aiConfig = stageConfig.id >= 71 && stageConfig.id <= 80 ? War.model.GetAIConfig(102) : War.model.GetAIConfig(302); } } if (War.isRecord) { legionData.aiSendArm = false; legionData.aiSkill = false; legionData.aiUplevel = false; } int id = GetPlayerUID(legionData.legionId); // 势力单位数据 UnitData unitData = new UnitData(); unitData.id = id; unitData.legionId = legionData.legionId; unitData.unitType = UnitType.Player; float x = 5 * Mathf.FloorToInt((legionData.legionId + 1) / 2) * (legionData.legionId % 2 == 0 ? 1 : -1); unitData.position = new Vector3(x, 0f, -11F); legionData.unitData = unitData; /** 战前势力--怒气上限 */ legionData.legionInitProp[PropId.InitMaxMage] = WarFormula.WF_Legion_MaxMage(); /** 战前势力--怒气 */ legionData.legionInitProp[PropId.MagAdd] = legionData.legionInitProp[PropId.InitMag] = enterData.vsmode != VSMode.PVE_Expedition ? WarFormula.WF_Legion_Mage() : enterData.GetMag(legionData.legionId); /** 战前势力--怒气 */ legionData.legionInitProp[PropId.InitMageSpeed] = ConstConfig.GetFloat(ConstConfig.ID.War_DV_Mag_Recovery_Ratio); //TODO Test //legionData.aiSendArm = true; //legionData.aiSkill = true; //legionData.aiConfig = War.model.GetAIConfig(302); } // 获取自己势力数据 ownLegion = legionDict[ownLegionID]; // 交换势力颜色 if (occupyMainLegionData != null && occupyMainLegionData != ownLegion) { int tempColorId = ownLegion.colorId; ownLegion.colorId = occupyMainLegionData.colorId; occupyMainLegionData.colorId = tempColorId; } else { ownLegion.colorId = War.config.ownDefaultColor; } // 创建势力联盟数据LegionGroupData foreach (StageLegionGroupConfig groupConfig in stageConfig.legionGroups) { LegionGroupData groupData = new LegionGroupData(groupConfig.id); legionGroupDict.Add(groupData.id, groupData); foreach (StageLegionConfig legionConfig in groupConfig.list) { groupData.AddLegion(legionDict[legionConfig.legionId]); } } List <int> colorIdList = new List <int>(); foreach (KeyValuePair <int, LegionData> legionKVP in War.sceneData.legionDict) { colorIdList.Add(legionKVP.Value.colorId); } colorIds = colorIdList.ToArray(); }
/** 战前兵营--速攻: * 速攻值=(默认最小值+武将模块--参战武将总速攻值)*参数;//默认参数为1; */ public static float WF_Casern_SpeedAtk(float legionInitSpeedAtk, float totalHero_InitSpeedAtk) { return((legionInitSpeedAtk + legionInitSpeedAtk) * ConstConfig.GetFloat(ConstConfig.ID.War_DV_Casern_SpeedAtk_Ratio)); }
/** 战前兵营--兵力上限--玩家: * 兵力上限=(城池模块--默认兵力上限+武将模块--兵力上限之和)*参数A; */ public static float WF_Casern_MaxHP(float totalHero_MaxHP) { return((ConstConfig.GetFloat(ConstConfig.ID.War_DV_Casern_MaxHp_DefaultMin) + totalHero_MaxHP) * ConstConfig.GetFloat(ConstConfig.ID.War_DV_Casern_MaxHp_Ratio)); }
/** 战前兵营--防御--玩家 * 防御=(主公模块--战力+武将模块--上阵武将总战力)*战力转换防御参数 */ public static float WF_Casern_Def(float legionInitBattleForce, float totalHero_Def) { // return totalHero_Def + legionInitBattleForce * ConstConfig.GetFloat(ConstConfig.ID.War_DV_BattleForce2Defence_Ratio); return(legionInitBattleForce * ConstConfig.GetFloat(ConstConfig.ID.War_DV_BattleForce2Defence_Ratio)); }
/** 战前势力--怒气 * 初始怒气=(默认最小值)*参数//参数默认为0.01 */ public static float WF_Legion_Mage() { return(ConstConfig.GetFloat(ConstConfig.ID.War_DV_Team_Mage_Default) * ConstConfig.GetFloat(ConstConfig.ID.War_DV_Team_Mage_Ratio)); }
/** 斩杀率 * 斩杀概率=1-(3*B势力防斩杀值/(3*B势力防斩杀值+A势力斩杀值)) */ public static float WD_KillHeroRate(float d_defKillHero, float a_killHero) { float a = ConstConfig.GetFloat(ConstConfig.ID.War_DV_KillHeroRate_Ratio); return(1 - (a * d_defKillHero / (a * d_defKillHero + a_killHero))); }
/** 战前士兵--攻击: * 攻击=(主公模块--战力+武将模块--上阵武将总战力)*战力转换攻击参数 */ public static float WF_Solider_Atk(float legionInitBattleForce, float totalHero_atk) { // return totalHero_atk + legionInitBattleForce * ConstConfig.GetFloat(ConstConfig.ID.War_DV_BattleForce2Atk_Ratio); return(legionInitBattleForce * ConstConfig.GetFloat(ConstConfig.ID.War_DV_BattleForce2Atk_Ratio)); }
/** 战前英雄--防斩杀值--玩家: * 防斩杀值=武将模块--防斩杀值*参数;//参数默认为1 */ public static float WF_Hero_DefKillHero_Player(float defKillHero) { return(defKillHero * ConstConfig.GetFloat(ConstConfig.ID.War_DV_Hero_Player_DefKillHero_Ratio)); }
/** 战前势力--斩将率 * 斩杀率=士兵模块--斩杀等级*参数;//参数默认为0.01 */ public static float WF_Legion_KillHero(float solider_KillHero) { return(solider_KillHero * ConstConfig.GetFloat(ConstConfig.ID.War_DV_Team_KillHero_Ratio)); }