public void ChangeParameterValue(string paramName, float newValue) { if (Parameter.Any(t => t.Name == paramName)) { Parameter.First(t => t.Name == paramName).Value = newValue; } //This is not the optimal solution BT_WeightedSelector selector = BT_Culture.GetChild(0) as BT_WeightedSelector; if (selector == null) { return; } int index = paramName == "Behaviour" ? 0 : paramName == "Communication" ? 1 : paramName == "Economics" ? 2 : paramName == "Sociology" ? 3 : -1; selector.ChangeWeight(index, newValue); }