コード例 #1
0
    private IGameObject CreateObjectAt(Vector pos)
    {
        if (application.SnapToGrid)
        {
            int snap = 32;
            pos = new Vector((float)((int)pos.X / snap) * snap,
                             (float)((int)pos.Y / snap) * snap);
        }
        IGameObject gameObject = (IGameObject)CreateObject();

        if (gameObject is IObject)
        {
            IObject    obj  = (IObject)gameObject;
            RectangleF rect = obj.Area;
            rect.MoveTo(pos);
            obj.ChangeArea(rect);
        }
        if (gameObject is IPathObject)
        {
            Path path = ((IPathObject)gameObject).Path;
            if (path != null)
            {
                if (path.Nodes.Count == 0)
                {
                    path.Nodes.Add(new Path.Node());
                }
                path.Nodes[0].Pos = pos;
            }
        }

        sector.Add(gameObject, objectType.ToString());
        Redraw();
        return(gameObject);
    }
コード例 #2
0
    public void ChangeArea(RectangleF Area)
    {
        float adjust = SIZE / 2f + DISTANCE;

        RectangleF newArea = Object.Area;

        if ((attachPoint & AttachPoint.TOP) != 0)
        {
            newArea.Top = Area.Top + adjust;
        }
        else if ((attachPoint & AttachPoint.BOTTOM) != 0)
        {
            newArea.Bottom = Area.Bottom - adjust;
        }
        if ((attachPoint & AttachPoint.LEFT) != 0)
        {
            newArea.Left = Area.Left + adjust;
        }
        else if ((attachPoint & AttachPoint.RIGHT) != 0)
        {
            newArea.Right = Area.Right - adjust;
        }
        Object.ChangeArea(newArea);
        area = Area;
    }
コード例 #3
0
ファイル: ObjectsEditor.cs プロジェクト: slackstone/tuxjunior
    private void moveObject(Vector mousePos, int snap)
    {
        RectangleF newArea = getNewPosition(mousePos, snap);

        activeObject.ChangeArea(newArea);
        Redraw();
    }
コード例 #4
0
 public override void Do()
 {
     changedObject.ChangeArea(newArea);
 }