Esempio n. 1
0
        public Sector(PLayer layer, String name)
        {
            Random rnd = new Random((int)DateTime.Now.Ticks); // seeded with ticks
            Color penColor = Color.FromArgb((rnd.Next(0, 255)), (rnd.Next(0, 255)), (rnd.Next(0, 255)));

            Pen sigPen = new Pen(penColor, 2.0F);
            sigPen.DashStyle = DashStyle.DashDotDot;

            PPath sigCircle = PPath.CreateEllipse(100, 500, 100, 100);
            sigCircle.Pen = sigPen;
            sigCircle.Brush = Brushes.Transparent;

            PText pname = new PText(name);
            pname.TextBrush = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X = sigCircle.X;
            pname.Y = sigCircle.Y;

            //Display Object by adding them to its layer
            layer.AddChild(pname);
            layer.AddChild(sigCircle);
        }
        public Harvestable(PLayer layer, String name, float x, float y, float sigRadius, float rrRadius)
        {
            float sigDia = (sigRadius * 2) / 100;
            float rrDia = (rrRadius * 2) / 100;

            string dataDirectory = "Images";
            string filePath = Path.Combine("..", "..");
            if (File.Exists(Path.Combine(dataDirectory, "resource.png")))
            {
                filePath = "";
            }

            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, "resource.png")));
            PImage stationImage = new PImage(image);
            stationImage.X = (x - (image.Width/2)) / 100;
            stationImage.Y = (y - (image.Height/2)) / 100;

            float sigX = (x / 100) - ((sigDia / 2) - (image.Width / 2));
            float sigY = (y / 100) - ((sigDia / 2) - (image.Height / 2));
            float rrX = (x / 100) - ((rrDia / 2) - (image.Width / 2));
            float rrY = (y / 100) - ((rrDia / 2) - (image.Height / 2));

            Pen sigPen = new Pen(Color.Violet, 2.0F);
            sigPen.DashStyle = DashStyle.DashDotDot;
            Pen rrPen = new Pen(Color.Pink, 1.0F);

            PPath sigCircle = PPath.CreateEllipse(sigX, sigY, sigDia, sigDia);
            sigCircle.Pen = sigPen;
            PPath rrCircle = PPath.CreateEllipse(rrX, rrY, rrDia, rrDia);
            rrCircle.Pen = rrPen;

            PNode sigNode = sigCircle;
            sigNode.Brush = Brushes.Transparent;

            PNode rrNode = rrCircle;
            rrNode.Brush = Brushes.Transparent;

            PText pname = new PText(name);
            pname.TextBrush = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X = (x / 100) - (pname.Width / 2);
            pname.Y = (y / 100) - 20;

            stationImage.AddChild(sigNode);
            stationImage.AddChild(rrNode);
            stationImage.AddChild(pname);

            //Display Object by adding them to its layer
            layer.AddChild(stationImage);
        }
        public SectorBounds(PLayer layer, float x_min, float y_min, float x_max, float y_max)
        {
            float width = (x_max-x_min)/100;
            float height = (y_max-y_min)/100;
            float x = x_min / 100;
            float y = (y_min / 100) - (height / 2);

            Console.Out.WriteLine(width + ", " + height);

            Pen boundsPen = new Pen(Color.Red, 10.0F);
            boundsPen.DashStyle = DashStyle.DashDotDot;

            PPath boundsRectangle = PPath.CreateRectangle(x, y, width, height);
            boundsRectangle.Brush = Brushes.Transparent;
            boundsRectangle.Pen = boundsPen;

            layer.AddChild(boundsRectangle);
        }
