internal static SubBlock GetSubBlock(int subblockid) { SubBlock subBlock = null; using (SqlConnection connection = new SqlConnection(connectionString)) { try { connection.Open(); SqlCommand cmdGetCustomers = new SqlCommand("select * from SubBlock, TrialType WHERE SubBlockID=@SubBlockID", connection); cmdGetCustomers.Parameters.Add(new SqlParameter("@SubBlockID", subblockid)); SqlDataReader reader = cmdGetCustomers.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { subBlock = new SubBlock(reader.GetInt32(0), reader.GetString(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetInt32(5), reader.GetInt32(6), reader.GetInt32(7), reader.GetInt32(8), reader.GetString(10), new TrialType(reader.GetString(12)), null); } } } catch (SqlException e) { } finally { connection.Close(); connection.Dispose(); } } return(subBlock); }
public IHttpActionResult PutSubBlock(int id, SubBlock subBlock) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != subBlock.SubBlockID) { return(BadRequest()); } db.Entry(subBlock).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SubBlockExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public NewT3Texture(NewT3Texture newClass) { headerSize = newClass.headerSize; textureSize = newClass.textureSize; isPVR = newClass.isPVR; SomeValue = newClass.SomeValue; unknownFlags = newClass.unknownFlags; platform = newClass.platform; ObjectName = newClass.ObjectName; SubObjectName = newClass.SubObjectName; Zero = newClass.Zero; OneValue = newClass.OneValue; OneByte = newClass.OneByte; UnknownData = newClass.UnknownData; HasOneValueTex = newClass.HasOneValueTex; Mip = newClass.Mip; Width = newClass.Width; Height = newClass.Height; Faces = newClass.Faces; ArrayMembers = newClass.ArrayMembers; TextureFormat = newClass.TextureFormat; Unknown1 = newClass.Unknown1; block = newClass.block; subBlock = newClass.subBlock; subBlock2 = newClass.subBlock2; Tex = newClass.Tex; }
/*private void UpdateGrid() * { * gridArr = gameWorld.allSubBlocks; * /*Clear(); * for (int x = (int) position.X; x < Width; x++) * { * for (int y = (int)position.Y; y < Height; y++) * { * if(gameWorld.allSubBlocks[x, y]) * SubBlock gridBlock = new SubBlock(x, y, Color.White, gameWorld); * if (SubBlock.GetSubBlockAtPosition(x, y) == null) * grid.Add(gridBlock); * } * } * } */ /// <summary> /// Draws the grid on the screen. /// </summary> /// <param name="gameTime">An object with information about the time that has passed in the game.</param> /// <param name="spriteBatch">The SpriteBatch used for drawing sprites and text.</param> public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { // UpdateGrid(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int correctedX = (int)(x + position.X); int correctedY = (int)(y + position.Y); //Debug.WriteLine("x: " + x + " Y ; " + y); if (gridArr[x, y] != null) { SubBlock subBlock = gridArr[x, y]; spriteBatch.Draw(emptyCell, new Vector2(correctedX * emptyCell.Width, correctedY * emptyCell.Height), subBlock.color); } else { spriteBatch.Draw(emptyCell, new Vector2(correctedX * emptyCell.Width, correctedY * emptyCell.Height), Color.White); } } } /* foreach(SubBlock subBlock in grid) * { * spriteBatch.Draw(emptyCell, new Vector2(subBlock.X * emptyCell.Width, subBlock.Y * emptyCell.Height), subBlock.Color); * }*/ }
public IHttpActionResult GetSubBlock(int id) { SubBlock subBlock = db.SubBlocks.Find(id); if (subBlock == null) { return(NotFound()); } return(Ok(subBlock)); }
public IHttpActionResult PostSubBlock(SubBlock subBlock) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SubBlocks.Add(subBlock); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = subBlock.SubBlockID }, subBlock)); }
public void Turn() { foreach (SubBlock subBlock in subBlockArray) { SubBlock turnBlock = GetCurrentTurnBlock(); int x = subBlock.x; int y = subBlock.y; int tx = turnBlock.x; int ty = turnBlock.y; subBlock.x = (y + tx - ty); subBlock.y = (tx + ty - x); } }
public IHttpActionResult DeleteSubBlock(int id) { SubBlock subBlock = db.SubBlocks.Find(id); if (subBlock == null) { return(NotFound()); } db.SubBlocks.Remove(subBlock); db.SaveChanges(); return(Ok(subBlock)); }
/// <summary> /// Creates a new TetrisGrid. /// </summary> /// <param name="b"></param> public TetrisGrid(Texture2D cell, Vector2 Position, GameWorld G, int Height, int Width) { gameWorld = G; emptyCell = cell; position = Position; width = Width; height = Height; correctHeight = (int)(height + position.Y); correctWidth = (int)(width + position.X); // correctHeight = (int)(Math.Abs(position.Y) + Math.Abs(Height)); // correctWidth = (int)(Math.Abs(position.X) + Math.Abs(Width)); gridArr = new SubBlock[width, height]; Clear(); }
public void Fall() { for (int x = 0; x < grid.width; x++) { if (rowBlocks[x] != null) { //SubBlock subBlock = rowBlocks[x]; SubBlock subBlock = new SubBlock(x, y, Color.Green, grid); if (subBlock.CanMoveTo(x, y + 1)) { grid.gridArr[x, y] = grid.gridArr[x, y + 1]; grid.gridArr[x, y] = null; } } } y += 1; //verschuift de rij eentje omlaag. ApplyChanges(); }
public bool CanTurn() { foreach (SubBlock subBlock in subBlockArray) { SubBlock turnBlock = GetCurrentTurnBlock(); int tx = turnBlock.x; int ty = turnBlock.y; SubBlock temporarySubBlock = new SubBlock(subBlock.y + tx - ty, -subBlock.x + tx + ty, subBlock.color, grid); if (TetrisGrid.IsInBounds(temporarySubBlock.x, temporarySubBlock.y, grid)) { if (grid.gridArr[temporarySubBlock.x, temporarySubBlock.y] != null) { return(false); } } else { return(false); } temporarySubBlock = null; } return(true); }
private void EmitBasicBlockDebugInfo(ModuleWriter writer, BasicBlock block) { // Compute instructions subblocks. List<SubBlock> subBlocks = new List<SubBlock> (); TokenPosition position = NullPosition; int start = 0; int index = 0; foreach(Instruction inst in block.GetInstructions()) { // Get the instruction position. TokenPosition instPos = inst.GetPosition(); if(instPos == null) instPos = NullPosition; if(instPos != position) { // Create a sub block for the previous set. if(index != 0) { SubBlock subBlock = new SubBlock(); subBlock.Position = position; subBlock.Start = (ushort)start; subBlock.End = (ushort)(index - 1); // Store the sub block. subBlocks.Add(subBlock); } // Store the start of the next subblock. start = index; position = instPos; } // Increase the index. ++index; } // Create the last sub block. SubBlock lastSubBlock = new SubBlock(); lastSubBlock.Position = position; lastSubBlock.Start = (ushort)(start); lastSubBlock.End = (ushort)(index - 1); // Store the sub block. subBlocks.Add(lastSubBlock); // Emit all of the sub blocks. ushort numSubs = (ushort)subBlocks.Count; writer.Write(numSubs); foreach(SubBlock subBlock in subBlocks) { writer.Write(subBlock.Start); writer.Write(subBlock.End); EmitPosition(writer, subBlock.Position); } }
private void EmitBasicBlockDebugInfo(ModuleWriter writer, BasicBlock block) { // Compute instructions subblocks. List <SubBlock> subBlocks = new List <SubBlock> (); TokenPosition position = NullPosition; int start = 0; int index = 0; foreach (Instruction inst in block.GetInstructions()) { // Get the instruction position. TokenPosition instPos = inst.GetPosition(); if (instPos == null) { instPos = NullPosition; } if (instPos != position) { // Create a sub block for the previous set. if (index != 0) { SubBlock subBlock = new SubBlock(); subBlock.Position = position; subBlock.Start = (ushort)start; subBlock.End = (ushort)(index - 1); // Store the sub block. subBlocks.Add(subBlock); } // Store the start of the next subblock. start = index; position = instPos; } // Increase the index. ++index; } // Create the last sub block. SubBlock lastSubBlock = new SubBlock(); lastSubBlock.Position = position; lastSubBlock.Start = (ushort)(start); lastSubBlock.End = (ushort)(index - 1); // Store the sub block. subBlocks.Add(lastSubBlock); // Emit all of the sub blocks. ushort numSubs = (ushort)subBlocks.Count; writer.Write(numSubs); foreach (SubBlock subBlock in subBlocks) { writer.Write(subBlock.Start); writer.Write(subBlock.End); EmitPosition(writer, subBlock.Position); } }