Ejemplo n.º 1
0
        public void Rebuild()
        {
            tree.Root = new Vivid.Resonance.Forms.TreeNode("Map Root");

            var menu = tree.ContextMenu = new Vivid.Resonance.Forms.ContextMenuForm();


            var m_nodes = menu.AddItem("Nodes");

            var m_logic = m_nodes.Menu.AddItem("Logic");

            var l_marker = m_logic.Menu.AddItem("Marker");

            var n_lights = m_nodes.Menu.AddItem("Lights");

            var l_pointL = n_lights.Menu.AddItem("Point Light");

            l_marker.Click = () =>
            {
                var gm = new Vivid.Scene.GraphMarker();
                gm.SetPos(300, 300);
                GameGlobal.EditMap.AddMarker(gm);
            };

            l_pointL.Click = () =>
            {
                var nl = new Vivid.Scene.GraphLight();

                nl.SetPos(250, 250);
                nl.Range = 800;
                nl.Z     = 0.1f;
                map.AddLight(nl);
                Console.WriteLine("Added light to scene.");
            };
        }
Ejemplo n.º 2
0
 public BigShotProjector()
 {
     Name           = "Big Shot";
     HudImg         = new Vivid.Texture.Texture2D("Corona/img/icon/bigshoticon.png", Vivid.Texture.LoadMethod.Single, true);
     Img            = new Vivid.Tex.Tex2D("Corona/img/icon/bigshoticon.png", true);
     ImgFrame       = Img;
     Light1         = new Vivid.Scene.GraphLight();
     Light1.X       = X;
     Light1.Y       = Y;
     Light1.Range   = 300;
     Light1.Diffuse = new OpenTK.Vector3(0, 0.4f, 0.4f);
 }
Ejemplo n.º 3
0
        public void Rebuild()
        {
            tree.Root = new Vivid.Resonance.Forms.TreeNode("Map Root");

            var menu = tree.ContextMenu = new Vivid.Resonance.Forms.ContextMenuForm();


            var m_nodes = menu.AddItem("Nodes");

            var n_lights = m_nodes.Menu.AddItem("Lights");

            var l_pointL = n_lights.Menu.AddItem("Point Light");

            l_pointL.Click = () =>
            {
                var nl = new Vivid.Scene.GraphLight();

                nl.SetPos(250, 250);
                nl.Range = 800;
                nl.Z     = 0.1f;
                map.AddLight(nl);
                Console.WriteLine("Added light to scene.");
            };
        }
