public BoardData() //コンストラクタ { InitializeComponent(); back = new Bitmap(pictureBox1.Width, pictureBox1.Height); fore = new Bitmap(pictureBox1.Width, pictureBox1.Height); this.pictureBox1.BackgroundImage = back; this.pictureBox1.Image = fore; Graphics g=Graphics.FromImage(back); BoardSizeWidth = pictureBox1.Width; BoardSizeHeight = pictureBox1.Height; gridsizewidth=BoardSizeWidth/squarelength; gridsizeheight = BoardSizeHeight / squarelength; CanPutObjectOnBoard=new bool[gridsizewidth, gridsizeheight]; for (int i = 0; i < gridsizewidth; i++) { for (int j = 0; j < gridsizeheight; j++) { CanPutObjectOnBoard[i, j] = true; g.FillRectangle(Brushes.White, i * squarelength, j * squarelength, squarelength, squarelength); //---------------------------デバック領域 //if (i == gridsizewidth / 2 || j == gridsizeheight / 2) //{ // CanPutObjectOnBoard[i, j] = true; //{ // g.FillRectangle(Brushes.White, i * squarelength, j * squarelength, squarelength, squarelength); //} // } //else { CanPutObjectOnBoard[i, j] = false; //{ // g.FillRectangle(Brushes.Black, i * squarelength, j * squarelength, squarelength, squarelength); //} //} //デバック領域エンド } } controlobj = new PlayerObject(gridsizeheight / 2, gridsizeheight / 2); //player = (PlayerObject)controlobj; ListObjectBoard.Add(controlobj); bmppaint.ObjectSetPaint(controlobj.ObjectPositionX,controlobj.ObjectPositionY,fore,ref CanPutObjectOnBoard,controlobj.ObjectSelectNum); pictureBox1.Refresh(); g.Dispose(); }
private void MoveOperation(BoardObject obj,int directionselect,int repititionnum) //ブロックスクリプト用移動命令 { CanPutObjectOnBoard[controlobj.ObjectPositionX, controlobj.ObjectPositionY] = true; switch(directionselect){ case 1: obj.moveUp(); break; case 2: obj.moveRight(); break; case 3: obj.moveLeft(); break; case 4: obj.moveDown(); break; } bmppaint = new BitmapPaintClass(squarelength); bmppaint.ObjectSetPaint(obj.ObjectPositionX, obj.ObjectPositionY, fore, ref CanPutObjectOnBoard, obj.ObjectSelectNum); }
public void ObjectSet(int x,int y,int ObjectSelectNum) //ブロックスクリプト用配置命令 { if (controlobj.ObjectPositionX == x && controlobj.ObjectPositionY == y) { return; } CanPutObjectOnBoard[x, y] = true; BoardObject NewObject = new BoardObject(); switch (ObjectSelectNum) { case 0: NewObject = new WallObject(x, y); ListObjectBoard.Add(NewObject); break; case 1: if (controlobj is PlayerObject == false) CanPutObjectOnBoard[controlobj.ObjectPositionX, controlobj.ObjectPositionY] = false; controlobj = new PlayerObject(x, y); NewObject = controlobj; ListObjectBoard[0] = controlobj; break; case 2: NewObject = new EnemyObject(x, y); ListObjectBoard.Add(NewObject); break; case 3: NewObject = new ItemObject(x, y); ListObjectBoard.Add(NewObject); break; case 4: NewObject = new GoalObject(x, y); ListObjectBoard.Add(NewObject); break; } if (NewObject is GoalObject || NewObject is ItemObject) { bmppaint.ObjectSetPaint(NewObject.ObjectPositionX, NewObject.ObjectPositionY, back, ref CanPutObjectOnBoard, NewObject.ObjectSelectNum); } else { bmppaint.ObjectSetPaint(NewObject.ObjectPositionX, NewObject.ObjectPositionY, fore, ref CanPutObjectOnBoard, NewObject.ObjectSelectNum); } pictureBox1.Refresh(); }
private void pictureBox1_Click(object sender, EventArgs e)//マウスクリックによるオブジェクトの操作権限の移行 { int x = -1; int y = -1; Point sp = System.Windows.Forms.Cursor.Position; System.Drawing.Point cp = pictureBox1.PointToClient(sp); GetCursolPosition(cp.X, cp.Y,ref x,ref y); squareX.Text = "squareX:" + x; squareY.Text = "squareY:" + y; WallObject wall = new WallObject(x, y); if (-1 < x) { //bmppaint.PointSquare(x,y,fore); //pictureBox1.Refresh(); switch (CanPutObjectOnBoard[x, y]) { case (false): { if(ListObjectBoard!=null){ controlobj = ListObjectBoard.Find(p => p.ObjectPositionX == x && p.ObjectPositionY == y); } break; } case (true): { //bmppaint.ObjectSetPaint(x, y, fore, ref CanPutObjectOnBoard,wall.ObjectSelectNum); //pictureBox1.Refresh(); break; } } } }