public override void UpdateVal(egVar var) { if (var.GetType() == typeof(egFloat)) { updated = true; egFloat s = (egFloat)var; _Value = s; } else { Console.WriteLine("Type: " + var.GetType() + " not supported by egString"); } }
/// <summary> /// This method will update all the variables binded to the Game Parameter "subject" /// </summary> /// <param name="subject">Game Parameters inherit Subject class</param> public void UpdateRoutine(Subject subject) { // creating a generic variable egVar and instantiating the correct type // the eg types are the same implemented as parameters (string, int, bool, double) egVar var; GameParameter gp = (GameParameter)subject; if (subject.GetType() == typeof(IntParameter)) { IntParameter iP = (IntParameter)subject; egInt i = iP.Value; var = i; } else if (subject.GetType() == typeof(BoolParameter)) { BoolParameter bP = (BoolParameter)subject; egBool b = bP.Value; var = b; } else if (subject.GetType() == typeof(StringListParameter)) { StringListParameter sP = (StringListParameter)subject; egString s = sP.Value; var = s; } else if (subject.GetType() == typeof(StringParameter)) { StringParameter sP = (StringParameter)subject; egString s = sP.Value; Debug.Log((string)s + " variable Handler test"); var = s; } else if (subject.GetType() == typeof(RangeParameter)) { RangeParameter fP = (RangeParameter)subject; egFloat s = fP.Value; var = s; } else { // if the type is not registered something went wrong Debug.Log("ERROR, type: " + subject.GetType() + " not defined as a parameter type. Check parameter types."); return; } //then we will update the variables UpdateVariables(var, gp.Name); }