private void SetSuccessRate(int id, List <int> emps) { if (emps.Count == 0) { EmployeeQuestData qData = EmployeeQuestData.GetData(_taskId); SuccessRate0.text = qData.successRate_ + "%"; SuccessRate1.text = "0%"; SuccessRate2.text = "0%"; return; } int rate = (int)EmployeeTaskSystem.CalcSuccessRate(id, emps); SuccessRate0.text = rate + "%"; if (rate - 100 > 0) { SuccessRate1.text = (rate - 100) + "%"; } else { SuccessRate1.text = "0%"; } if (rate - 200 > 0) { SuccessRate2.text = (rate - 200) + "%"; } else { SuccessRate2.text = "0%"; } empNumLab.text = (GamePlayer.Instance.EmployeeList.Count - GamePlayer.Instance.GetBattleEmployees().Count - EmployeeTaskSystem.instance.GetTaskEmpNum()) + "/" + GamePlayer.Instance.EmployeeList.Count; }
public void UpdateEmpList() { for (int i = 0; i < CellList.Count; ++i) { employeeListGuid.RemoveChild(CellList[i].transform); CellList[i].transform.parent = null; CellList[i].gameObject.SetActive(false); } CellList.Clear(); List <Employee> employeeList = GamePlayer.Instance.EmployeeList; for (int i = 0; i < employeeList.Count; i++) { //if(employeeList[i].isForBattle_) // continue; if (EmployeeTaskSystem.instance.IsTaskEmp(employeeList[i].InstId)) { continue; } GameObject objCell = Object.Instantiate(employeeListCell.gameObject) as GameObject; UIManager.SetButtonEventHandler(objCell.gameObject, EnumButtonEvent.OnClick, OnEmpOn, employeeList[i].InstId, 0); EmployeeTaskInfoCell cell = objCell.GetComponent <EmployeeTaskInfoCell>(); cell.monster = EmployeeQuestData.GetData(_taskId).monsterList; cell.EmpData = employeeList[i]; objCell.transform.parent = employeeListGuid.transform; objCell.SetActive(true); objCell.transform.localScale = Vector3.one; CellList.Add(objCell); } employeeListGuid.Reposition(); }
private void OnEmpOn(ButtonScript obj, object args, int param1, int param2) { EmployeeQuestData qData = EmployeeQuestData.GetData(_taskId); if (empTaskList.Count >= qData.employeeRequier_) { return; } if (empTaskList.Contains(param1)) { return; } empTaskList.Add(param1); UpdateBattleEmp(empTaskList); SetSuccessRate(TaskId, empTaskList); }
private void OnStart(ButtonScript obj, object args, int param1, int param2) { EmployeeQuestData qData = EmployeeQuestData.GetData(_taskId); if (qData == null) { return; } if (empTaskList.Count < qData.employeeRequier_) { PopText.Instance.Show(LanguageManager.instance.GetValue("renshubuzhu")); return; } if (GamePlayer.Instance.GetIprop(PropertyType.PT_Money) < qData.needMoney_) { PopText.Instance.Show(LanguageManager.instance.GetValue("nomoney")); return; } NetConnection.Instance.acceptEmployeeQuest(_taskId, empTaskList.ToArray()); }
public static void ParseData(string content, string fileName) { metaData = new Dictionary <int, EmployeeQuestData> (); CSVParser parser = new CSVParser(); if (!parser.Parse(content)) { ClientLog.Instance.LogError("EmployeeQuest" + ConfigLoader.Instance.csvext + "解析错误"); return; } int recordCounter = parser.GetRecordCounter(); EmployeeQuestData data = null; for (int i = 0; i < recordCounter; ++i) { data = new EmployeeQuestData(); data.id_ = parser.GetInt(i, "EQID"); data.name_ = parser.GetString(i, "EQName"); string[] monsters = parser.GetString(i, "EmployeeMonster").Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (monsters.Length == 1) { data.employeeMonster_ = int.Parse(monsters[0]); data.employeeMonster_1 = 0; data.employeeMonster_2 = 0; } else if (monsters.Length == 2) { data.employeeMonster_ = int.Parse(monsters[0]); data.employeeMonster_1 = int.Parse(monsters[1]); data.employeeMonster_2 = 0; } else if (monsters.Length == 3) { data.employeeMonster_ = int.Parse(monsters[0]); data.employeeMonster_1 = int.Parse(monsters[1]); data.employeeMonster_2 = int.Parse(monsters[2]); } data.monsterList.Add(data.employeeMonster_); if (data.employeeMonster_1 != 0) { data.monsterList.Add(data.employeeMonster_1); } if (data.employeeMonster_2 != 0) { data.monsterList.Add(data.employeeMonster_2); } data.employeeQuestColor_ = (EmployeeQuestColor)Enum.Parse(typeof(EmployeeQuestColor), parser.GetString(i, "EmployeeQuestColor")); data.timeRequier_ = parser.GetInt(i, "TimeRequier"); data.employeeRequier_ = parser.GetInt(i, "EmployeeRequier"); data.successRate_ = parser.GetInt(i, "SuccessRate"); data.award1_ = parser.GetInt(i, "award1"); data.award2_ = parser.GetInt(i, "award2"); data.award3_ = parser.GetInt(i, "award3"); data.needMoney_ = parser.GetInt(i, "cost"); 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_); }