示例#1
0
        public Editor(List <Tuple <int, List <HitShape> > > loadedHitboxes, string p_tilesetName, Form1 p_parentForm, int startTile, int maxTile, int tw, int th)
        {
            InitializeComponent();
            move         = false;
            centerPos.X  = pictureBox.Width / 2;  //tw / 2;
            centerPos.Y  = pictureBox.Height / 2; //th / 2;
            tilesetName  = p_tilesetName;
            currHitShape = null;
            //state = State.S_DRAWRECT1;
            state            = State.S_DRAWCIRCLE;
            parentForm       = p_parentForm;
            minFrame         = startTile;
            maxFrame         = maxTile;
            currFrame        = minFrame;
            pictureBox.Image = parentForm.ims[currFrame - minFrame];
            pictureBox.Refresh();
            currFrameLabel.Text = (currFrame - startTile).ToString() + " / " + (maxTile - startTile).ToString();
            Color c = Color.FromArgb(80, 255, 0, 0);

            hitboxBrush     = new System.Drawing.SolidBrush(c);
            minCircleRadius = 2;
            hitboxLists     = new List <HitShape> [(maxTile - startTile) + 1];
            for (int i = 0; i < hitboxLists.Length; ++i)
            {
                hitboxLists[i] = new List <HitShape>();
            }
            LoadHitboxes(loadedHitboxes);
        }
示例#2
0
        private void pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            Point mPos = new Point(e.X, e.Y);

            if (e.Button == MouseButtons.Left)
            {
                switch (state)
                {
                case State.S_DRAWCIRCLE:
                {
                    currHitShape = new CircleHitShape();
                    CircleHitShape chs = (CircleHitShape)currHitShape;
                    chs.centerPos.X = e.X;
                    chs.centerPos.Y = e.Y;
                    chs.radius      = minCircleRadius;
                    break;
                }

                case State.S_DRAWRECT1:
                {
                    currHitShape = new RectHitShape();
                    RectHitShape rhs = (RectHitShape)currHitShape;
                    rhs.SetRect(mPos, minCircleRadius, minCircleRadius, 0);
                    break;
                }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (currHitShape != null)
                {
                    currHitShape = null;
                    if (state == State.S_DRAWRECT2)
                    {
                        state = State.S_DRAWRECT1;
                    }
                }
                else
                {
                    List <HitShape> hList = hitboxLists[currFrame - minFrame];
                    foreach (HitShape ht in hList.Reverse <HitShape>())
                    {
                        if (ht.HasPoint(mPos))
                        {
                            hList.Remove(ht);
                        }
                        //if contains mouse position, then remove the hitbox
                    }
                    pictureBox.Refresh();
                }
            }
        }
示例#3
0
        public override bool IsSame(HitShape hShape)
        {
            if (hShape.sh != sh)
            {
                return(false);
            }

            if (hShape is RectHitShape)
            {
                RectHitShape rhs = hShape as RectHitShape;
                return(rhs.width == width && rhs.height == height && rhs.angle == angle && rhs.centerPos.X == centerPos.X && rhs.centerPos.Y == centerPos.Y);
            }
            else
            {
                return(false);
            }
        }
        public override bool IsSame(HitShape hShape)
        {
            if (hShape.sh != sh)
            {
                return(false);
            }

            if (hShape is CircleHitShape)
            {
                CircleHitShape chs = hShape as CircleHitShape;
                return(chs.radius == radius && chs.centerPos.X == centerPos.X && chs.centerPos.Y == centerPos.Y);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
        private void openButton_Click(object sender, EventArgs e)
        {
            string hitboxFileName = GetHitboxFileName();

            if (!hitboxFileName.Equals(""))
            {
                //spriteNameLabel.Text = openFileDialog1.SafeFileName;

                //string str = openFileDialog1.SafeFileName;

                using (StreamReader sr = new StreamReader(hitboxFileName))
                {
                    // int nameLen = Convert.ToInt32(sr.ReadLine());
                    string tilesetName = sr.ReadLine();

                    currFileName = tilesetName;

                    LoadSpriteSheet(tilesetName);

                    startIndexBox.Text = sr.ReadLine();
                    numTilesBox.Text   = sr.ReadLine();

                    int numPopulatedFrames = Convert.ToInt32(sr.ReadLine());
                    loadedHitboxes = new List <Tuple <int, List <HitShape> > >();
                    for (int i = 0; i < numPopulatedFrames; ++i)
                    {
                        int             frameIndex  = Convert.ToInt32(sr.ReadLine());
                        int             numHitboxes = Convert.ToInt32(sr.ReadLine());
                        List <HitShape> hList       = new List <HitShape>();

                        for (int h = 0; h < numHitboxes; ++h)
                        {
                            hList.Add(HitShape.Load(sr, gCenter));
                        }

                        Tuple <int, List <HitShape> > t = new Tuple <int, List <HitShape> >(frameIndex, hList);
                        loadedHitboxes.Add(t);
                    }
                }
                StartEditor();
            }
        }
示例#6
0
        private void pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
            case MouseButtons.Left:
            {
                switch (state)
                {
                case State.S_DRAWRECT2:
                {
                    state = State.S_DRAWRECT1;

                    hitboxLists[currFrame - minFrame].Add(currHitShape);
                    currHitShape = null;
                    pictureBox.Refresh();
                    break;
                }

                case State.S_DRAWCIRCLE:
                {
                    hitboxLists[currFrame - minFrame].Add(currHitShape);
                    currHitShape = null;
                    pictureBox.Refresh();
                    break;
                }

                case State.S_DRAWRECT1:
                {
                    state = State.S_DRAWRECT2;
                    break;
                }
                }
                break;
            }

            case MouseButtons.Right:
            {
                break;
            }
            }
        }
示例#7
0
 abstract public bool IsSame(HitShape hShape);