Esempio n. 1
0
 public GameObject(Image image, float x, float y, float width)
 {
     pictureBox = new CustomPictureBox(image);
     position   = new Vector2(x, y);
     //size = new Vector2(width, height);
     this.width = width;
 }
Esempio n. 2
0
 public GameObject(Image image, Vector2 position, float width)
 {
     pictureBox    = new CustomPictureBox(image);
     this.position = position;
     //this.size = size;
     this.width = width;
 }
Esempio n. 3
0
        private void DrawLevelToPanel(Panel panel, Level level)
        {
            //if (imagesInLevel.ContainsKey(panel) && !imagesInLevel[panel].Where(tupel => tupel.Item1.hasToRedraw).Any()) return;


            panel.BackColor = level.backgroundColor;


            //if (!imagesInLevel.ContainsKey(panel)) {
            //    //imagesInLevel.Add(panel, new List<(GameObject, CustomPictureBox)>());
            //    panel.SendToBack();
            //    panel.BackColor = level.backgroundColor;
            //} else {
            //    //for (int i = imagesInLevel[panel].Count - 1; i >= 0; i--) {
            //    //    var tupel = imagesInLevel[panel][i];
            //    //    if (tupel.Item1.hasToRedraw) {
            //    //        imagesInLevel[panel].Remove(tupel);
            //    //        tupel.Item2.Dispose();
            //    //    } else {
            //    //        tupel.Item2.BringToFront();
            //    //    }
            //    //}
            //}

            foreach (GameObject gameObject in level.objects)
            {
                if (!gameObject.hasToRedraw)
                {
                    continue;
                }
                gameObject.hasToRedraw = false;

                CustomPictureBox pb = gameObject.pictureBox;
                pb.Size = gameObject.GetSizeFromWidth();
                //Console.WriteLine(pb.Size + "," + gameObject.position);
                //pb.Top = panel.Top + (int)(panel.Height) /* *(1f - gameObject.position.y)) - pb.Height*/;
                //pb.Top = panel.Top - pb.Height;
                pb.Top  = (int)((panel.Height - pb.Height) * (1f - gameObject.position.y));
                pb.Left = (int)(gameObject.position.x * MainHandler.windowSize.Width);
                //Console.WriteLine(pb.Location);
                //pb.Image = gameObject.pictureBox.Image;
                //pb.BackColor = Color.FromArgb(255, 255, 120, 150);
                //pb.BackColor = Color.Transparent;
                pb.BorderStyle         = BorderStyle.FixedSingle; //#DEBUG
                pb.overlay.BorderStyle = BorderStyle.FixedSingle; //#DEBUG
                if (!panel.Controls.Contains(pb))
                {
                    panel.Controls.Add(pb);
                }
                //imagesInLevel[panel].Add((gameObject, pb));
                pb.BringToFront();
            }
        }
Esempio n. 4
0
 public GameObject(Image image, float x, float y)
 {
     pictureBox = new CustomPictureBox(image);
     position   = new Vector2(x, y);
 }
Esempio n. 5
0
 public GameObject(Image image, Vector2 position)
 {
     pictureBox    = new CustomPictureBox(image);
     this.position = position;
 }
Esempio n. 6
0
 public GameObject(Image image)
 {
     pictureBox = new CustomPictureBox(image);
 }