/// <summary> /// 获取转换后新的gizmo各顶点的相对坐标 /// </summary> /// <param name="type">0表示放大1表示缩小2表示旋转</param> /// <param name="id"></param> /// <returns></returns> public List <Point> getChangeRelativePoint(int type, int id) { GizmoComponents gizmo = scene.getGizmo(id); if (gizmo != null) { int size = gizmo.GizmoSize; int angle = (int)(gizmo.Angle * 180 / System.Math.PI); FormGizmoType formGizmoType = gizmo.FormGizmoType; switch (type) { case 0: size++; break; case 1: size--; break; case 2: angle = angle + 90; break; } if (size != 0) { return(getRelativePoint(formGizmoType, size, angle)); } } return(null); }
/// <summary> /// 根据size、angle、gizmo的种类获取该gizmo各个顶点相较于(0,0)的坐标 /// </summary> /// <param name="type">gizmo的种类</param> /// <param name="size">gizmo的放大倍数</param> /// <param name="angle">gizmo的旋转角度</param> /// <returns></returns> public List <Point> getRelativePoint(FormGizmoType type, int size, int angle) { List <Point> points = new List <Point>(); switch (type) { case FormGizmoType.Circle: points = GizmoShape.Circle.getPoint(size, angle); break; case FormGizmoType.Square: points = GizmoShape.Square.getPoint(size, angle); break; case FormGizmoType.Triangle: points = GizmoShape.Triangle.getPoint(size, angle); break; case FormGizmoType.PineBall: points = GizmoShape.Circle.getPoint(size, angle); break; case FormGizmoType.Trapezoid: points = GizmoShape.Trapezoid.getPoint(size, angle); break; case FormGizmoType.L: points = GizmoShape.L.getPoint(size, angle); break; case FormGizmoType.Baffle: points = GizmoShape.Rectangle.getPoint(size, angle); break; case FormGizmoType.BaffleX: points = GizmoShape.BaffleX.getPoint(size, angle); break; } return(points); }
/// <summary> /// 添加gizmo /// </summary> /// <param name="positionX"></param> /// <param name="positionY"></param> /// <param name="size"></param> /// <param name="angle"></param> /// <param name="type"></param> /// <param name="interval"></param> /// <returns></returns> public int addGizmo(float positionX, float positionY, int size, int angle, FormGizmoType type, float interval) { int id = 0; switch (type) { case FormGizmoType.Circle: id = addCircle(positionX, positionY, size, interval); break; case FormGizmoType.Square: id = addSquare(positionX, positionY, size, angle, interval); break; case FormGizmoType.Triangle: id = addTriangle(positionX, positionY, size, angle, interval); break; case FormGizmoType.PineBall: id = addPineBall(positionX, positionY, size, interval); break; case FormGizmoType.Trapezoid: id = addTrapezoid(positionX, positionY, size, angle, interval); break; case FormGizmoType.L: id = addL(positionX, positionY, size, angle, interval); break; case FormGizmoType.Baffle: id = addBaffle(positionX, positionY, size, angle, interval); break; case FormGizmoType.BaffleX: id = addBaffleX(positionX, positionY, size, angle, interval); break; } return(id); }
private void baffleX_Click(object sender, EventArgs e) { currentModel = 0; if (this.timer1.Enabled == true) { this.timer1.Enabled = false; } currentType = FormGizmoType.BaffleX; }
private void addGizmo(FormGizmoType formGizmoType) { id = -1; this.label3.Text = "当前GizmoId:" + id; currentModel = 0; if (this.timer1.Enabled == true) { this.timer1.Enabled = false; } currentType = formGizmoType; }
private void delete_Click(object sender, EventArgs e) { if (id != -1) { drawBoard.deleteGizmoById(id); gsystem.deleteGizmo(id); gsystem.startGame(); this.pictureBox1.Image = drawBoard.drawFrame(false, gsystem); id = -1; } this.timer1.Enabled = false; currentType = FormGizmoType.Null; currentModel = 1; }
/// <summary> /// 改变gizmo的大小、角度 /// </summary> /// <param name="positionX"></param> /// <param name="positionY"></param> /// <param name="type"></param> /// <param name="id"></param> /// <param name="interval"></param> /// <returns></returns> public int changeGizmo(float positionX, float positionY, int type, int id, float interval) { GizmoComponents gizmo = getGizmo(id); if (gizmo != null) { int size = gizmo.GizmoSize; int angle = (int)gizmo.Angle; FormGizmoType formGizmoType = gizmo.FormGizmoType; switch (type) { case 0: size++; break; case 1: size--; break; case 2: angle = (angle + 90) % 360; break; } if (size != 0) { deleteGizmo(id); int newId = 0; newId = addGizmo(positionX, positionY, size, angle, formGizmoType, interval); for (int i = 0; i < GizmoOpera.Count; i++) { if (gizmoOpera[i].id == id) { gizmoOpera[i].id = newId; } } return(newId); } } return(-1); }
private void changeMode_Click(object sender, EventArgs e) { if (this.timer1.Enabled == false) { this.textBox1.Visible = false; this.changeMode.Text = "编辑地图"; currentModel = 6; id = -1; this.timer1.Enabled = true; this.startOver.Visible = true; this.chooseGizmo.Visible = false; this.square.Visible = false; this.triangle.Visible = false; this.pineball.Visible = false; this.L.Visible = false; this.delete.Visible = false; this.baffleX.Visible = false; this.bigger.Visible = false; this.smaller.Visible = false; this.rotate.Visible = false; this.absorb.Visible = false; this.track.Visible = false; this.dynamic.Visible = false; this.down.Visible = false; this.up.Visible = false; this.left.Visible = false; this.right.Visible = false; this.circle.Visible = false; this.trapezoid.Visible = false; this.baffle.Visible = false; this.label1.Visible = false; this.label2.Visible = false; this.label3.Visible = false; this.label4.Visible = false; this.label5.Visible = false; } else { this.textBox1.Visible = true; this.changeMode.Text = "开始游戏"; this.startOver.Visible = false; this.chooseGizmo.Visible = true; this.square.Visible = true; this.triangle.Visible = true; this.pineball.Visible = true; this.L.Visible = true; this.delete.Visible = true; this.baffleX.Visible = true; this.bigger.Visible = true; this.smaller.Visible = true; this.rotate.Visible = true; this.absorb.Visible = true; this.track.Visible = true; this.dynamic.Visible = true; this.down.Visible = true; this.up.Visible = true; this.left.Visible = true; this.right.Visible = true; this.circle.Visible = true; this.trapezoid.Visible = true; this.baffle.Visible = true; this.label1.Visible = true; this.label2.Visible = true; this.label3.Visible = true; this.label4.Visible = true; this.label5.Visible = true; this.timer1.Enabled = false; currentType = FormGizmoType.Null; } }
/// <summary> /// 在scene中添加gizmo /// </summary> /// <param name="positionX"></param> /// <param name="positionY"></param> /// <param name="size"></param> /// <param name="angle"></param> /// <param name="type"></param> /// <param name="interval">网格在物理世界中的二分之一边长</param> /// <returns></returns> public int addGizmo(float positionX, float positionY, int size, int angle, FormGizmoType type, float interval) { return(scene.addGizmo(positionX, positionY, size, angle, type, interval)); }