Esempio n. 4
0
		public override void Initialize() {
			PLayer l = new PLayer();
			PPath n = PPath.CreateEllipse(0, 0, 100, 80);			
			n.Brush = Brushes.Red;
			n.Pen = null;
			PBoundsHandle.AddBoundsHandlesTo(n);
			l.AddChild(n);
			n.TranslateBy(200, 200);

			PCamera c = new PCamera();
			c.SetBounds(0, 0, 100, 80);
			c.ScaleViewBy(0.1f);
			c.AddLayer(l);
			PBoundsHandle.AddBoundsHandlesTo(c);
			c.Brush = Brushes.Yellow;

			Canvas.Layer.AddChild(l);
			Canvas.Layer.AddChild(c);
 		}
		public override void Initialize() {
			//create bar layers
			PLayer rowBarLayer = new PLayer();
			PLayer colBarLayer = new PLayer();

			//create bar nodes
			for (int i = 0; i < 10; i++) {
				//create row bar with node row1, row2,...row10
				PText p = new PText("Row " + i);
				p.X = 0;
				p.Y = NODE_HEIGHT * i + NODE_HEIGHT;
				p.Brush = Brushes.White;
				colBarLayer.AddChild(p);

				//create col bar with node col1, col2,...col10
				p = new PText("Col " + i);
				p.X = NODE_WIDTH * i + NODE_WIDTH;
				p.Y = 0;
				p.Brush = Brushes.White;
				rowBarLayer.AddChild(p);
			}

			//add bar layers to camera
			Canvas.Camera.AddChild(rowBarLayer);
			Canvas.Camera.AddChild(colBarLayer);

			//create matrix nodes
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					PPath path = PPath.CreateRectangle(NODE_WIDTH * j + NODE_WIDTH,
						NODE_HEIGHT * i + NODE_HEIGHT, NODE_WIDTH - 1,
						NODE_HEIGHT - 1);
					Canvas.Layer.AddChild(path);
				}
			}

			//catch drag event and move bars corresponding
			Canvas.AddInputEventListener(new BarDragEventHandler(Canvas, rowBarLayer, colBarLayer));
		}
        public SectorSprite(PLayer layer, PropertyGrid pg, DataRow r, String name, float galaxy_x, float galaxy_y, float xmin, float xmax, float ymin, float ymax)
        {
            _pg = pg;
            dr = r;

            setupData(r);

            float width = (xmax - xmin) / 1000;
            float height = (ymax - ymin) / 1000;

            Color penColor = Color.Honeydew;

            Pen sigPen = new Pen(penColor, 2.0F);
            sigPen.DashStyle = DashStyle.Dash;

            PPath sigCircle = PPath.CreateEllipse(galaxy_x, galaxy_y, width, width);
            sigCircle.Pen = sigPen;
            sigCircle.Brush = Brushes.Transparent;

            pname = new PText(name);
            pname.TextBrush = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X = sigCircle.X + ((sigCircle.Width / 2) - (pname.Width / 2));
            pname.Y = sigCircle.Y + (sigCircle.Height / 2);

            sigCircle.Tag = this;

            //Display Object by adding them to its layer
            sigCircle.AddChild(pname);
            layer.AddChild(sigCircle);

            sigCircle.ChildrenPickable = false;

            // Attach event delegates directly to the node.
            sigCircle.MouseDown += new PInputEventHandler(Image_MouseDown);
        }
        public SystemWindow(PCanvas pcanvas, String systemName, DataRow[] sectorTable, PropertyGrid pg, DataRow selectedRow)
        {
            canvas = pcanvas;
            dr = selectedRow;
            _pg = pg;

            sectorLayer = new PLayer();

            //Setup Mouse Wheel Zoom instead of regular piccollo zoom.
            new MouseWheelZoomController(canvas.Camera);

            //Setup Default Background Color
            canvas.BackColor = Color.Black;

            //Create the master Layer
            masterLayer = canvas.Layer;

            for (int i = 0; i < sectorTable.Length; i++)
            {
                String sectorName = sectorTable[i]["name"].ToString();
                float xmin = float.Parse(sectorTable[i]["x_min"].ToString());
                float xmax = float.Parse(sectorTable[i]["x_max"].ToString());
                float ymin = float.Parse(sectorTable[i]["y_min"].ToString());
                float ymax = float.Parse(sectorTable[i]["y_max"].ToString());
                float x = float.Parse(sectorTable[i]["galaxy_x"].ToString());
                float y = float.Parse(sectorTable[i]["galaxy_y"].ToString());

                DataRow r = sectorTable[i];
                new SectorSprite(sectorLayer, pg, r, sectorName, x, y, xmin, xmax, ymin, ymax);
            }

            masterLayer.AddChild(sectorLayer);

            //create events
            masterLayer.MouseDown += new PInputEventHandler(MasterLayer_OnMouseDown);
        }