Ejemplo n.º 4
0
        public WindowForm CrTileSetEditor()
        {
            setX      = 0;
            setY      = 0;
            CurSetMap = new Map();

            var setLight = new Vivid.Scene.GraphLight();

            setLight.SetPos(120, 120);
            setLight.SetZ(40);
            setLight.Diffuse  = new OpenTK.Vector3(1, 1, 1);
            setLight.Specular = new OpenTK.Vector3(1, 1, 1);
            setLight.Range    = 1200;

            CurSetMap.AddLight(setLight);

            WindowForm set_Editor = new WindowForm().Set(200, 200, 700, 600, "TileSet") as WindowForm;

            ToolBarForm tools = new ToolBarForm().Set(0, 0, 700, 25) as ToolBarForm;



            set_Editor.body.Add(tools);

            MapViewForm tileSet_View = new MapViewForm(CurSetMap).Set(0, 25, set_Editor.body.W, set_Editor.body.H - 25) as MapViewForm;

            tView = tileSet_View;
            //CurSetMap = new Map(1);
            tView.MouseLeave = () =>
            {
                ClearHL(tileSet_View);
            };
            tView.MouseMove = (x, y, dx, dy) =>
            {
                if (tView.Graph != null)
                {
                    var node = tView.Graph.Pick(x, y);

                    if (node != null)
                    {
                        tView.Map.HL.Clear();
                        tView.Map.HighlightTile(node.TileX, node.TileY);
                        tileSet_View.UpdateGraph();
                        // tileSet_View.Graph.X = -32 + tileSet_View.W / 2;
                        //tileSet_View.Graph.Y = -32 + tileSet_View.H / 2;
                        // Console.WriteLine("MX:" + x + " MY:" + y);
                    }
                    else
                    {
                        ClearHL(tileSet_View);
                    }
                }
            };

            CurSetLayer = CurSetMap.AddLayer(new SpaceEngine.Map.Layer.MapLayer(setWidth, setHeight));



            set_Editor.body.Add(tileSet_View);

            void click_AddFolder()
            {
                var req = new RequestFileForm("Select a folder to scan..", ContentPath, true);

                SUI.Top = req;

                req.Selected = (path) =>
                {
                    Console.WriteLine("Folder:" + path + ":");
                    SUI.Top = null;

                    var di = new DirectoryInfo(path);

                    foreach (var file in di.GetFiles())
                    {
                        switch (file.Extension)
                        {
                        case ".png":
                        case ".bmp":
                        case ".jpg":
                        case ".tga":
                            FAddTile(file.FullName);

                            break;
                        }
                    }

                    ResetMap(tView);
                };


                // var file
            }

            tools.AddItem("Clear");
            var tile_Add       = tools.AddItem("Add Tile");
            var tile_AddFolder = tools.AddItem("Add Folder");

            tile_AddFolder.Click = click_AddFolder;

            void click_AddTile()
            {
                var addReq = new RequestFileForm("Add Tile to set...", ContentPath);

                SUI.Top = addReq;

                addReq.Selected = (path) =>
                {
                    Console.WriteLine("Loading Tile:" + path);

                    FAddTile(path);
                    //CurSetMap.HighlightTile(setX - 1, setY);
                    ResetMap(tileSet_View);
                    //tileSet_View.Graph.X = (CurSetMap.Layers[0].Width * 64)/2;
                    // tileSet_View.Graph.Y = (CurSetMap.Layers[0].Height * 64) / 2;
                    // tileSet_View.Graph.X -= 64;
                    SUI.Top = null;
                };
            }

            tile_Add.Click = click_AddTile;


            return(set_Editor);
        }
Ejemplo n.º 5
0
        public MapEditForm()


        {
            var layDown = new ButtonForm().Set(140, -20, 30, 20, "\\/");
            var layUp   = new ButtonForm().Set(240, -20, 30, 20, "/\\");

            lay = new TextBoxForm().Set(175, -20, 70, 20, "0") as TextBoxForm;
            Body.Add(layDown);
            Body.Add(layUp);
            Body.Add(lay);

            layDown.Click = (b) =>
            {
                EditZ--;
                if (EditZ < 0)
                {
                    EditZ = 0;
                }
                lay.Text = EditZ.ToString();
            };
            layUp.Click = (b) =>
            {
                EditZ++;
                if (EditZ >= View.Map.Layers.Count)
                {
                    EditZ = View.Map.Layers.Count - 1;
                }
                ;
                lay.Text = EditZ.ToString();
            };
            Tab           = new TabForm();
            moveForm      = new MoveNodeForm().Set(0, 0, 0, 0) as MoveNodeForm;
            moveForm.View = View;
            NewMap();

            var l1 = new Vivid.Scene.GraphLight();
            var l2 = new Vivid.Scene.GraphLight();
            var l3 = new Vivid.Scene.GraphLight();

            //            View.Map.AddLight(l1);
            //          View.Map.AddLight(l2);
            //        View.Map.AddLight(l3);

            cLab = null;
            ; var TView = View;

            float r = 0;

            Update = () =>

            {
                if (lMode != Mode)
                {
                    updateModeLabel();
                    lMode = Mode;
                }
                View.UpdateGraph();

                /*
                 * TView.Map.Lights[0].SetPos(300,300);
                 * TView.Map.Lights[0].Range = 450;
                 * TView.Map.Lights[0].Diffuse = new OpenTK.Vector3(0, 1, 1);
                 * TView.Map.Lights[1].SetPos(650, 400);
                 * TView.Map.Lights[1].Range = 400;
                 * TView.Map.Lights[1].Diffuse = new OpenTK.Vector3(1, 1, 0);
                 * TView.Map.Lights[0].Z = 0.1f;
                 * TView.Map.Lights[1].Z = 0.1f;
                 * TView.Map.Lights[2].Z = 0.1f;
                 * TView.Map.Lights[2].Diffuse = new OpenTK.Vector3(1, 0, 1);
                 * TView.Map.Lights[2].Range = 600;
                 * TView.Map.Lights[2].SetPos(150, 150);
                 */
            };

            void updateModeLabel()
            {
                if (cLab != null)
                {
                    View.Forms.Remove(cLab);
                }
                cLab = new LabelForm().Set(2, -23, 30, 20, "Mode:Paste") as LabelForm;

                View.Add(cLab);
                Rebuild();
            }

            updateModeLabel();

            // Body.Add(View);



            AfterSet = () =>
            {
                Tab.W = W;
                Tab.H = Body.H;
                View.Set(0, 0, Body.W, Body.H);
                View.UpdateGraph();
            };
        }
