コード例 #1
0
 public CTreeObject(int _id, Rectangle _r, GameObject _g)
 {
     id = _id;
     oRect = _r;
     gameObject = _g;
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: hotkutepro/Mario-Bros-3
        private void pbImgMap_MouseMove(object sender, MouseEventArgs e)
        {
            if (ctype == typeO._null || mousedown == 0 || remove)
                return;
            int i = e.X / 16;
            int j = e.Y / 16;
            int index = j * colum_Count + i;
            if (index < 0 || index > row_Count * colum_Count)//Kiểm tra phần tử có chỉ số index có tồn tại hay không
                return;
            //Thêm đối tượng vào map
            if (lCTreeObject[index].id == -1)//Kiểm tra tại vị trí đang xét đã có hay chưa, có rồi thì thôi
            {
                lCTreeObject[index].id = index;
                lCTreeObject[index].gameObject.id = index;
            }
            else
                return;
            GameObject t = new GameObject(index, ctype);
            t.Image = pImageType.Image;
            t.Size = new System.Drawing.Size(t.Image.Width, t.Image.Height);
            t.Location = new Point(i * 16, j * 16);
            Rectangle r = new Rectangle(i * 16, j * 16, t.Image.Width, t.Image.Height);
            CTreeObject ct = new CTreeObject(index, r, t);
            ct.gameObject.MouseDown += new MouseEventHandler(cTreeObject_MouseDown);

            switch (ctype)
            {
                case typeO.brick:
                    c_brick.Add(ct);
                    pbImgMap.Controls.Add(c_brick[c_brick.Count - 1].gameObject);
                    c_brick[c_brick.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_brick[c_brick.Count - 1]);
                    break;
                case typeO.Music:
                    c_music.Add(ct);
                    pbImgMap.Controls.Add(c_music[c_music.Count - 1].gameObject);
                    c_music[c_music.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_music[c_music.Count - 1]);
                    break;
                case typeO.coin:
                    c_coin.Add(ct);
                    pbImgMap.Controls.Add(c_coin[c_coin.Count - 1].gameObject);
                    c_coin[c_coin.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_coin[c_coin.Count - 1]);
                    break;
                case typeO.drain:
                    c_drain.Add(ct);
                    pbImgMap.Controls.Add(c_drain[c_drain.Count - 1].gameObject);
                    c_drain[c_drain.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_drain[c_drain.Count - 1]);
                    break;
                /*case typeO.land:
                    c_land.Add(ct);
                    pbImgMap.Controls.Add(c_land[c_land.Count - 1].gameObject);
                    c_land[c_land.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_land[c_land.Count - 1]);
                    break;*/
                case typeO.leaf:
                    c_leaf.Add(ct);
                    pbImgMap.Controls.Add(c_leaf[c_leaf.Count - 1].gameObject);
                    c_leaf[c_leaf.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_leaf[c_leaf.Count - 1]);
                    break;
                case typeO.mushroom_red:
                    c_mushroom_red.Add(ct);
                    pbImgMap.Controls.Add(c_mushroom_red[c_mushroom_red.Count - 1].gameObject);
                    c_mushroom_red[c_mushroom_red.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_mushroom_red[c_mushroom_red.Count - 1]);
                    break;
                case typeO.p:
                    c_p.Add(ct);
                    pbImgMap.Controls.Add(c_p[c_p.Count - 1].gameObject);
                    c_p[c_p.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_p[c_p.Count - 1]);
                    break;
                /*case typeO.Box:
                    c_box.Add(ct);
                    pbImgMap.Controls.Add(c_box[c_box.Count - 1].gameObject);
                    c_box[c_box.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_box[c_box.Count - 1]);
                    break;*/
                case typeO.question_block:
                    c_question_block.Add(ct);
                    pbImgMap.Controls.Add(c_question_block[c_question_block.Count - 1].gameObject);
                    c_question_block[c_question_block.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_question_block[c_question_block.Count - 1]);
                    break;
                case typeO.star:
                    c_star.Add(ct);
                    pbImgMap.Controls.Add(c_star[c_star.Count - 1].gameObject);
                    c_star[c_star.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_star[c_star.Count - 1]);
                    break;
                case typeO.tarnooki:
                    c_tarnooki.Add(ct);
                    pbImgMap.Controls.Add(c_tarnooki[c_tarnooki.Count - 1].gameObject);
                    c_tarnooki[c_tarnooki.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_tarnooki[c_tarnooki.Count - 1]);
                    break;
                case typeO.tarnooki_fly:
                    c_tarnooki_fly.Add(ct);
                    pbImgMap.Controls.Add(c_tarnooki_fly[c_tarnooki_fly.Count - 1].gameObject);
                    c_tarnooki_fly[c_tarnooki_fly.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_tarnooki_fly[c_tarnooki_fly.Count - 1]);
                    break;
                case typeO.tortoise:
                    c_tortoise.Add(ct);
                    pbImgMap.Controls.Add(c_tortoise[c_tortoise.Count - 1].gameObject);
                    c_tortoise[c_tortoise.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_tortoise[c_tortoise.Count - 1]);
                    break;
                case typeO.tortoise_fly:
                    c_tortoise_fly.Add(ct);
                    pbImgMap.Controls.Add(c_tortoise_fly[c_tortoise_fly.Count - 1].gameObject);
                    c_tortoise_fly[c_tortoise_fly.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_tortoise_fly[c_tortoise_fly.Count - 1]);
                    break;
                case typeO.tortoise_red:
                    c_tortoise_red.Add(ct);
                    pbImgMap.Controls.Add(c_tortoise_red[c_tortoise_red.Count - 1].gameObject);
                    c_tortoise_red[c_tortoise_red.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_tortoise_red[c_tortoise_red.Count - 1]);
                    break;
                case typeO.tree:
                    c_tree.Add(ct);
                    pbImgMap.Controls.Add(c_tree[c_tree.Count - 1].gameObject);
                    c_tree[c_tree.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_tree[c_tree.Count - 1]);
                    break;
                case typeO.tree_red:
                    c_tree_red.Add(ct);
                    pbImgMap.Controls.Add(c_tree_red[c_tree_red.Count - 1].gameObject);
                    c_tree_red[c_tree_red.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_tree_red[c_tree_red.Count - 1]);
                    break;
                case typeO.tree_red_shoot:
                    c_tree_red_shoot.Add(ct);
                    pbImgMap.Controls.Add(c_tree_red_shoot[c_tree_red_shoot.Count - 1].gameObject);
                    c_tree_red_shoot[c_tree_red_shoot.Count - 1].gameObject.BringToFront();
                    lCtree.Add(c_tree_red_shoot[c_tree_red_shoot.Count - 1]);
                    break;
                //case typeO.tree_shoot:
                //    c_tree_shoot.Add(ct);
                //    pbImgMap.Controls.Add(c_tree_shoot[c_tree_shoot.Count - 1].gameObject);
                //    c_tree_shoot[c_tree_shoot.Count - 1].gameObject.BringToFront();
                //    lCtree.Add(c_tree_shoot[c_tree_shoot.Count - 1]);
                //    break;

            }
        }
コード例 #3
0
 public CTreeObject(GameObject _gameObject)
 {
     gameObject = _gameObject;
 }