Esempio n. 8
0
		public override void Initialize() {
			int numNodes = 50;
			int numEdges = 50;

			// Initialize, and create a layer for the edges (always underneath the nodes)
			PLayer nodeLayer = Canvas.Layer;
			PLayer edgeLayer = new PLayer();
			Canvas.Root.AddChild(edgeLayer);
			Canvas.Camera.AddLayer(0, edgeLayer);
			Random rnd = new Random();

			// Create some random nodes
			// Each node's Tag has an ArrayList used to store associated edges
			for (int i=0; i<numNodes; i++) {
				float x = (float)(ClientSize.Width * rnd.NextDouble());
				float y = (float)(ClientSize.Height * rnd.NextDouble());
				P3Path node = P3Path.CreateEllipse(x, y, 20, 20);

				node.Tag = new ArrayList();
				nodeLayer.AddChild(node);
			}

			// Create some random edges
			// Each edge's Tag has an ArrayList used to store associated nodes
			for (int i=0; i<numEdges; i++) {
				int n1 = rnd.Next(numNodes);
				int n2 = n1;
				while (n2 == n1) {
					n2 = rnd.Next(numNodes);  // Make sure we have two distinct nodes.
				}

				PNode node1 = nodeLayer[n1];
				PNode node2 = nodeLayer[n2];
				P3Path edge = P3Path.CreateLine((node1.Bounds.Left + node1.Bounds.Right)/2, (node1.Bounds.Top + node1.Bounds.Bottom)/2,
					(node2.Bounds.Left + node2.Bounds.Right)/2, (node2.Bounds.Top + node2.Bounds.Bottom)/2);

				((ArrayList)node1.Tag).Add(edge);
				((ArrayList)node2.Tag).Add(edge);
				edge.Tag = new ArrayList();
				((ArrayList)edge.Tag).Add(node1);
				((ArrayList)edge.Tag).Add(node2);

				edgeLayer.AddChild(edge);
			}

			// Create event handler to move nodes and update edges
			nodeLayer.AddInputEventListener(new NodeDragHandler());
		}
        public MobSprite(PLayer layer, DataRow r, PropertyGrid pg, DataGridView dgv)
        {
            _pg = pg;
            setupData(r);
            dr = r;
            _layer = layer;
            _dgv = dgv;

            String name = r["name"].ToString();
            float x = float.Parse(r["position_x"].ToString());
            float y = -(float.Parse(r["position_y"].ToString()));
            float sigRadius = float.Parse(r["signature"].ToString());
            float rrRadius = float.Parse(r["radar_range"].ToString());
            float ExplorationRange = float.Parse(r["exploration_range"].ToString());
            appearsInRadar = (Boolean) r["appears_in_radar"];
            int navType = int.Parse(r["nav_type"].ToString());
            float SpawnRadius = float.Parse(r["mob_spawn_radius"].ToString());

            float sigDia = (sigRadius * 2) / 100;
            float rrDia = (rrRadius * 2) / 100;
            float expDia = (ExplorationRange * 2) / 100;
            float spawnDia = (SpawnRadius * 2) / 100;

            if (sigDia == 0)
            {
                sigDia = 5;
            }
            if (rrDia == 0)
            {
                rrDia = 5;
            }
            if (expDia == 0)
            {
                expDia = 5;
            }
            if (spawnDia == 0)
            {
                spawnDia = 5;
            }

            string dataDirectory = "Images";
            string filePath = Path.Combine("..", "..");
            if (File.Exists(Path.Combine(dataDirectory, "hostileMob.gif")))
            {
                filePath = "";
            }

            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, "hostileMob.gif")));
            mobImage = new PImage(image);
            mobImage.X = (x - (image.Width / 2)) / 100;
            mobImage.Y = (y - (image.Height / 2)) / 100;

            float sigX = (x / 100) - ((sigDia / 2) - (image.Width / 2));
            float sigY = (y / 100) - ((sigDia / 2) - (image.Height / 2));
            float rrX = (x / 100) - ((rrDia / 2) - (image.Width / 2));
            float rrY = (y / 100) - ((rrDia / 2) - (image.Height / 2));
            float expX = (x / 100) - ((expDia / 2) - (image.Width / 2));
            float expY = (y / 100) - ((expDia / 2) - (image.Height / 2));
            float spawnX = (x / 100) - ((spawnDia / 2) - (image.Width / 2));
            float spawnY = (y / 100) - ((spawnDia / 2) - (image.Height / 2));

            Pen sigPen = new Pen(Color.Red, 3.0F);
            Pen rrPen = new Pen(Color.MistyRose, 2.0F);
            rrPen.DashStyle = DashStyle.Dash;
            Pen expPen = new Pen(Color.Maroon, 1.0F);
            expPen.DashStyle = DashStyle.DashDotDot;
            Pen spawnPen = new Pen(Color.Fuchsia, 1.0F);
            spawnPen.DashStyle = DashStyle.Dot;

            PPath sigCircle = PPath.CreateEllipse(sigX, sigY, sigDia, sigDia);
            sigCircle.Pen = sigPen;
            PPath rrCircle = PPath.CreateEllipse(rrX, rrY, rrDia, rrDia);
            rrCircle.Pen = rrPen;
            PPath expCircle = PPath.CreateEllipse(expX, expY, expDia, expDia);
            expCircle.Pen = expPen;
            PPath spawnCircle = PPath.CreateEllipse(spawnX, spawnY, spawnDia, spawnDia);
            spawnCircle.Pen = spawnPen;

            PNode sigNode = sigCircle;
            sigNode.Brush = Brushes.Transparent;

            PNode rrNode = rrCircle;
            rrNode.Brush = Brushes.Transparent;

            PNode expNode = expCircle;
            expNode.Brush = Brushes.Transparent;

            PNode spawnNode = spawnCircle;
            spawnNode.Brush = Brushes.Transparent;

            pname = new PText(name);
            pname.TextBrush = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X = (x / 100) - (pname.Width / 2);
            pname.Y = (y / 100) - 20;

            mobImage.AddChild(sigNode);
            mobImage.AddChild(rrNode);
            mobImage.AddChild(expNode);
            mobImage.AddChild(pname);

            //Add placeholder nodes for nav_type visualization lookup.
            for (int i = 0; i < navType; i++)
            {
                mobImage.AddChild(new PNode());
            }

            mobImage.AddChild(spawnNode);

            mobImage.ChildrenPickable = false;

            //Set the tag to this class for information retrieval later.
            mobImage.Tag = this;

            // Attach event delegates directly to the node.
            mobImage.MouseDown += new PInputEventHandler(Image_MouseDown);
            mobImage.MouseUp += new PInputEventHandler(Image_MouseUp);
            mobImage.MouseDrag += new PInputEventHandler(Image_MouseDrag);

            //Display Object by adding them to its layer
            layer.AddChild(mobImage);
        }
        public SectorWindow(PCanvas pcanvas, DataRow[] sectorRows, PropertyGrid pg, DataGridView dgv)
        {
            canvas = pcanvas;
            dr = sectorRows[0];
            _pg = pg;
            _dgv = dgv;

            //Setup Mouse Wheel Zoom type based on user settings.
            int zoomType = Properties.Settings.Default.zoomSelection;

            switch (zoomType)
            {
                case 0:
                    new MouseWheelZoomController(canvas.Camera);
                    break;
            }

            //Setup Default Background Color
            canvas.BackColor = Color.Black;

            //Create the master Layer
            masterLayer = canvas.Layer;

            //Initialize object Layers
            boundsLayer = new PLayer();
            mobsLayer = new PLayer();
            planetsLayer = new PLayer();
            stargatesLayer = new PLayer();
            starbasesLayer = new PLayer();
            decorationsLayer = new PLayer();
            harvestableLayer = new PLayer();

            //Retrieve Properties from sql row.
            String sectorName = sectorRows[0]["name"].ToString();
            int sectorID = int.Parse(sectorRows[0]["sector_id"].ToString());
            float xmin = float.Parse(sectorRows[0]["x_min"].ToString());
            float xmax = float.Parse(sectorRows[0]["x_max"].ToString());
            float ymin = float.Parse(sectorRows[0]["y_min"].ToString());
            float ymax = float.Parse(sectorRows[0]["y_max"].ToString());
            float zmin = float.Parse(sectorRows[0]["z_min"].ToString());
            float zmax = float.Parse(sectorRows[0]["z_max"].ToString());
            int gridx = int.Parse(sectorRows[0]["grid_x"].ToString());
            int gridy = int.Parse(sectorRows[0]["grid_y"].ToString());
            int gridz = int.Parse(sectorRows[0]["grid_z"].ToString());
            float fognear = float.Parse(sectorRows[0]["fog_near"].ToString());
            float fogfar = float.Parse(sectorRows[0]["fog_far"].ToString());
            int debrismode = int.Parse(sectorRows[0]["debris_mode"].ToString());
            bool lightbackdrop = (Boolean) sectorRows[0]["light_backdrop"];
            bool fogbackdrop = (Boolean) sectorRows[0]["fog_backdrop"];
            bool swapbackdrop = (Boolean) sectorRows[0]["swap_backdrop"];
            float backdropfognear = float.Parse(sectorRows[0]["backdrop_fog_near"].ToString());
            float backdropfogfar = float.Parse(sectorRows[0]["backdrop_fog_far"].ToString());
            float maxtilt = float.Parse(sectorRows[0]["max_tilt"].ToString());
            bool autolevel = (Boolean) sectorRows[0]["auto_level"];
            float impulserate = float.Parse(sectorRows[0]["impulse_rate"].ToString());
            float decayvelocity = float.Parse(sectorRows[0]["decay_velocity"].ToString());
            float decayspin = float.Parse(sectorRows[0]["decay_spin"].ToString());
            int backdropasset = int.Parse(sectorRows[0]["backdrop_asset"].ToString());
            String greetings = sectorRows[0]["greetings"].ToString();
            String notes = sectorRows[0]["notes"].ToString();
            int systemid = int.Parse(sectorRows[0]["system_id"].ToString());
            float galaxyx = float.Parse(sectorRows[0]["galaxy_x"].ToString());
            float galaxyy = float.Parse(sectorRows[0]["galaxy_y"].ToString());
            float galaxyz = float.Parse(sectorRows[0]["galaxy_z"].ToString());
            int sector_type = int.Parse(sectorRows[0]["sector_type"].ToString());

            //Load Sector Object Sql.
            so = new SectorObjectsSql(sectorName);
            DataTable sot = so.getSectorObject();

            float width = xmax - xmin;
            float height = ymax - ymin;
            float depth = zmax - zmin;

            //Populate Properties
            sp = new SectorProps();
            sp.Name = sectorName;
            sp.SectorID = sectorID;
            sp.Width = width;
            sp.Height = height;
            sp.Depth = depth;
            sp.GridX = gridx;
            sp.GridY = gridy;
            sp.GridZ = gridz;
            sp.FogNear = fognear;
            sp.FogFar = fogfar;
            sp.DebrisMode = debrismode;
            sp.LightBackdrop = lightbackdrop;
            sp.FogBackdrop = fogbackdrop;
            sp.SwapBackdrop = swapbackdrop;
            sp.BackdropFogNear = backdropfognear;
            sp.BackdropFogFar = backdropfogfar;
            sp.MaxTilt = maxtilt;
            sp.AutoLevel = autolevel;
            sp.ImpulseRate = impulserate;
            sp.DecayVelocity = decayvelocity;
            sp.DecaySpin = decayspin;
            sp.BackdropAsset = backdropasset;
            sp.Greetings = greetings;
            sp.Notes = notes;
            sp.SystemID = systemid;
            sp.GalaxyX = galaxyx;
            sp.GalaxyY = galaxyy;
            sp.GalaxyZ = galaxyz;

            String oSector = "";
            switch (sector_type)
            {
                case 0:
                    oSector = "Space Sector";
                    break;
                case 1:
                    oSector = "Rocky Planet Surface";
                    break;
                case 2:
                    oSector = "Gas Giant Surface";
                    break; ;
            }

            sp.SectorType = oSector;

            pg.SelectedObject = sp;

            //Create Sector Bounds
            new SectorBoundsSprite(boundsLayer, xmin, ymin, xmax, ymax);

            //Create All Sector Object sprites
            foreach (DataRow r in sot.Rows)
            {
                int type = int.Parse(r["type"].ToString());

                switch (type)
                {
                    case 0:
                        new MobSprite(mobsLayer, r, pg, dgv);
                        break;
                    case 3:
                        new PlanetSprite(planetsLayer, r, pg, dgv);
                        break;
                    case 11:
                        new StargateSprite(stargatesLayer, r, pg, dgv);
                        break;
                    case 12:
                        new StarbaseSprite(starbasesLayer, r, pg, dgv);
                        break;
                    case 37:
                        new DecorationSprite(decorationsLayer, r, pg, dgv);
                        break;
                    case 38:
                        new HarvestableSprite(harvestableLayer, r, pg, dgv);
                        break;

                }
            }

            //Attach all layers to their master
            masterLayer.AddChild(boundsLayer);
            masterLayer.AddChild(mobsLayer);
            masterLayer.AddChild(planetsLayer);
            masterLayer.AddChild(stargatesLayer);
            masterLayer.AddChild(starbasesLayer);
            masterLayer.AddChild(decorationsLayer);
            masterLayer.AddChild(harvestableLayer);

            //create events
            masterLayer.MouseDown += new PInputEventHandler(MasterLayer_OnMouseDown);

            canvas.Camera.MouseDown += new PInputEventHandler(canvasCamera_MouseDown);

            //Zoom all the way out.
            canvas.Camera.ViewScale = .375f;
        }
