// Khoi tao cac button cho mo vang void initMineButtons() { mine_btns = new List <Button>(); for (int i = 0; i < mine.listOfMine.Count(); i++) { SquareBlock block = mine.listOfMine[i]; Button btn = new Button(); btn.Location = new System.Drawing.Point(block.getX(), block.getY()); btn.Size = new System.Drawing.Size(block.getSize(), block.getSize()); if (block.getType() == 1) { btn.BackColor = Color.Gold; } else if (block.getType() == 2) { btn.BackColor = Color.Gray; } else if (block.getType() == 3) { btn.BackColor = Color.LightBlue; } mine_btns.Add(btn); this.Controls.Add(btn); } }
void drawHole(SquareBlock block, Color color) { GL.Enable(EnableCap.LineSmooth); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Hint(HintTarget.LineSmoothHint, HintMode.DontCare); GL.Enable(EnableCap.PolygonOffsetLine); GL.PolygonOffset(-1.0f, -1.0f); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); GL.LineWidth(1.0f); GL.Color3(color); GL.Begin(PrimitiveType.Triangles); foreach (SquareBlock.Node v in block.nodes) { GL.Vertex3((float)v.x[0], (float)v.y[0], (float)v.z[0]); GL.Vertex3((float)v.x[1], (float)v.y[1], (float)v.z[1]); GL.Vertex3((float)v.x[2], (float)v.y[2], (float)v.z[2]); } GL.End(); GL.Disable(EnableCap.LineSmooth); GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.PolygonOffsetLine); }
// Ham xet va cham giua 2 button cho phien ban offline SquareBlock touch(int index) { for (int i = 0; i < mine_btns.Count(); i++) { Button c = mine_btns[i]; if (!c.Equals(grabbers_btn[index]) && grabbers_btn[index].Bounds.IntersectsWith(c.Bounds)) { SquareBlock result = mine.listOfMine[i]; grabbers[index].grabbedItem_index = i; mine.listOfMine.RemoveAt(i); return(result); } } return(null); }
// Xu ly ket qua xet va cham tra ve tu server SquareBlock touch(int index) { int flag1 = tcp1.SendData("IS TOUCH"); int flag2 = tcp1.SendData(grabbers[index]); string tmp = tcp1.ReadStringData(); int receive = int.Parse(tmp); if (receive == -1) { return(null); } SquareBlock result = mine.listOfMine[receive]; grabbers[index].grabbedItem_index = receive; return(result); }
/// <summary> /// Generates a random block /// </summary> /// <param name="block">A reference to the Block object that will be affected</param> private void GenerateBlock(ref Block block) { switch (random.Next(0, 7)) { case 0: block = new IBlock(); break; case 1: block = new LBlock(); break; case 2: block = new RLBlock(); break; case 3: block = new SBlock(); break; case 4: block = new SquareBlock(); break; case 5: block = new TBlock(); break; case 6: block = new ZBlock(); break; default: throw new ArgumentException("Bad block type!"); } }
private void BlastCorpsViewer_MouseUp(object sender, MouseEventArgs e) { if (level != null && e.Button == System.Windows.Forms.MouseButtons.Left) { switch (Mode) { case MouseMode.Move: if (dragItem != null) { selectedItem = dragItem; OnSelectionChangedEvent(new SelectionChangedEventArgs(selectedItem, false, false)); dragItem = null; Invalidate(); } break; case MouseMode.Add: Int16 x = (Int16)levelX(e.X); Int16 z = (Int16)levelZ(e.Y); if (AddType == typeof(AmmoBox)) { AmmoBox box = new AmmoBox(x, level.carrier.y, z, 0); selectedItem = box; level.ammoBoxes.Add(box); } else if (AddType == typeof(CommPoint)) { CommPoint comm = new CommPoint(x, level.carrier.y, z, 0); selectedItem = comm; level.commPoints.Add(comm); } else if (AddType == typeof(RDU)) { RDU rdu = new RDU(x, level.carrier.y, z); selectedItem = rdu; level.rdus.Add(rdu); } else if (AddType == typeof(TNTCrate)) { TNTCrate tnt = new TNTCrate(x, level.carrier.y, z, 0, 0, 0, 0); selectedItem = tnt; level.tntCrates.Add(tnt); } else if (AddType == typeof(SquareBlock)) { SquareBlock block = new SquareBlock(x, level.carrier.y, z, SquareBlock.Type.Block, SquareBlock.Shape.Square); selectedItem = block; level.squareBlocks.Add(block); } else if (AddType == typeof(Vehicle)) { Vehicle vehicle = new Vehicle(0, x, level.carrier.y, z, 0); selectedItem = vehicle; level.vehicles.Add(vehicle); } else if (AddType == typeof(Building)) { Building building = new Building(x, level.carrier.y, z, 0, 0, 0, 0, 0); selectedItem = building; level.buildings.Add(building); } OnSelectionChangedEvent(new SelectionChangedEventArgs(selectedItem, true, false)); Invalidate(); break; } } }