//Computation logic for executing a result. //Depending on the configuration of the card the corresponding results are selected. void computeResult(result res) { ComputeResultTypeDependant(res); executeExtraChanges(changeExtrasOnCardDespawn); foreach (resultModifier rm in changeValueOnCardDespawn) { executeValueChange(rm); } //foreach(Inventory_ChangeItem.itemModifier im in changeItemOnCardDespawn) //{ // Inventory_ChangeItem.executeItemChange(im); //} OnCardDespawn.Invoke(); }
//Computation logic for executing a result. //Depending on the configuration of the card the corresponding results are selected. void computeResult(result res) { if (res.resultType == resultTypes.simple) { //If the result is configured as 'simple' just execute the value modifiers. executeValueChanges(res.modifiers); } else if (res.resultType == resultTypes.conditional) { //If the result is configured as 'conditional' validate the conditions and //execute the depending modifiers. if (AreConditinsForResultMet(res.conditions)) { executeValueChanges(res.modifiersTrue); } else { executeValueChanges(res.modifiersFalse); } } else if (res.resultType == resultTypes.randomConditions) { //If the result is configured as 'randomConditions': //1. Randomize the borders of predefined value-typ dependencies. //2. Validate the new conditions. //3. Execute outcome dependent value changes. float rndResult = 1f; ValueScript v = null; foreach (condition c in res.conditions) { rndResult = Random.Range(0f, 1f); v = valueManager.instance.getFirstFittingValue(c.value); if (v != null) { //set the minimum border for the conditon between min and max, //if the real value is over min, the path 'true' is executed c.valueMin = v.limits.min + rndResult * (v.limits.max - v.limits.min); c.valueMax = v.limits.max; } else { Debug.LogWarning("Missing value type: " + c.value); } } if (AreConditinsForResultMet(res.conditions)) { executeValueChanges(res.modifiersTrue); } else { executeValueChanges(res.modifiersFalse); } } else if (res.resultType == resultTypes.random) { //If the result is configured as 'random': //Select randomly a modifier-group out of the defined pool and execute the value changes. if (res.randomModifiers.Length != 0) { int rndResult = Random.Range(0, res.randomModifiers.Length); executeValueChanges(res.randomModifiers[rndResult]); } else { Debug.LogWarning("Missing random results-list"); } } else { Debug.LogError("Path not reachable?"); } foreach (resultModifier rm in changeValueOnCardDespawn) { valueManager.instance.changeValue(rm.modifier, rm.valueAdd); } OnCardDespawn.Invoke(); }