Exemple #1
0
        private void Avatar_MouseUp(object sender, MouseEventArgs e)
        {
            CustomPictureBoxCircle circlebox = (CustomPictureBoxCircle)sender;

            isDragging         = false;
            circlebox.Location = SnapToGrid(circlebox.Location);
        }
Exemple #2
0
        /*****************************************************************
         * Function: Avatar_PlaceOnGrid
         * Trigger: double click on an avatar in the list of players & enemies
         * Where: main page
         * Result: Creates a duplicate avatar and places it on the grid
         ******************************************************************/
        public void Avatar_PlaceOnGrid(object sender, EventArgs e)
        {
            CustomPictureBoxCircle circlebox      = (CustomPictureBoxCircle)sender;
            CustomPictureBoxCircle circleboxClone = GetPictureBoxClone(circlebox);
            int duplicate = 0;

            if (circlebox.Tag.Equals("avatar"))
            {
                foreach (var avatarObject in tabPage1.Controls.OfType <CustomPictureBoxCircle>())
                {
                    Console.WriteLine(avatarObject.Name + ": debug");
                    if (avatarObject.Name.Equals(circlebox.Name.ToString()))
                    {
                        duplicate++;
                    }
                }

                if (duplicate == 1)
                {
                    return;
                }
                else
                {
                    circleboxClone.Location = new Point(250, 20);
                    circleboxClone.Size     = GridControl.returnAvatarSize(trackBar_gridsize.Value);
                    // this.Controls.Add(circleboxClone);
                    this.tabPage1.Controls.Add(circleboxClone);
                    //circlebox.Location = SnapToGrid(circleboxClone.Location);
                    circleboxClone.BringToFront();
                }
            }
        }
Exemple #3
0
        /*****************************************************************
         * Function: avatartooltip
         * Trigger: Hover over avatar on gameplay field
         * Where: main page
         * Result: Displays a tooltip showing who the avatar is
         ******************************************************************/
        private void avatartooltip(object sender, EventArgs e)
        {
            CustomPictureBoxCircle circlebox = (CustomPictureBoxCircle)sender;

            tempstorage      = circlebox.Name;
            tempstoragearray = tempstorage.Split('_');
            toolTip1.Show(tempstoragearray[1].ToString(), circlebox);
        }
Exemple #4
0
        /*****************************************************************
         * Functions: Avatar_MouseMove
         *         Avatar_MouseDown
         *         Avatar_MouseUp
         * Trigger: Hold and drag an avatar on the play field
         * Where: main page
         * Result: Moves the avatar around the grid
         ******************************************************************/
        private void Avatar_MouseMove(object sender, MouseEventArgs e)
        {
            CustomPictureBoxCircle circlebox = (CustomPictureBoxCircle)sender;

            if (isDragging && allowDrag)
            {
                circlebox.Top  = circlebox.Top + (e.Y - currentY);
                circlebox.Left = circlebox.Left + (e.X - currentX);
            }
        }
Exemple #5
0
        private CustomPictureBoxCircle createAvatarEnemy(string picturebox_name)
        {
            CustomPictureBoxCircle returnavatar = new CustomPictureBoxCircle();

            returnavatar.Location              = new Point(0, 0);
            returnavatar.Name                  = "picturebox_" + picturebox_name;
            returnavatar.Size                  = new Size(60, 60);
            returnavatar.BackColor             = customPictureBoxCircle_enemycreation_chosenAvatar.BackColor;
            returnavatar.BackgroundImage       = customPictureBoxCircle_enemycreation_chosenAvatar.BackgroundImage;
            returnavatar.BackgroundImageLayout = ImageLayout.Stretch;
            returnavatar.Tag          = "avatar";
            returnavatar.DoubleClick += new EventHandler(Form1.thisFormStatic.Avatar_PlaceOnGrid);
            return(returnavatar);
        }
Exemple #6
0
        /*****************************************************************
         * Result: creates a copy of a circle picturebox and 'clones it'
         ******************************************************************/
        private CustomPictureBoxCircle GetPictureBoxClone(CustomPictureBoxCircle origionalp)
        {
            CustomPictureBoxCircle pb = new CustomPictureBoxCircle();

            pb.Size = origionalp.Size;
            // pb.Name = "gameplay_" +origionalp.Name;
            pb.Name                  = origionalp.Name;
            pb.Size                  = origionalp.Size;
            pb.BackColor             = origionalp.BackColor;
            pb.BackgroundImage       = origionalp.BackgroundImage;
            pb.BackgroundImageLayout = origionalp.BackgroundImageLayout;
            pb.Tag         = origionalp.Tag;
            pb.MouseMove  += new MouseEventHandler(Avatar_MouseMove);
            pb.MouseDown  += new MouseEventHandler(Avatar_MouseDown);
            pb.MouseUp    += new MouseEventHandler(Avatar_MouseUp);
            pb.MouseHover += new EventHandler(Form1.thisFormStatic.avatartooltip);

            return(pb);
        }
Exemple #7
0
 public Enemy(string name, CustomPictureBoxCircle avatar, int health)
 {
     this.name   = name;
     this.avatar = avatar;
     this.health = health;
 }
        /*****************************************************************
         * Description: when a user clicks on a picture box, assign
         * its background image to the main avatar
         ******************************************************************/
        private void picturebox_click(object sender, EventArgs e)
        {
            CustomPictureBoxCircle clickedAvatar = sender as CustomPictureBoxCircle;

            customPictureBoxCircle_chosenAvatar.BackgroundImage = clickedAvatar.BackgroundImage;
        }
Exemple #9
0
 public Player(string name, CustomPictureBoxCircle avatar)
 {
     this.name   = name;
     this.avatar = avatar;
 }