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; } } } }