public void calMonsterData(Excel.Worksheet v_monsterSheet) { Excel.Cells data = v_monsterSheet.Cells; SheetHeader header = new SheetHeader(); header.readHeader(v_monsterSheet, 1); m_monsterAttr = new List <MonsterAttr>(); //读取设置数据 for (int i = 2; true; i++) { object oid = header.getData(data, i, "ID"); if (oid == null || string.IsNullOrWhiteSpace(oid.ToString())) { break; } MonsterAttr tmp = new MonsterAttr(); tmp.id = Convert.ToInt32(oid); tmp.note = header.getData(data, i, "备注").ToString(); tmp.groupID = Convert.ToInt32(header.getData(data, i, "组ID")); tmp.level = Convert.ToInt32(header.getData(data, i, "等级")); tmp.iniAngry = Convert.ToInt32(header.getData(data, i, "初始怒气")); tmp.angryRecover = Convert.ToInt32(header.getData(data, i, "怒气回复")); tmp.killMonsterRound = Convert.ToSingle(header.getData(data, i, "玩家杀怪回合数")); tmp.hpCost = Convert.ToSingle(header.getData(data, i, "消耗血量")); tmp.phisicalDefPercent = Convert.ToSingle(header.getData(data, i, "物防百分比")); tmp.magicalDefPercent = Convert.ToSingle(header.getData(data, i, "法防百分比")); tmp.playerCureNum = Convert.ToSingle(header.getData(data, i, "玩家治疗数")); tmp.monsterCureNum = Convert.ToSingle(header.getData(data, i, "怪物治疗数")); m_monsterAttr.Add(tmp); } //进行计算,并填表 for (int i = 0; i < m_monsterAttr.Count; i++) { MonsterAttr cur = m_monsterAttr[i]; int playerIdx = getPlayerAttrIdx(cur.groupID, cur.level); BaseAttrData playerAttr = m_playerAttrdatas[playerIdx]; cur.playerAttr = playerAttr; cur.calMonsterAttr(); header.setData(data, i + 2, "玩家血量", playerAttr.Hp); header.setData(data, i + 2, "玩家攻击", playerAttr.Atk); header.setData(data, i + 2, "玩家物防", playerAttr.PhisicalDef); header.setData(data, i + 2, "玩家法防", playerAttr.MagicalDef); header.setData(data, i + 2, "怪物血量", cur.monsterAttr.Hp); header.setData(data, i + 2, "怪物攻击", cur.monsterAttr.Atk); header.setData(data, i + 2, "怪物物防", cur.monsterAttr.PhisicalDef); header.setData(data, i + 2, "怪物法防", cur.monsterAttr.MagicalDef); } }
//protected List<BaseAttrData> monsterAttr; public void calPlayerAttr(Excel.Worksheet v_monsterSheet) { const int OFF_Y = 2; Excel.Cells data = v_monsterSheet.Cells; m_playerAttrdatas = new List <BaseAttrData>(); m_playerAttrIndex = new Dictionary <int, List <int> >(); SheetHeader header = new SheetHeader(); header.readHeader(v_monsterSheet, 1); for (int i = 0; i < m_playerDatas.Count; i++) { BaseAttrData attrVal = new BaseAttrData(); attrVal.init(); BaseAttrData attrFac = new BaseAttrData(); attrFac.init(); playerData pd = m_playerDatas[i]; //计算武将属性 attrVal = attrVal + m_heroAttr * pd.heroAptitude * (pd.level + 10) * (float)Math.Pow(1.2, (double)pd.heroBreak); //计算武器 attrVal = attrVal + m_equipStrengthenData.Weapon * (8 + pd.equipStrengthenLv); //计算胸甲 attrVal = attrVal + m_equipStrengthenData.Breast * (8 + pd.equipStrengthenLv); //计算头盔 attrVal = attrVal + m_equipStrengthenData.halmet * (8 + pd.equipStrengthenLv); //计算鞋子 attrVal = attrVal + m_equipStrengthenData.shoose * (8 + pd.equipStrengthenLv); //计算神器 attrFac = attrFac + m_equipStrengthenData.almulet_1 * (10 + pd.amulet_level) * pd.heroNum; //计算圣器 attrFac = attrFac + m_equipStrengthenData.almulet_2 * (10 + pd.amulet_level) * pd.heroNum; //计算装备突破 for (int j = 0; j < 4; j++) { attrFac = attrFac + m_equipBreakupData.getData(j + 1, pd.equipBreakLv); } //计算宝物精炼 for (int j = 0; j < pd.amuletQualityArrHp.Length; j++) { attrVal = attrVal + m_amuletRecoinData.getData(0, j, pd.amulet_recoin) * pd.amuletQualityArrHp[j]; attrVal = attrVal + m_amuletRecoinData.getData(1, j, pd.amulet_recoin) * pd.amuletQualityArrAtk[j]; } //计算战宠培养 attrVal = attrVal + m_petFosterData.levelData[pd.pet_level] * pd.heroNum; //计算战宠星语 attrFac = attrFac + m_petStarData.levelData[pd.pet_xingyu] * pd.heroNum; //计算最终结果 attrVal = attrVal / pd.heroNum; attrFac = attrFac / pd.heroNum; BaseAttrData finalAttr = attrVal * attrFac; //考虑英雄技能系数 float avgSkillFac = 0; for (int j = 0; j < 5; j++) { avgSkillFac += m_skillFac[j] * pd.heroQualitys[j]; } avgSkillFac /= pd.heroNum; finalAttr.Atk *= avgSkillFac; float[] arrAttr = new float[] { (float)Math.Round(finalAttr.Hp, 2), (float)Math.Round(finalAttr.Atk, 2), (float)Math.Round(finalAttr.PhisicalDef, 2), (float)Math.Round(finalAttr.MagicalDef, 2) }; BaseAttrData bad = new BaseAttrData(); bad.init(arrAttr); List <int> arrPlayerAttrIndex = null; if (!m_playerAttrIndex.ContainsKey(pd.groupID)) { arrPlayerAttrIndex = new List <int>(); m_playerAttrIndex.Add(pd.groupID, arrPlayerAttrIndex); } else { arrPlayerAttrIndex = m_playerAttrIndex[pd.groupID]; } arrPlayerAttrIndex.Add(m_playerAttrdatas.Count); m_playerAttrdatas.Add(bad); header.setData(data, OFF_Y + i, "玩家血", bad.Hp); header.setData(data, OFF_Y + i, "玩家攻", bad.Atk); header.setData(data, OFF_Y + i, "玩家物防", bad.PhisicalDef); header.setData(data, OFF_Y + i, "玩家法防", bad.MagicalDef); } }