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 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_); }