public bool ShouldFireSkill(SkillFireConditionConfigDetails detailds, int listIndex) { bool result = false; bool isShouldTurnNext = false; if (listIndex <= conditionList.Count - 1 && listIndex >= 0) { result = conditionList[listIndex].CalculateConditionResultWithOutIsShouldGoNext(detailds, out isShouldTurnNext); if (isShouldTurnNext) { //需要去下一个说明到目前都是false 结果由下一个判断条件判断 result = ShouldFireSkill(detailds, listIndex + 1); return(result); } else { //不需要去下一个说明 完成,直接返回结果即可,退出递归 return(result); } } else { //条件判断完了 返回false 退出递归 result = false; return(result); } }
public void CheckFireConditionPathList() { List <SkillFireConditionController> removeList = new List <SkillFireConditionController>(); foreach (SkillFireConditionController fc in skillFireConditionControllerList) { currSkillConfig.castor = gameObject; currSkillConfig.animator = animator; currSkillConfig.skillCanSkillControlDelegate = this; currSkillConfig.skillFinishDelegate = this; currSkillConfig.castorIsEnemy = true; currSkillConfig.targetPosition = playerPosition; currSkillConfig.castorRigidbody2d = rigid2d; SkillFireConditionConfigDetails _details = new SkillFireConditionConfigDetails(); _details.castorHealth = health; _details.castorHealthPresentValue = health / maxHealth; _details.runTimer = survivalTime; if (fc.ShouldFireSkill(_details, 0)) { GameObject skillPrefab = (GameObject)Resources.Load(fc.skillResPath); currSkill = ((GameObject)Instantiate(skillPrefab, transform.position, Quaternion.identity)).GetComponent <Skill>(); currSkill.transform.position = transform.position; currSkill.transform.parent = transform; currSkill.ConfigSkill(currSkillConfig); currSkill.CastSkill(); removeList.Add(fc); } } foreach (SkillFireConditionController fc in removeList) { skillFireConditionControllerList.Remove(fc); } }
public bool CalculateConditionResultWithOutIsShouldGoNext(SkillFireConditionConfigDetails _details, out bool _isShouldGoNext) { bool conditionResult = true; //判断条件结果 conditionResult = CalculateConditionResult(_details); //判断是否继续执行 _isShouldGoNext = CalculateShouldResult(conditionResult); return(conditionResult); }
private bool CalculateConditionResult(SkillFireConditionConfigDetails _details) { bool conditionResult = false; //拼凑判断条件 switch (firstType) { case SkillFireConditionValueType.CastorHpPresent: firstValue = _details.castorHealthPresentValue; break; case SkillFireConditionValueType.TargetHpPresent: firstValue = _details.targetHealthPresentValue; break; case SkillFireConditionValueType.CastorHp: firstValue = _details.castorHealth; break; case SkillFireConditionValueType.TargetHp: firstValue = _details.targetHealth; break; case SkillFireConditionValueType.Timer: firstValue = _details.runTimer; break; } switch (compareType) { case SkillFireConditionValueType.FloatValue: break; case SkillFireConditionValueType.Present: break; } //判断条件 switch (condition) { case SkillFireConditionType.Greater: if (firstValue > compareValue) { conditionResult = true; } else { conditionResult = false; } break; case SkillFireConditionType.GreaterEqual: if (firstValue >= compareValue) { conditionResult = true; } else { conditionResult = false; } break; case SkillFireConditionType.Equal: if (firstValue == compareValue) { conditionResult = true; } else { conditionResult = false; } break; case SkillFireConditionType.LessEqual: if (firstValue <= compareValue) { conditionResult = true; } else { conditionResult = false; } break; case SkillFireConditionType.Less: if (firstValue < compareValue) { conditionResult = true; } else { conditionResult = false; } break; } return(conditionResult); }