Ejemplo n.º 6
0
        public MapEditForm()

        {
            var layDown = new ButtonForm().Set(140, -20, 30, 20, "\\/");
            var layUp   = new ButtonForm().Set(240, -20, 30, 20, "/\\");
            var lay     = new TextBoxForm().Set(175, -20, 70, 20, "0");

            body.Add(layDown);
            body.Add(layUp);
            body.Add(lay);

            layDown.Click = (b) =>
            {
                EditZ--;
                if (EditZ < 0)
                {
                    EditZ = 0;
                }
                lay.Text = EditZ.ToString();
            };
            layUp.Click = (b) =>
            {
                EditZ++;
                if (EditZ >= View.Map.Layers.Count)
                {
                    EditZ = View.Map.Layers.Count - 1;
                }
                ;
                lay.Text = EditZ.ToString();
            };
            Tab = new TabForm();

            CurMap = new Map();
            for (int i = 0; i < 4; i++)
            {
                Layers.Add(new MapLayer(24, 24, CurMap));
                CurMap.AddLayer(Layers[i]);
            }
            //CurMap.AddLayer(layer[0]);

            CurLayer = Layers[0];

            CurTile = null;


            View = new MapViewForm(CurMap);

            var l1 = new Vivid.Scene.GraphLight();
            var l2 = new Vivid.Scene.GraphLight();
            var l3 = new Vivid.Scene.GraphLight();

//            View.Map.AddLight(l1);
//          View.Map.AddLight(l2);
//        View.Map.AddLight(l3);

            LabelForm cLab = null;

            ; var TView = View;

            float r = 0;

            Update = () =>

            {
                if (lMode != Mode)
                {
                    updateModeLabel();
                    lMode = Mode;
                }

                /*
                 * TView.Map.Lights[0].SetPos(300,300);
                 * TView.Map.Lights[0].Range = 450;
                 * TView.Map.Lights[0].Diffuse = new OpenTK.Vector3(0, 1, 1);
                 * TView.Map.Lights[1].SetPos(650, 400);
                 * TView.Map.Lights[1].Range = 400;
                 * TView.Map.Lights[1].Diffuse = new OpenTK.Vector3(1, 1, 0);
                 * TView.Map.Lights[0].Z = 0.1f;
                 * TView.Map.Lights[1].Z = 0.1f;
                 * TView.Map.Lights[2].Z = 0.1f;
                 * TView.Map.Lights[2].Diffuse = new OpenTK.Vector3(1, 0, 1);
                 * TView.Map.Lights[2].Range = 600;
                 * TView.Map.Lights[2].SetPos(150, 150);
                 */
            };

            void updateModeLabel()
            {
                if (cLab != null)
                {
                    View.Forms.Remove(cLab);
                }
                cLab = new LabelForm().Set(2, -23, 30, 20, "Mode:Paste") as LabelForm;

                View.Add(cLab);
            }

            updateModeLabel();

            body.Add(View);

            MoveNodeForm moveForm = new MoveNodeForm().Set(0, 0, 0, 0) as MoveNodeForm;

            moveForm.View = TView;
            TView.Add(moveForm);

            TView.MouseDown = (b) =>
            {
                if (b == 2)
                {
                    rotCam = true;
                    return;
                }
                if (b == 1)
                {
                    MoveCam = true;
                    return;
                }
                Console.WriteLine("MX:" + mX + " MY:" + mY);
                AppInfo.RW = W;
                AppInfo.RH = H;
                var pn = TView.PickObj(mX, mY);
                if (pn != null)
                {
                    if (pn is Vivid.Scene.GraphLight)
                    {
                        ActiveNode       = pn;
                        TView.ActiveNode = pn;
                        TView.SetActiveSprite();
                        moveForm.SetNode(TView.ActiveNode);
                        moveForm.Set((int)TView.ActiveNodeSprite.DrawP[0].X, (int)TView.ActiveNodeSprite.DrawP[0].Y, 64, 64);
                        Console.WriteLine("Set PN");
                    }
                    else
                    {
                        Console.WriteLine("nope");
                    }
                }
                else
                {
                    Console.WriteLine("No obj");
                }

                MouseIn = true;
                var hz = ONode; // TView.Graph.Pick(lx, ly);

                if (hz != null)
                {
                }
            };
            TView.MouseWheelMoved = (z) =>
            {
                TView.Graph.Z += ((z * 0.1f) * TView.Graph.Z);
            };
            TView.MouseUp = (b) =>
            {
                if (b == 2)
                {
                    rotCam = false;
                    return;
                }
                if (b == 1)
                {
                    MoveCam = false;
                    return;
                }
                MouseIn = false;
            };

            TView.MouseMove = (x, y, dx, dy) =>
            {
                mX = x;
                mY = y;

                if (rotCam)
                {
                    TView.Graph.Rot += dx;
                }
                if (MoveCam)
                {
                    TView.Graph.Move(-dx, -dy);
                    //TView.Graph.X -= dx;
                    // TView.Graph.Y -= dy;
                }

                lx = x;
                ly = y;
                if (TView.Graph != null)
                {
                    AppInfo.RW = TView.MapFrame.IW;
                    AppInfo.RH = TView.MapFrame.IH;
                    var node = TView.Graph.Pick(x, y);
                    AppInfo.RW = AppInfo.W;
                    AppInfo.RH = AppInfo.H;
                    if (node != null)
                    {
                        ONode = node;

                        if (MouseIn)
                        {
                            switch (Mode)
                            {
                            case EditMode.Paste:
                                TView.Map.Layers[EditZ].SetTile(node.TileX, node.TileY, TileBrowser.ActiveTile);
                                //TView.UpdateGraph();
                                break;

                            case EditMode.Fill:
                                TView.Map.Layers[EditZ].Fill(TileBrowser.ActiveTile);
                                break;
                            }
                        }

                        var tView = TView;

                        TView.Map.HL.Clear();
                        TView.Map.HighlightTile(node.TileX, node.TileY);
                        TView.UpdateGraph();


                        if (TView.ActiveNodeSprite != null)
                        {
                            // TView.ActiveNodeSprite.SyncCoords();
                            if (TView.ActiveNodeSprite.DrawP != null)
                            {
                                moveForm.Set((int)TView.ActiveNodeSprite.DrawP[0].X, (int)TView.ActiveNodeSprite.DrawP[0].Y, 64, 64);
                                //  TView.Graph.X = -32 + TView.W / 2;
                            }
                        }
                        // TView.Graph.Y = -32 + TView.H / 2;
                        // Console.WriteLine("MX:" + x + " MY:" + y);
                    }
                    else
                    {
                        ClearHL(TView);
                    }
                }
            };


            AfterSet = () =>
            {
                Tab.W = W;
                Tab.H = body.H;
                View.Set(0, 0, body.W, body.H);
                View.UpdateGraph();
            };
        }
