Exemplo n.º 1
0
    private void OnObjectAdded(Sector sector, IGameObject Object)
    {
        if (Object is IObject)
        {
            IObject iObject = (IObject)Object;
            Node    node    = iObject.GetSceneGraphNode();
            if (node != null)
            {
                objectsNode.AddChild(node);
            }
        }

        Layer layer = (Layer)SceneGraphRoot;

        if (Object is Tilemap)
        {
            Tilemap   tilemap   = (Tilemap)Object;
            Node      tnode     = new TilemapNode(tilemap, level.Tileset);
            ColorNode colorNode = new ColorNode(tnode, new Color(1f, 1f, 1f, 1f));
            layer.Add(tilemap.ZPos, colorNode);
            LogManager.Log(LogLevel.Debug, "Adding tilemap color: {0}", Object.GetHashCode());
            colors[tilemap] = colorNode;
        }

        if (Object is Background)
        {
            Background background = (Background)Object;

            Node mynode = background.GetSceneGraphNode();
            if (mynode != null)
            {
                backgroundNode.AddChild(mynode);
            }
        }
    }
Exemplo n.º 2
0
    public SectorRenderer(Application application, Level level, Sector sector)
    {
        this.application = application;
        this.level       = level;
        this.sector      = sector;
        Layer layer = new Layer();

        foreach (IDrawableLayer IDrawableLayer in sector.GetObjects(typeof(IDrawableLayer)))
        {
            Node node = IDrawableLayer.GetSceneGraphNode();
            if (IDrawableLayer is Tilemap)              //Special handling for tilemaps
            {
                node = new TilemapNode((Tilemap)IDrawableLayer, level.Tileset);
            }
            ColorNode colorNode = new ColorNode(node, new Color(1f, 1f, 1f, 1f), true);
            layer.Add(IDrawableLayer.Layer, colorNode);
            colors[IDrawableLayer] = colorNode;
        }

        objectsNode      = new NodeWithChilds();
        objectsColorNode = new ColorNode(objectsNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(1, objectsColorNode);

        foreach (IObject Object in sector.GetObjects(typeof(IObject)))
        {
            Node node = Object.GetSceneGraphNode();
            if (node != null)
            {
                objectsNode.AddChild(node);
            }
        }

        // fill remaining place with one color
        sectorFill      = new SceneGraph.Rectangle();
        sectorFill.Fill = true;
        ColorNode color = new ColorNode(sectorFill, new Drawing.Color(0.4f, 0.3f, 0.4f));

        layer.Add(-10000, color);

        // draw border around sector...
        sectorBBox      = new SceneGraph.Rectangle();
        sectorBBox.Fill = false;
        color           = new ColorNode(sectorBBox, new Drawing.Color(1, 0.3f, 1));
        layer.Add(1000, color);

        // draw border around selected layer...
        color = new ColorNode(new TilemapBorder(application), new Drawing.Color(1, 1, 0));
        layer.Add(1001, color);

        OnSizeChanged(sector);

        this.SceneGraphRoot = layer;

        sector.ObjectAdded         += OnObjectAdded;
        sector.ObjectRemoved       += OnObjectRemoved;
        sector.SizeChanged         += OnSizeChanged;
        application.TilemapChanged += OnTilemapChanged;
        //TODO: It should be possible to iterate over all (currently present?) types that implements ILayer.. How?
        FieldOrProperty.AnyFieldChanged += OnFieldChanged;
    }
Exemplo n.º 3
0
    public SectorRenderer(Application application, Level level, Sector sector)
    {
        this.application = application;
        this.level = level;
        this.sector = sector;
        Layer layer = new Layer();

        foreach(IDrawableLayer IDrawableLayer in sector.GetObjects(typeof(IDrawableLayer))) {
            Node node = IDrawableLayer.GetSceneGraphNode();
            if (IDrawableLayer is Tilemap)	//Special handling for tilemaps
                node = new TilemapNode((Tilemap) IDrawableLayer, level.Tileset);
            ColorNode colorNode = new ColorNode(node, new Color(1f, 1f, 1f, 1f), true);
            layer.Add(IDrawableLayer.Layer, colorNode);
            colors[IDrawableLayer] = colorNode;
        }

        objectsNode = new NodeWithChilds();
        objectsColorNode = new ColorNode(objectsNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(1, objectsColorNode);

        foreach(IObject Object in sector.GetObjects(typeof(IObject))) {
            Node node = Object.GetSceneGraphNode();
            if(node != null)
                objectsNode.AddChild(node);
        }

        // fill remaining place with one color
        sectorFill = new SceneGraph.Rectangle();
        sectorFill.Fill = true;
        ColorNode color = new ColorNode(sectorFill, new Drawing.Color(0.4f, 0.3f, 0.4f));
        layer.Add(-10000, color);

        // draw border around sector...
        sectorBBox = new SceneGraph.Rectangle();
        sectorBBox.Fill = false;
        color = new ColorNode(sectorBBox, new Drawing.Color(1, 0.3f, 1));
        layer.Add(1000, color);

        // draw border around selected layer...
        color = new ColorNode(new TilemapBorder(application), new Drawing.Color(1, 1, 0));
        layer.Add(1001, color);

        OnSizeChanged(sector);

        this.SceneGraphRoot = layer;

        sector.ObjectAdded += OnObjectAdded;
        sector.ObjectRemoved += OnObjectRemoved;
        sector.SizeChanged += OnSizeChanged;
        application.TilemapChanged += OnTilemapChanged;
        //TODO: It should be possible to iterate over all (currently present?) types that implements ILayer.. How?
        FieldOrProperty.AnyFieldChanged += OnFieldChanged;
    }
    public SectorRenderer(Level level, Sector sector)
    {
        this.level = level;
        Layer layer = new Layer();

        backgroundNode = new NodeWithChilds();
        backgroundColorNode = new ColorNode(backgroundNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(-900, backgroundColorNode);
        foreach(Background background in sector.GetObjects(typeof(Background))) {
            Node node = background.GetSceneGraphNode();
            if(node == null) continue;
            backgroundNode.AddChild(node);
        }

        foreach(Tilemap tilemap in sector.GetObjects(typeof(Tilemap))) {
            Node node = new TilemapNode(tilemap, level.Tileset);
            ColorNode colorNode = new ColorNode(node, new Color(1f, 1f, 1f, 1f));
            layer.Add(tilemap.ZPos, colorNode);
            colors[tilemap] = colorNode;
        }

        objectsNode = new NodeWithChilds();
        objectsColorNode = new ColorNode(objectsNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(1, objectsColorNode);

        foreach(IObject Object in sector.GetObjects(typeof(IObject))) {
            Node node = Object.GetSceneGraphNode();
            if(node != null)
                objectsNode.AddChild(node);
        }

        // draw border around sector...
        sectorFill = new SceneGraph.Rectangle();
        sectorFill.Fill = true;
        ColorNode color = new ColorNode(sectorFill, new Drawing.Color(0.4f, 0.3f, 0.4f));
        layer.Add(-10000, color);

        sectorBBox = new SceneGraph.Rectangle();
        sectorBBox.Fill = false;
        color = new ColorNode(sectorBBox, new Drawing.Color(1, 0.3f, 1));
        layer.Add(1000, color);

        OnSizeChanged(sector);

        this.SceneGraphRoot = layer;

        sector.ObjectAdded += OnObjectAdded;
        sector.ObjectRemoved += OnObjectRemoved;
        sector.SizeChanged += OnSizeChanged;

        Drag.DestSet(this, DestDefaults.All, ObjectListWidget.DragTargetEntries, Gdk.DragAction.Default);
        DragMotion += OnDragMotion;
    }
Exemplo n.º 5
0
    private void OnObjectAdded(Sector sector, IGameObject Object)
    {
        if (Object is IObject)
        {
            IObject iObject = (IObject)Object;
            Node    node    = iObject.GetSceneGraphNode();
            if (node != null)
            {
                objectsNode.AddChild(node);
            }
        }

        Layer layer = (Layer)SceneGraphRoot;

        if (Object is Tilemap)
        {
            Tilemap   tilemap   = (Tilemap)Object;
            Node      tnode     = new TilemapNode(tilemap, level.Tileset);
            ColorNode colorNode = new ColorNode(tnode, new Color(1f, 1f, 1f, 1f));
            layer.Add(tilemap.Layer, colorNode);
            colors[tilemap] = colorNode;
        }

        if (Object is IDrawableLayer)
        {
            IDrawableLayer IDrawableLayer = (IDrawableLayer)Object;

            Node mynode = IDrawableLayer.GetSceneGraphNode();
            if (mynode != null)
            {
                ColorNode colorNode = new ColorNode(mynode, new Color(1f, 1f, 1f, 1f));
                layer.Add(IDrawableLayer.Layer, colorNode);
                colors[IDrawableLayer] = colorNode;
            }
        }
    }
Exemplo n.º 6
0
    private void OnObjectAdded(Sector sector, IGameObject Object)
    {
        if(Object is IObject) {
            IObject iObject = (IObject) Object;
            Node node = iObject.GetSceneGraphNode();
            if(node != null)
                objectsNode.AddChild(node);
        }

        Layer layer = (Layer) SceneGraphRoot;

        if(Object is Tilemap) {
            Tilemap tilemap = (Tilemap) Object;
            Node tnode = new TilemapNode(tilemap, level.Tileset);
            ColorNode colorNode = new ColorNode(tnode, new Color(1f, 1f, 1f, 1f));
            layer.Add(tilemap.Layer, colorNode);
            colors[tilemap] = colorNode;
        }

        if (Object is IDrawableLayer) {
            IDrawableLayer IDrawableLayer = (IDrawableLayer) Object;

            Node mynode = IDrawableLayer.GetSceneGraphNode();
            if(mynode != null) {
                ColorNode colorNode = new ColorNode(mynode, new Color(1f, 1f, 1f, 1f));
                layer.Add(IDrawableLayer.Layer, colorNode);
                colors[IDrawableLayer] = colorNode;
            }
        }
    }
    private void OnObjectAdded(Sector sector, IGameObject Object)
    {
        if(Object is IObject) {
            IObject iObject = (IObject) Object;
            Node node = iObject.GetSceneGraphNode();
            if(node != null)
                objectsNode.AddChild(node);
        }

        Layer layer = (Layer) SceneGraphRoot;

        if(Object is Tilemap) {
            Tilemap tilemap = (Tilemap) Object;
            Node tnode = new TilemapNode(tilemap, level.Tileset);
            ColorNode colorNode = new ColorNode(tnode, new Color(1f, 1f, 1f, 1f));
            layer.Add(tilemap.ZPos, colorNode);
            System.Console.WriteLine("Adding tilemap color: {0}", Object.GetHashCode());
            colors[tilemap] = colorNode;
        }

        if (Object is Background) {
            Background background = (Background) Object;

            Node mynode = background.GetSceneGraphNode();
            if(mynode != null) {
                ColorNode colorNode = new ColorNode(mynode, new Color(1f, 1f, 1f, 1f));
                layer.Add(background.Layer, colorNode);
            }
        }
    }
Exemplo n.º 8
0
    public SectorRenderer(IEditorApplication application, Level level, Sector sector)
    {
        this.application = application;
        this.level       = level;
        this.sector      = sector;
        Layer layer = new Layer();

        backgroundNode      = new NodeWithChilds();
        backgroundColorNode = new ColorNode(backgroundNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(-900, backgroundColorNode);
        foreach (Background background in sector.GetObjects(typeof(Background)))
        {
            Node node = background.GetSceneGraphNode();
            if (node == null)
            {
                continue;
            }
            backgroundNode.AddChild(node);
        }

        foreach (Tilemap tilemap in sector.GetObjects(typeof(Tilemap)))
        {
            Node      node      = new TilemapNode(tilemap, level.Tileset);
            ColorNode colorNode = new ColorNode(node, new Color(1f, 1f, 1f, 1f), true);
            layer.Add(tilemap.ZPos, colorNode);
            colors[tilemap] = colorNode;
        }

        objectsNode      = new NodeWithChilds();
        objectsColorNode = new ColorNode(objectsNode, new Color(1f, 1f, 1f, 1f));
        layer.Add(1, objectsColorNode);

        foreach (IObject Object in sector.GetObjects(typeof(IObject)))
        {
            Node node = Object.GetSceneGraphNode();
            if (node != null)
            {
                objectsNode.AddChild(node);
            }
        }

        // fill remaining place with one color
        sectorFill      = new SceneGraph.Rectangle();
        sectorFill.Fill = true;
        ColorNode color = new ColorNode(sectorFill, new Drawing.Color(0.4f, 0.3f, 0.4f));

        layer.Add(-10000, color);

        // draw border around sector...
        sectorBBox      = new SceneGraph.Rectangle();
        sectorBBox.Fill = false;
        color           = new ColorNode(sectorBBox, new Drawing.Color(1, 0.3f, 1));
        layer.Add(1000, color);

        // draw border around selected layer...
        color = new ColorNode(new TilemapBorder(application), new Drawing.Color(1, 1, 0));
        layer.Add(1001, color);

        OnSizeChanged(sector);

        this.SceneGraphRoot = layer;

        sector.ObjectAdded         += OnObjectAdded;
        sector.ObjectRemoved       += OnObjectRemoved;
        sector.SizeChanged         += OnSizeChanged;
        application.TilemapChanged += OnTilemapChanged;
        FieldOrProperty.Lookup(typeof(Tilemap).GetField("ZPos")).Changed += OnTilemapZPosModified;
    }
Exemplo n.º 9
0
 public override void SetupGraphics(Layer Layer)
 {
     Node node = new TilemapNode(Field, Tileset);
     Layer.Add(0f, node);
 }