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);
            }
        }
        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);
            }
        }
Exemplo n.º 3
0
 private void HandleOneWaySignpostCollision(OneWaySignpost collider)
 {
     if ((collider.Mirror != _motionEngine.IsMovingLeft) && (IsHorizontallyCloseEnoughForEffect(collider, Signpost_Effect_Distance)))
     {
         SoundEffectManager.PlayEffect("turn-round");
         ChangeHorizontalMovementDirection();
     }
 }