Ejemplo n.º 7
0
        public WindowForm CrTileSetEditor()
        {
            setX      = 0;
            setY      = 0;
            CurSetMap = new Map();


            var setLight = new Vivid.Scene.GraphLight();

            setLight.SetPos(120, 120);
            setLight.SetZ(40);
            setLight.Diffuse  = new OpenTK.Vector3(1, 1, 1);
            setLight.Specular = new OpenTK.Vector3(1, 1, 1);
            setLight.Range    = 1200;

            //  CurSetMap.AddLight(setLight);


            WindowForm set_Editor = new WindowForm().Set(200, 200, 700, 600, "TileSet") as WindowForm;

            ToolBarForm tools = new ToolBarForm().Set(0, 0, 700, 25) as ToolBarForm;



            set_Editor.Body.Add(tools);

            MapViewForm tileSet_View = new MapViewForm(CurSetMap).Set(0, 25, set_Editor.Body.W, set_Editor.Body.H - 25) as MapViewForm;

            tView = tileSet_View;


            // tileSet_View.LockCam = true;
            //tileSet_View.LockX = (set_Editor.Body.W / 2)-32;
            //tileSet_View.LockY = (set_Editor.Body.H / 2)-48;
            bool move_on = false;

            //CurSetMap = new Map(1);
            tView.MouseLeave = () =>
            {
                ClearHL(tileSet_View);
            };
            tView.MouseUp = (b) =>
            {
                if (b == 1)
                {
                    move_on = false;
                }
            };
            tView.MouseDown = (b) =>
            {
                if (b == 1)
                {
                    move_on = true;
                }
                if (CurTile != null)
                {
                    Inspect.SetObj(CurTile);
                }
            };
            tView.MouseMove = (x, y, dx, dy) =>
            {
                if (tView.Graph != null)
                {
                    if (move_on == true)
                    {
                        tView.Graph.Move(-dx, -dy);
                        if (tView.Graph.X > (tileSet_View.W / 2) - 32)
                        {
                            tView.Graph.X = ((tileSet_View.W / 2) - 32) - 6;
                        }
                        ;
                        if (tView.Graph.Y > (tileSet_View.H / 2) - 32)
                        {
                            tView.Graph.Y = ((tileSet_View.H / 2) - 32) - 6;
                        }
                    }

                    AppInfo.RW = tView.MapFrame.IW;
                    AppInfo.RH = tView.MapFrame.IH;
                    var node = tView.Graph.Pick(x, y);
                    AppInfo.RW = AppInfo.W;
                    AppInfo.RH = AppInfo.H;
                    if (node != null)
                    {
                        tView.Map.HL.Clear();
                        tView.Map.HighlightTile(node.TileX, node.TileY);
                        tileSet_View.UpdateGraph();
                        //Inspect.SetObj(node.Obj[0]);
                        CurTile = node.Obj[0];
                        // tileSet_View.Graph.X = -32 + tileSet_View.W / 2;
                        //tileSet_View.Graph.Y = -32 + tileSet_View.H / 2;
                        // Console.WriteLine("MX:" + x + " MY:" + y);
                    }
                    else
                    {
                        ClearHL(tileSet_View);
                    }
                }
            };

            CurSetLayer = CurSetMap.AddLayer(new Vivid.Map.Layer.MapLayer(setWidth, setHeight, CurSetMap));



            set_Editor.Body.Add(tileSet_View);

            void click_AddFolder()
            {
                var req = new RequestFileForm("Select a folder to scan..", GameGlobal.ContentPath, true);

                SUI.Top = req;

                req.Selected = (path) =>
                {
                    Console.WriteLine("Folder:" + path + ":");
                    SUI.Top = null;

                    var di = new DirectoryInfo(path);

                    foreach (var file in di.GetFiles())
                    {
                        switch (file.Extension)
                        {
                        case ".png":
                        case ".bmp":
                        case ".jpg":
                        case ".tga":

                            if (file.FullName.ToLower().Contains("nrm"))
                            {
                                continue;
                            }

                            FAddTile(file.FullName);

                            break;
                        }
                    }

                    ResetMap(tView);
                };


                // var file
            }

            tools.AddItem("Clear");
            var tile_Add       = tools.AddItem("Add Tile");
            var tile_AddFolder = tools.AddItem("Add Folder");

            tile_AddFolder.Click = click_AddFolder;

            void click_AddTile()
            {
                var addReq = new RequestFileForm("Add Tile to set...", GameGlobal.ContentPath);

                SUI.Top = addReq;

                addReq.Selected = (path) =>
                {
                    Console.WriteLine("Loading Tile:" + path);

                    FAddTile(path);
                    //CurSetMap.HighlightTile(setX - 1, setY);
                    ResetMap(tileSet_View);
                    //tileSet_View.Graph.X = (CurSetMap.Layers[0].Width * 64)/2;
                    // tileSet_View.Graph.Y = (CurSetMap.Layers[0].Height * 64) / 2;
                    // tileSet_View.Graph.X -= 64;
                    SUI.Top = null;
                };
            }

            tile_Add.Click = click_AddTile;


            return(set_Editor);
        }