public static void ParseData(string content, string fileName) { metaData = new Dictionary <int, EmployeeMonsterData> (); CSVParser parser = new CSVParser(); if (!parser.Parse(content)) { ClientLog.Instance.LogError("EmployeeQuest" + ConfigLoader.Instance.csvext + "解析错误"); return; } int recordCounter = parser.GetRecordCounter(); EmployeeMonsterData data = null; for (int i = 0; i < recordCounter; ++i) { data = new EmployeeMonsterData(); data.id_ = parser.GetInt(i, "ID"); data.name_ = parser.GetString(i, "Name"); data.assteId_ = parser.GetInt(i, "AssetsID"); data.icon_ = parser.GetString(i, "Icon"); string[] skill = parser.GetString(i, "Skill").Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (skill.Length > 1) { data.skill_0 = (EmployeeSkillType)Enum.Parse(typeof(EmployeeSkillType), skill[0]); data.skill_1 = (EmployeeSkillType)Enum.Parse(typeof(EmployeeSkillType), skill[1]); } else { data.skill_0 = (EmployeeSkillType)Enum.Parse(typeof(EmployeeSkillType), skill[0]); data.skill_1 = EmployeeSkillType.EKT_Max; } data.skills.Add((int)data.skill_0); data.skills.Add((int)data.skill_1); if (metaData.ContainsKey(data.id_)) { ClientLog.Instance.LogError("EmployeeData" + ConfigLoader.Instance.csvext + "ID重复"); return; } metaData[data.id_] = data; } parser.Dispose(); parser = null; }
public static float CalcSuccessRate(int questId, List <int> employees) { EmployeeQuestData quest = EmployeeQuestData.GetData(questId); if (null == quest) { return(0.0F); } List <EmployeeContext> contexts = new List <EmployeeContext>(); for (int i = 0; i < employees.Count; ++i) { Employee employee = GamePlayer.Instance.GetEmployeeById(employees[i]); if (null == employee) { //ACE_DEBUG((LM_ERROR,"EmployeeQuestSystem::CalcSuccessRate [[ player(%d) not haved employee(%d) at employee quest(%d)\n",playerId,questInst.usedEmployees_[i],questInst.questId_)); continue; } for (int j = 0; j < employee.SkillInsts.Count; ++j) { if (employee.SkillInsts[j] == null) { continue; } EmployeeContext c = new EmployeeContext(); c.star_ = (int)employee.star_; c.color_ = (int)employee.quality_; c.skId_ = (int)employee.SkillInsts[j].skillID_; c.skLevel_ = (int)employee.SkillInsts[j].skillLevel_; contexts.Add(c); } } if (contexts.Count == 0) { // ACE_DEBUG((LM_ERROR,"EmployeeQuestSystem::CalcSuccessRate [[ player(%d) empty employee at employee quest(%d)\n",playerId,questInst.questId_)); return(0.0F); } float maxRate = 0.0F; for (int i = 0; i < quest.monsterList.Count; ++i) { EmployeeMonsterData monster = EmployeeMonsterData.GetData(quest.monsterList[i]); if (null == monster) { continue; } for (int k = 0; k < monster.skills.Count; ++k) { int usedIndex = -1; float usedRate = 0.0F; for (int j = 0; j < contexts.Count; ++j) { int successRate = EmployeeQuestSkillData.GetData(contexts[j].skId_, (EmployeeSkillType)monster.skills[k]); float rate = CalcEmployeeQuestSuccessRate(contexts[j].skLevel_, contexts[j].star_, contexts[j].color_, successRate, quest.monsterList.Count); if (rate > usedRate) { usedRate = rate; usedIndex = j; } } if (usedIndex != -1) { contexts.RemoveAt(usedIndex); } maxRate += usedRate; } } return(maxRate + quest.successRate_); }