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);
            }
        }
예제 #3
0
        private void HandleSpeedLimitSignpostCollision(SpeedLimitSignpost collider)
        {
            collider.InitiateCollisionEffect();

            if (_motionEngine.AvailableSpeedRangeSteps != collider.SpeedRange)
            {
                if (!_motionEngine.SpeedIsOverridden)
                {
                    if ((collider.SpeedRange.Minimum > _motionEngine.AvailableSpeedRangeSteps.Minimum) ||
                        (collider.SpeedRange.Maximum > _motionEngine.AvailableSpeedRangeSteps.Maximum))
                    {
                        SoundEffectManager.PlayEffect("speed-up");
                    }
                    else if ((collider.SpeedRange.Minimum < _motionEngine.AvailableSpeedRangeSteps.Minimum) ||
                        (collider.SpeedRange.Maximum < _motionEngine.AvailableSpeedRangeSteps.Maximum))
                    {
                        SoundEffectManager.PlayEffect("slow-down");
                    }
                }

                _motionEngine.AvailableSpeedRangeSteps = collider.SpeedRange;
            }
        }