public void Start( ) { if (_started) { return; } _propertyInfo = _propertiesThisAppliesTo.GetType( ).GetProperty(_behaviourProperties.NameOfPropertyToModify); if (_propertyInfo.PropertyType != typeof(Vector2)) { throw new InvalidOperationException(@"Only Vector2 properties are valid for animating positions."); } _originalValue = _propertyInfo.GetValue(_propertiesThisAppliesTo, null); _tweener = new Vector2Tweener( _behaviourProperties.From, _behaviourProperties.To, TimeSpan.FromSeconds(_behaviourProperties.DurationInSeconds), Tweener.CreateTweeningFunction( Type.GetType(_behaviourProperties.ClrTypeOfInterpolator), _behaviourProperties.Easing)); _started = true; }
void instantiateEditorForProperties(ItemProperties itemProperties) { string editorName = @"{0}Editor".FormatWith(itemProperties.GetType( ).Name); Type t = Type.GetType(editorName); if (t == null) { throw new InvalidOperationException( @"Cannot instantiate an editor named '{0}' for the item properties of type '{1}'. No such editor exists.". FormatWith( editorName, itemProperties.GetType( ))); } Activator.CreateInstance(t, this, itemProperties); }
public virtual XElement ToXml( ) { return(new XElement( @"Editor", new XAttribute(@"ClrTypeOfEditor", GetType( ).AssemblyQualifiedName), // we need to write the properties type so that in-game component can recreate them new XAttribute(@"ClrTypeOfProperties", ItemProperties.GetType( ).AssemblyQualifiedName), new XAttribute(@"Name", Name), ItemProperties.SerializeToXml( ), Behaviours.ToXml( ) )); }
public void Start( ) { if (_started) { return; } _propertyInfo = _propertiesThisAppliesTo.GetType( ).GetProperty(_behaviourProperties.NameOfPropertyToModify); _originalValue = _propertyInfo.GetValue(_propertiesThisAppliesTo, null); _tweener = new Tweener( _behaviourProperties.From, _behaviourProperties.To, TimeSpan.FromSeconds(_behaviourProperties.DurationInSeconds), Tweener.CreateTweeningFunction( Type.GetType(_behaviourProperties.ClrTypeOfInterpolator), _behaviourProperties.Easing)); _started = true; }