Exemplo n.º 1
0
        private void NewMethod(SceneGraph2D Graph)
        {
            foreach (var hl in HL)
            {
                int mx = hl.X * TileWidth;
                int my = hl.Y * TileHeight;


                var hs = new GraphSprite(new Tex2D("content/edit/highlight1.png", true), null, 64, 64);

                hs.SetPos(mx, my);
                // tileSpr.SetPos(mx, my);


                Graph.Add(hs);;
            }
        }
Exemplo n.º 2
0
        public Vivid.Scene.SceneGraph2D UpdateGraph(int tw, int th)
        {
            if (sceneChanged == false)
            {
                return(oGraph);
            }
            Vivid.Scene.SceneGraph2D Graph = oGraph;
            if (oGraph == null)
            {
                Graph = new Vivid.Scene.SceneGraph2D();
            }
            oGraph       = Graph;
            sceneChanged = false;
            float sp = 0;
            int   li = 0;

            Graph.Root = new GraphNode();
            foreach (var layer in Layers)
            {
                li++;
                for (int y = 0; y < layer.Height; y++)
                {
                    for (int x = 0; x < layer.Width; x++)
                    {
                        var tile = layer.GetTile(x, y);

                        if (tile == null)
                        {
                            if (li == 1)
                            {
                                var notile = new GraphSprite(new Tex2D("content/edit/notile.png", false), null, TileWidth, TileHeight);
                                notile.SetPos(x * TileWidth, y * TileHeight);
                                notile.TileX = x;
                                notile.TileY = y;
                                Graph.Add(notile);
                            }
                            continue;
                        }

                        var tileSpr = new GraphSprite(tile.ColorImage, tile.NormalImage, TileWidth, TileHeight);

                        tileSpr.TileX = x;
                        tileSpr.TileY = y;

                        int mx = x * TileWidth;
                        int my = y * TileHeight;



                        tileSpr.SetPos(mx, my);
                        tileSpr.Obj[0] = tile;
                        if (Lights.Count > 0)
                        {
                            tileSpr.ShadowPlane = sp;
                        }
                        Graph.Add(tileSpr);
                        if (li > 1)
                        {
                            tileSpr.CastShadow = true;
                            tileSpr.RecvShadow = false;
                        }
                    }
                }
                sp = sp + 0.1f;
            }

            NewMethod(Graph);

            if (Graph.Lights.Count != Lights.Count)
            {
                Graph.Lights.Clear();
                Graph.Add(Lights.ToArray());
            }
            // Graph.Add(Lights.ToArray());
            foreach (var l in Lights)
            {
                var lg = new GraphSprite(new Tex2D("content/edit/light.png", true), null, 64, 64);
                lg.X = l.X;
                lg.Y = l.Y;
                lg.Z = l.Z;
                //   Graph.Add(lg);
            }


            return(Graph);
        }