Esempio n. 11
0
		public GraphEditor(int width, int height) {
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			this.Size = new Size(width, height);
			int numNodes = 50;
			int numEdges = 50;

			// Initialize, and create a layer for the edges (always underneath the nodes)
			PLayer nodeLayer = this.Layer;
			PLayer edgeLayer = new PLayer();
			Root.AddChild(edgeLayer);
			this.Camera.AddLayer(0, edgeLayer);
			Random rnd = new Random();

			// Create some random nodes
			// Each node's Tag has an ArrayList used to store associated edges
			for (int i=0; i<numNodes; i++) {
				float x = (float)(this.ClientSize.Width * rnd.NextDouble());
				float y = (float)(this.ClientSize.Height * rnd.NextDouble());
				PPath path = PPath.CreateEllipse(x, y, 20, 20);
				path.Tag = new ArrayList();
				nodeLayer.AddChild(path);
			}

			// Create some random edges
			// Each edge's Tag has an ArrayList used to store associated nodes
			for (int i=0; i<numEdges; i++) {
				int n1 = rnd.Next(numNodes);
				int n2 = n1;
				while (n2 == n1) {
					n2 = rnd.Next(numNodes);  // Make sure we have two distinct nodes.
				}

				PNode node1 = nodeLayer[n1];
				PNode node2 = nodeLayer[n2];
				PPath edge = new PPath();
				((ArrayList)node1.Tag).Add(edge);
				((ArrayList)node2.Tag).Add(edge);
				edge.Tag = new ArrayList();
				((ArrayList)edge.Tag).Add(node1);
				((ArrayList)edge.Tag).Add(node2);
				edgeLayer.AddChild(edge);
				UpdateEdge(edge);
			}

			// Create event handler to move nodes and update edges
			nodeLayer.AddInputEventListener(new NodeDragHandler());
		}
        public DecorationSprite(PLayer layer, DataRow r, PropertyGrid pg, DataGridView dgv)
        {
            //Setup all of our property window data
            _pg = pg;
            setupData(r);
            dr = r;
            _layer = layer;
            _dgv = dgv;

            //Get our properties from our DataRow.
            String name = r["name"].ToString();
            float x = float.Parse(r["position_x"].ToString());
            float y = -(float.Parse(r["position_y"].ToString()));
            float sigRadius = float.Parse(r["signature"].ToString());
            float rrRadius = float.Parse(r["radar_range"].ToString());
            float ExplorationRange = float.Parse(r["exploration_range"].ToString());
            appearsInRadar = (Boolean) r["appears_in_radar"];
            int navType = int.Parse(r["nav_type"].ToString());

            float sigDia = (sigRadius * 2) / 100;
            float rrDia = (rrRadius * 2) / 100;
            float expDia = (ExplorationRange * 2) / 100;

            if (sigDia == 0)
            {
                sigDia = 5;
            }
            if (rrDia == 0)
            {
                rrDia = 5;
            }
            if (expDia == 0)
            {
                expDia = 5;
            }

            //Setup our Image Path's based on our properties
            string dataDirectory = "Images";
            string filePath = Path.Combine("..", "..");
            string imageName = null;

            if (appearsInRadar == true)
            {
                imageName = "standardNav.gif";
            }
            else
            {
                imageName = "hiddenNav.gif";
            }

            if (File.Exists(Path.Combine(dataDirectory, imageName)))
            {
                filePath = "";
            }

            //Load our main icon.
            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, imageName)));
            decorationImage = new PImage(image);

            //Extrapolate the new position taking into account the image size and scale property.
            decorationImage.X = (x - (image.Width / 2)) / 100;
            decorationImage.Y = (y - (image.Height / 2)) / 100;

            float sigX = (x / 100) - ((sigDia / 2) - (image.Width / 2));
            float sigY = (y / 100) - ((sigDia / 2) - (image.Height / 2));
            float rrX = (x / 100) - ((rrDia / 2) - (image.Width / 2));
            float rrY = (y / 100) - ((rrDia / 2) - (image.Height / 2));
            float expX = (x / 100) - ((expDia / 2) - (image.Width / 2));
            float expY = (y / 100) - ((expDia / 2) - (image.Height / 2));

            //Setup the geometry, style and colors of the sprite.
            Pen sigPen = new Pen(Color.DarkSlateGray, 3.0F);
            Pen rrPen = new Pen(Color.Gray, 2.0F);
            rrPen.DashStyle = DashStyle.Dash;
            Pen expPen = new Pen(Color.LightGray, 1.0F);
            expPen.DashStyle = DashStyle.DashDotDot;

            PPath sigCircle = PPath.CreateEllipse(sigX, sigY, sigDia, sigDia);
            sigCircle.Pen = sigPen;
            PPath rrCircle = PPath.CreateEllipse(rrX, rrY, rrDia, rrDia);
            rrCircle.Pen = rrPen;
            PPath expCircle = PPath.CreateEllipse(expX, expY, expDia, expDia);
            expCircle.Pen = expPen;

            PNode sigNode = sigCircle;
            sigNode.Brush = Brushes.Transparent;

            PNode rrNode = rrCircle;
            rrNode.Brush = Brushes.Transparent;

            PNode expNode = expCircle;
            expNode.Brush = Brushes.Transparent;

            pname = new PText(name);
            pname.TextBrush = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X = (x / 100) - (pname.Width / 2);
            pname.Y = (y / 100) - 20;

            //Add all the geometry to the image
            decorationImage.AddChild(sigNode);
            decorationImage.AddChild(rrNode);
            decorationImage.AddChild(expNode);
            decorationImage.AddChild(pname);

            //Add placeholder nodes for nav_type visualization lookup.
            for (int i = 0; i < navType; i++)
            {
                decorationImage.AddChild(new PNode());
            }

            //Set all the children of the image non-pickable.
            decorationImage.ChildrenPickable = false;

            //Set the tag to this class for information retrieval later.
            decorationImage.Tag = this;

            // Attach event delegates directly to the node.
            decorationImage.MouseDown += new PInputEventHandler(Image_MouseDown);
            decorationImage.MouseUp += new PInputEventHandler(Image_MouseUp);
            decorationImage.MouseDrag += new PInputEventHandler(Image_MouseDrag);

            //Display Object by adding them to its layer
            layer.AddChild(decorationImage);
        }
        public HarvestableSprite(PLayer layer, DataRow r, PropertyGrid pg, DataGridView dgv)
        {
            _pg = pg;
            setupData(r);
            dr = r;
            _layer = layer;
            _dgv = dgv;

            String name = r["name"].ToString();
            float x = float.Parse(r["position_x"].ToString());
            float y = -(float.Parse(r["position_y"].ToString()));
            float sigRadius = float.Parse(r["signature"].ToString());
            float rrRadius = float.Parse(r["radar_range"].ToString());
            float ExplorationRange = float.Parse(r["exploration_range"].ToString());
            appearsInRadar = (Boolean) r["appears_in_radar"];
            int navType = int.Parse(r["nav_type"].ToString());
            string mfrTest = r["max_field_radius"].ToString();
            string srTest = r["spawn_radius"].ToString();
            float MaxFieldRadius;
            float MobSpawnRadius;

            if (mfrTest == "" || srTest == "")
            {
                MaxFieldRadius = 0.0f;
                MobSpawnRadius = 0.0f;
            }
            else
            {
                MaxFieldRadius = float.Parse(r["max_field_radius"].ToString());
                MobSpawnRadius = float.Parse(r["spawn_radius"].ToString());
            }

            int field = 0;

            try
            {
                field = int.Parse(r["field"].ToString());
            }
            catch (Exception)
            {
                field = 0;
            }

            float sigDia = (sigRadius * 2) / 100;
            float rrDia = (rrRadius * 2) / 100;
            float expDia = (ExplorationRange * 2) / 100;
            float spawnDia = (MobSpawnRadius * 2) / 100;
            float fieldDia = (MaxFieldRadius * 2) / 100;

            if (sigDia == 0)
            {
                sigDia = 5;
            }
            if (rrDia == 0)
            {
                rrDia = 5;
            }
            if (expDia == 0)
            {
                expDia = 5;
            }
            if (spawnDia == 0)
            {
                spawnDia = 5;
            }
            if (fieldDia == 0)
            {
                fieldDia = 5;
            }

            string dataDirectory = "Images";
            string filePath = Path.Combine("..", "..");
            string imageName = null;

            if (appearsInRadar == true)
            {
                imageName = "resource.png";
            }
            else
            {
                imageName = "resource.png";
            }

            if (field > 0)
            {
                imageName = "resourceField.png";
            }

            if (File.Exists(Path.Combine(dataDirectory, imageName)))
            {
                filePath = "";
            }

            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, imageName)));
            harvestableImage = new PImage(image);
            harvestableImage.X = (x - (image.Width / 2)) / 100;
            harvestableImage.Y = (y - (image.Height / 2)) / 100;

            float sigX = (x / 100) - ((sigDia / 2) - (image.Width / 2));
            float sigY = (y / 100) - ((sigDia / 2) - (image.Height / 2));
            float rrX = (x / 100) - ((rrDia / 2) - (image.Width / 2));
            float rrY = (y / 100) - ((rrDia / 2) - (image.Height / 2));
            float expX = (x / 100) - ((expDia / 2) - (image.Width / 2));
            float expY = (y / 100) - ((expDia / 2) - (image.Height / 2));
            float spawnX = (x / 100) - ((spawnDia / 2) - (image.Width / 2));
            float spawnY = (y / 100) - ((spawnDia / 2) - (image.Height / 2));
            float fieldX = (x / 100) - ((fieldDia / 2) - (image.Width / 2));
            float fieldY = (y / 100) - ((fieldDia / 2) - (image.Height / 2));

            Pen sigPen = new Pen(Color.Violet, 3.0F);
            Pen rrPen = new Pen(Color.Pink, 2.0F);
            rrPen.DashStyle = DashStyle.Dash;
            Pen expPen = new Pen(Color.LightPink, 1.0F);
            expPen.DashStyle = DashStyle.DashDotDot;
            Pen spawnPen = new Pen(Color.Red, 1.0F);
            spawnPen.DashStyle = DashStyle.Dot;
            Pen fieldPen = new Pen(Color.MediumPurple, 1.0F);
            fieldPen.DashStyle = DashStyle.Dot;

            PPath sigCircle = PPath.CreateEllipse(sigX, sigY, sigDia, sigDia);
            sigCircle.Pen = sigPen;
            PPath rrCircle = PPath.CreateEllipse(rrX, rrY, rrDia, rrDia);
            rrCircle.Pen = rrPen;
            PPath expCircle = PPath.CreateEllipse(expX, expY, expDia, expDia);
            expCircle.Pen = expPen;
            PPath spawnCircle = PPath.CreateEllipse(spawnX, spawnY, spawnDia, spawnDia);
            spawnCircle.Pen = spawnPen;
            PPath fieldCircle = PPath.CreateEllipse(fieldX, fieldY, fieldDia, fieldDia);
            fieldCircle.Pen = fieldPen;

            PNode sigNode = sigCircle;
            sigNode.Brush = Brushes.Transparent;
            PNode rrNode = rrCircle;
            rrNode.Brush = Brushes.Transparent;
            PNode expNode = expCircle;
            expNode.Brush = Brushes.Transparent;
            PNode spawnNode = spawnCircle;
            spawnNode.Brush = Brushes.Transparent;
            PNode fieldNode = fieldCircle;
            fieldNode.Brush = Brushes.Transparent;

            pname = new PText(name);
            pname.TextBrush = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X = (x / 100) - (pname.Width / 2);
            pname.Y = (y / 100) - 20;

            harvestableImage.AddChild(sigNode);
            harvestableImage.AddChild(rrNode);
            harvestableImage.AddChild(expNode);
            harvestableImage.AddChild(pname);

            //Add placeholder nodes for nav_type visualization lookup.
            for (int i = 0; i < navType; i++)
            {
                harvestableImage.AddChild(new PNode());
            }

            harvestableImage.AddChild(spawnNode);
            harvestableImage.AddChild(fieldNode);

            harvestableImage.ChildrenPickable = false;

            //Set the tag to this class for information retrieval later.
            harvestableImage.Tag = this;

            // Attach event delegates directly to the node.
            harvestableImage.MouseDown += new PInputEventHandler(Image_MouseDown);
            harvestableImage.MouseUp += new PInputEventHandler(Image_MouseUp);
            harvestableImage.MouseDrag += new PInputEventHandler(Image_MouseDrag);

            //Display Object by adding them to its layer
            layer.AddChild(harvestableImage);
        }
        public StargateSprite(PLayer layer, DataRow r, PropertyGrid pg, DataGridView dgv)
        {
            _pg = pg;
            setupData(r);
            dr = r;
            _layer = layer;
            _dgv = dgv;

            String name = r["name"].ToString();
            float x = float.Parse(r["position_x"].ToString());
            float y = -(float.Parse(r["position_y"].ToString()));
            float sigRadius = float.Parse(r["signature"].ToString());
            float rrRadius = float.Parse(r["radar_range"].ToString());
            float ExplorationRange = float.Parse(r["exploration_range"].ToString());
            appearsInRadar = (Boolean) r["appears_in_radar"];
            int navType = int.Parse(r["nav_type"].ToString());
            bool isClassSpecific = (Boolean) r["classSpecific"];
            int factionID = int.Parse(r["faction_id"].ToString());

            float sigDia = (sigRadius * 2) / 100;
            float rrDia = (rrRadius * 2) / 100;
            float expDia = (ExplorationRange * 2) / 100;

            if (sigDia == 0)
            {
                sigDia = 5;
            }
            if (rrDia == 0)
            {
                rrDia = 5;
            }
            if (expDia == 0)
            {
                expDia = 5;
            }

            string dataDirectory = "Images";
            string filePath = Path.Combine("..", "..");
            string imageName = null;

            if (appearsInRadar == true)
            {
                imageName = "standardGate.gif";
            }
            else
            {
                imageName = "hiddenGate.gif";
            }

            if (isClassSpecific == true)
            {
                imageName = "classSpecificGate.gif";
            }

            if (factionID != -1)
            {
                imageName = "FactionSpecificGate.gif";
            }

            if (File.Exists(Path.Combine(dataDirectory, imageName)))
            {
                filePath = "";
            }

            Image image = Image.FromFile(Path.Combine(filePath, Path.Combine(dataDirectory, imageName)));
            stargateImage = new PImage(image);
            stargateImage.X = (x - (image.Width/2)) / 100;
            stargateImage.Y = (y - (image.Height/2)) / 100;

            float sigX = (x / 100) - ((sigDia / 2) - (image.Width / 2));
            float sigY = (y / 100) - ((sigDia / 2) - (image.Height / 2));
            float rrX = (x / 100) - ((rrDia / 2) - (image.Width / 2));
            float rrY = (y / 100) - ((rrDia / 2) - (image.Height / 2));
            float expX = (x / 100) - ((expDia / 2) - (image.Width / 2));
            float expY = (y / 100) - ((expDia / 2) - (image.Height / 2));

            Pen sigPen = new Pen(Color.ForestGreen, 3.0F);
            Pen rrPen = new Pen(Color.GreenYellow, 2.0F);
            rrPen.DashStyle = DashStyle.Dash;
            Pen expPen = new Pen(Color.LightGreen, 1.0F);
            expPen.DashStyle = DashStyle.DashDotDot;

            PPath sigCircle = PPath.CreateEllipse(sigX, sigY, sigDia, sigDia);
            sigCircle.Pen = sigPen;
            PPath rrCircle = PPath.CreateEllipse(rrX, rrY, rrDia, rrDia);
            rrCircle.Pen = rrPen;
            PPath expCircle = PPath.CreateEllipse(expX, expY, expDia, expDia);
            expCircle.Pen = expPen;

            PNode sigNode = sigCircle;
            sigNode.Brush = Brushes.Transparent;

            PNode rrNode = rrCircle;
            rrNode.Brush = Brushes.Transparent;

            PNode expNode = expCircle;
            expNode.Brush = Brushes.Transparent;

            pname = new PText(name);
            pname.TextBrush = Brushes.White;
            pname.TextAlignment = StringAlignment.Center;
            pname.X = (x / 100) - (pname.Width / 2);
            pname.Y = (y / 100) - 20;

            stargateImage.AddChild(sigNode);
            stargateImage.AddChild(rrNode);
            stargateImage.AddChild(expNode);
            stargateImage.AddChild(pname);

            //Add placeholder nodes for nav_type visualization lookup.
            for (int i = 0; i < navType; i++)
            {
                stargateImage.AddChild(new PNode());
            }

            stargateImage.ChildrenPickable = false;

            //Set the tag to this class for information retrieval later.
            stargateImage.Tag = this;

            // Attach event delegates directly to the node.
            stargateImage.MouseDown += new PInputEventHandler(Image_MouseDown);
            stargateImage.MouseUp += new PInputEventHandler(Image_MouseUp);
            stargateImage.MouseDrag += new PInputEventHandler(Image_MouseDrag);

            //Display Object by adding them to its layer
            layer.AddChild(stargateImage);
        }
