Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Drawing;
- using PlayerIO.GameLibrary;
- namespace Enline
- {
- class Detector
- {
- //public System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(600, 600, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
- public System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(30,255,0,0), 4);
- public int R = 20; //radius around the player locations to check
- //public Player checkee;
- public void Main() {
- }
- public Rectangle result(Player checkee, List<Player> players) {
- //List<Graphics> lines = new List<Graphics>();
- Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red, 4f);
- Bitmap bitmap = new System.Drawing.Bitmap(600, 600, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
- Graphics g = Graphics.FromImage(bitmap);
- g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
- foreach (Player player in players)
- {
- if (player!=checkee) drawPath(player,g,bitmap);
- }
- g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
- drawPath(checkee, g, bitmap);
- //findTheSpot(bitmap,checkee);
- return findTheSpot(bitmap, checkee);
- g.Dispose();
- }
- public Graphics drawPath(Player player, Graphics g, Bitmap bitmap){
- //Graphics g = Graphics.FromImage(bitmap);
- float command;
- bool counts = false;
- List<PointF> path = new List<PointF>();
- for (int q = 0; q < player.path.Count; q += 3)
- {
- command = player.path[q];
- if (command == 1) counts = !counts;
- path.Add(new PointF(player.path[q + 1], player.path[q + 2]));
- if (counts != true)
- {
- g.DrawLines(pen, path.ToArray());
- path.Clear();
- g = Graphics.FromImage(bitmap);
- }
- }
- return g;
- }
- public Rectangle findTheSpot(Bitmap map, Player player){
- Color pixel;
- Rectangle rect = new Rectangle(0,0,0,0);
- map.Save("C:\\Photon\\hitmap.bmp");
- int minWidth = Convert.ToInt16( player.x - R);
- if (minWidth < 0) minWidth = 0;
- int minHeight = Convert.ToInt16(player.y - R);
- if (minHeight < 0) minHeight = 0;
- int maxWidth = minWidth + R*2;
- if (maxWidth > map.Width) maxWidth = map.Width;
- int maxHeight = minHeight + R*2;
- if (maxHeight > map.Height) maxHeight = map.Height;
- for (int i = minWidth; i < maxWidth; i++)
- {
- for (int k = minHeight; k < maxHeight; k++)
- {
- pixel = map.GetPixel(i, k);
- if (pixel.A != 0 && pixel.A != pen.Color.A)
- {
- if (rect.X == 0) rect.X = i;
- if (rect.Y == 0) rect.Y = k;
- if (rect.Width < i - rect.X) rect.Width = i - rect.X;
- if (rect.Height < k) rect.Height = k - rect.Y;
- }
- }
- }
- return rect;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement