internal CollisionEntity(CollisionManager manager, System.Drawing.Size size, int pointsPerSide) { PointsPerSide = pointsPerSide; var position = new Vector((size.Width/2), -(size.Height/2)); //Top Right var direction = new Vector(0, size.Height); //TopToBottom Right = getPoints(position, direction); position.X = -(size.Width / 2); //TopLeft Left = getPoints(position, direction); direction = new Vector(size.Width, 0); //LeftToRight Front = getPoints(position, direction); position.Y = size.Height / 2; //BottomLeft Back = getPoints(position, direction); //var bottomRightCorner = new Vector(size.Width/2, size.Height/2); //var leftToRightDirection = new Vector(-size.Width, size.Height); //Front = getPoints(topLeft, topRight); //Right = getPoints(topRight, bottomRight); //Back = getPoints(bottomRight, bottomLeft); //Left = getPoints(bottomLeft, topRight); collision = manager; }
/// <summary> /// Erstellt die Boxen mit Bildern /// </summary> /// <param name="uiSize">Die Größe, in der die Map angezeigt werden soll</param> public void Initialize(Size uiSize) { this.Size = uiSize; //x=breitengrad (x-achse) elementBoxes = new PictureBox[MapGrid.GridElementCollection.Length][]; for (var x = 0; x < MapGrid.GridElementCollection.Length; x++) { elementBoxes[x] = new PictureBox[MapGrid.GridElementCollection[x].Length]; var column = MapGrid.GridElementCollection[x]; for (var y = 0; y < column.Length; y++) { var gridElement = column[y]; var pictureBox = new System.Windows.Forms.PictureBox(); //pictureBox.SizeMode = PictureBoxSizeMode.AutoSize; gridElementWidth = (int)((MapGrid.Width / MapGrid.GridElementCollection.Length) * ScaleFactorWidth); gridElementHeight = (int)((MapGrid.Height / column.Length) * ScaleFactorHeight); pictureBox.Width = (int)gridElementWidth; pictureBox.Height = (int)gridElementHeight; var image = MapParser.GetImageById(gridElement.ImageId); pictureBox.Image = image; //pictureBox.BorderStyle = BorderStyle.FixedSingle; pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; var boxX = gridElementWidth * x; var boxY = gridElementHeight * y; pictureBox.Left = (int)boxX; pictureBox.Top = (int)boxY; elementBoxes[x][y] = pictureBox; //Auskommentiert, um die Testausgaben der Kollision zu sehen this.Controls.Add(elementBoxes[x][y]); } } Collision = new CollisionManager(MapGrid, gridElementWidth, gridElementHeight); }
/// <summary> /// Erstellt die Boxen mit Bildern /// </summary> /// <param name="uiSize">Die Größe, in der die Map angezeigt werden soll</param> public void Initialize(Size uiSize) { this.Size = uiSize; //x=breitengrad (x-achse) for (var x = 0; x < MapGrid.GridElementCollection.Length; x++) { var column = MapGrid.GridElementCollection[x]; for (var y = 0; y < column.Length; y++) { var gridElement = column[y]; gridElementWidth = (int)Math.Ceiling((MapGrid.Width / MapGrid.GridElementCollection.Length) * ScaleFactorWidth); gridElementHeight = (int)Math.Ceiling((MapGrid.Height / column.Length) * ScaleFactorHeight); MapParser.Initialize(gridElementWidth, gridElementHeight); } } Collision = new CollisionManager(MapGrid, gridElementWidth, gridElementHeight); }
/// <summary> /// Immer, wenn die das UserControl größer oder kleiner wird, müssen alle Bilder skaliert und umpositioniert werden, damit die anzeige passt /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Map_Resize(object sender, EventArgs e) { for (var x = 0; x < MapGrid.GridElementCollection.Length; x++) { var column = MapGrid.GridElementCollection[x]; for (var y = 0; y < column.Length; y++) { gridElementWidth = (int)((MapGrid.Width / MapGrid.GridElementCollection.Length) * ScaleFactorWidth); gridElementHeight = (int)(((double)MapGrid.Height / (double)column.Length) * (double)ScaleFactorHeight); } } Collision=new CollisionManager(MapGrid, gridElementWidth, gridElementHeight); ; }