Esempio n. 15
0
		public override void Initialize() {
			PRoot root = Canvas.Root;
			PCamera camera = Canvas.Camera;		
			PLayer mainLayer = Canvas.Layer;	// viewed by the PCanvas camera, the lens is added to this layer.
			PLayer sharedLayer = new PLayer();			// viewed by both the lens camera and the PCanvas camera
			PLayer lensOnlyLayer = new PLayer();	// viewed by only the lens camera
		
			root.AddChild(lensOnlyLayer);
			root.AddChild(sharedLayer);
			camera.AddLayer(0, sharedLayer);
		
			PLens lens = new PLens();
			lens.SetBounds(10, 10, 100, 130);
			lens.AddLayer(0, lensOnlyLayer);		
			lens.AddLayer(1, sharedLayer);
			mainLayer.AddChild(lens);
			PBoundsHandle.AddBoundsHandlesTo(lens);

			// Create an event handler that draws squiggles on the first layer of the bottom
			// most camera.
			PDragSequenceEventHandler squiggleEventHandler = new SquiggleEventHandler();

			// add the squiggle event handler to both the lens and the
			// canvas camera.
			lens.Camera.AddInputEventListener(squiggleEventHandler);
			camera.AddInputEventListener(squiggleEventHandler);

			// remove default event handlers, not really nessessary since the squiggleEventHandler
			// consumes everything anyway, but still good to do.
			Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
			Canvas.RemoveInputEventListener(Canvas.ZoomEventHandler);

			PNode sharedNode = new SharedNode(lens);
			sharedNode.Brush = Brushes.Green;
			sharedNode.SetBounds(0, 0, 100, 200);
			sharedNode.TranslateBy(200, 200);
			sharedLayer.AddChild(sharedNode);
		
			PText label = new PText("Move the lens \n (by dragging title bar) over the green rectangle, and it will appear red. press and drag the mouse on the canvas and it will draw squiggles. press and drag the mouse over the lens and drag squiggles that are only visible through the lens.");
			label.ConstrainWidthToTextWidth = false;
			label.SetBounds(200, 100, 200, 200);
		
			sharedLayer.AddChild(label);				
		}