public RectangleObject(int id, Point leftTop, Point rightBottom, Brush stroke, double strokeThickness, Brush fill, LineHit lineHit)
        {
            Freeze();

            ShapeId = id;

            var rightTop   = new Point(rightBottom.X, leftTop.Y);
            var leftBottom = new Point(leftTop.X, rightBottom.Y);

            state = new RectangleState {
                TopLeft = leftTop, TopRight = rightTop, BottomRight = rightBottom, BottomLeft = leftBottom, StrokeThickness = strokeThickness
            };

            freeBehaviour = new FreeRectangleBehaviour(state, lineHit);

            behaviours = new List <ShapeBehaviour <RectangleState> > {
                new ResizeRectangleBehaviour(state, lineHit),
                new SelectRectangleBehaviour(state),
                freeBehaviour,
            };

            currentBehaviour = freeBehaviour;

            Shape = new DrawingVisual();

            Stroke = stroke;
            Fill   = fill;

            Unfreeze();
        }
Exemple #2
0
        public PolyLineObject(int id, System.Windows.Point start, System.Windows.Point end, Brush stroke, double strokeThickness, LineHit lineHit)
        {
            Freeze();

            ShapeId = id;

            state = new PoliLineState {
                StrokeThickness = strokeThickness, Points = new List <System.Windows.Point> {
                    start, end
                }
            };

            freeBehaviour    = new FreePoliLineBehaviour(state, lineHit);
            currentBehaviour = freeBehaviour;

            behaviours = new List <ShapeBehaviour <PoliLineState> > {
                new PointPolyLineBehaviour(state, lineHit),
                new SelectPolyLineBehaviour(state),
                freeBehaviour
            };

            Shape  = new DrawingVisual();
            Stroke = stroke;

            Unfreeze();
        }
Exemple #3
0
    public override void Load(GameDataReader reader)
    {
        base.Load(reader);
        if (reader.Version >= 5)
        {
            LoadColors(reader);
        }
        else
        {
            SetColor(reader.Version > 0 ? reader.ReadColor() : Color.white);
        }

        if (reader.Version >= 6)
        {
            Age = reader.ReadFloat();
            int behaviourCount = reader.ReadInt();
            for (int i = 0; i < behaviourCount; ++i)
            {
                ShapeBehaviour behabviour = ((ShapeBehaviourType)reader.ReadInt()).GetInstance();
                behaviourList.Add(behabviour);
                behabviour.Load(reader);
            }
        }
        else if (reader.Version >= 4)
        {
            AddBehaviour <RotationShapeBehaviour>().AngularVelocity = reader.ReadVector3();
            AddBehaviour <MovementShapeBehaviour>().Velocity        = reader.ReadVector3();
        }
    }