private void CreateSignpostFromXmlNode(XElement node) { SignpostBase newSignpost = null; switch (node.Name.ToString()) { case OneWaySignpost.Data_Node_Name: newSignpost = new OneWaySignpost(); ((OneWaySignpost)newSignpost).Mirror = (bool)node.Attribute("mirror"); break; case SpeedLimitSignpost.Data_Node_Name: newSignpost = new SpeedLimitSignpost(); ((SpeedLimitSignpost)newSignpost).SpeedRange = new Range((int)node.Attribute("minimum-speed"), (int)node.Attribute("maximum-speed")); break; } if (newSignpost != null) { newSignpost.ID = string.Concat(Signpost_Serialized_Data_Identifier, _nextSignpostID++); newSignpost.TextureReference = node.Attribute("texture").Value; newSignpost.Texture = TextureManager.Textures[node.Attribute("texture").Value]; newSignpost.SetCollisionBoundingBox((float)node.Attribute("zone-top")); newSignpost.WorldPosition = new Vector2( (float)node.Attribute("x") + (Definitions.Grid_Cell_Pixel_Size / 2.0f), (float)node.Attribute("y") + (Definitions.Grid_Cell_Pixel_Size / 2.0f) + SignpostBase.Plate_Vertical_Offset); _registerComponent(newSignpost); } }
public static void ReinstateSerializedSignposts(List <XElement> signpostData) { foreach (XElement el in signpostData) { SignpostBase newSignpost = (SignpostBase)Activator.CreateInstance(Type.GetType(el.Attribute("type").Value)); newSignpost.ID = el.Attribute("id").Value; Factory._registerComponent(newSignpost); } }
private void HandleSignpostCollision(SignpostBase collider) { if (collider is OneWaySignpost) { HandleOneWaySignpostCollision((OneWaySignpost)collider); } if (collider is SpeedLimitSignpost) { HandleSpeedLimitSignpostCollision((SpeedLimitSignpost)collider); } }