public BlockIcon(Texture2D ter, Vector2 pos, BlockTypes type) { Terrain = ter; UvMap = pos; Type = type; //icon = new Texture2D }
public void SendBlockSet(BlockTypes type,Vector3 pos) { _outmsg = _client.CreateMessage(); _outmsg.Write((byte)PacketType.PlayerBlockSet); _outmsg.Write(pos); _outmsg.Write((byte)type); }
public Block(Point location, BlockTypes newBlockType) { if (newBlockType==BlockTypes.Undefined) { BlockType = (BlockTypes)(random.Next(7)) + 1; } else { BlockType = newBlockType; } square1 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); square2 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); square3 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); square4 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); switch(BlockType) { case BlockTypes.Square: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X+squareSize, location.Y); square3.Location = new Point(location.X, location.Y+squareSize); square4.Location = new Point(location.X+squareSize, location.Y+squareSize); break; case BlockTypes.Line: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X, location.Y+squareSize); square3.Location = new Point(location.X, location.Y+2*squareSize); square4.Location = new Point(location.X, location.Y+3*squareSize); break; case BlockTypes.J: square1.Location = new Point(location.X+squareSize, location.Y); square2.Location = new Point(location.X+squareSize, location.Y+squareSize); square3.Location = new Point(location.X+squareSize, location.Y+2*squareSize); square4.Location = new Point(location.X, location.Y+2*squareSize); break; case BlockTypes.L: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X, location.Y+squareSize); square3.Location = new Point(location.X, location.Y+2*squareSize); square4.Location = new Point(location.X+squareSize, location.Y+2*squareSize); break; case BlockTypes.T: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X+squareSize, location.Y); square3.Location = new Point(location.X+2*squareSize, location.Y); square4.Location = new Point(location.X+squareSize, location.Y+squareSize); break; case BlockTypes.Z: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X+squareSize, location.Y); square3.Location = new Point(location.X+squareSize, location.Y+squareSize); square4.Location = new Point(location.X+2*squareSize, location.Y+squareSize); break; case BlockTypes.S: square1.Location = new Point(location.X, location.Y+squareSize); square2.Location = new Point(location.X+squareSize, location.Y+squareSize); square3.Location = new Point(location.X+squareSize, location.Y); square4.Location = new Point(location.X+2*squareSize, location.Y); break; } }
public BaseBlock(Vector2 top, Vector2 forward, Vector2 backward, Vector2 right, Vector2 left, Vector2 bottom, BlockModel modelIn, bool solidIn, bool transparentIn, bool aimSolidIn, BlockTypes typeIn) { UvMapTop = top / 16f; UvMapForward = forward / 16f; UvMapBackward = backward / 16f; UvMapLeft = left / 16f; UvMapRight = right / 16f; UvMapBottom = bottom / 16f; Model = modelIn; Transparent = transparentIn; Solid = solidIn; AimSolid = aimSolidIn; Type = typeIn; }
public BaseBlock(Vector2 uvMapIn, BlockModel modelIn, bool solidIn, bool transparentIn, bool aimSolidIn, BlockTypes typeIn) { UvMapTop = uvMapIn / 16f; UvMapForward = uvMapIn / 16f; UvMapBackward = uvMapIn / 16f; UvMapLeft = uvMapIn / 16f; UvMapRight = uvMapIn / 16f; UvMapBottom = uvMapIn / 16f; Model = modelIn; Transparent = transparentIn; Solid = solidIn; AimSolid = aimSolidIn; Type = typeIn; }
public void GenerateCubeMap(BlockTypes type) { WorldMap = new BlockTypes[Mapsize, ChunkHeight, Mapsize]; EmptyMap(); for (int xi = 0; xi < Mapsize; xi++) { for (int zi = 0; zi < Mapsize; zi++) { for (int yi = 0; yi < (ChunkHeight / 2); yi++) { WorldMap[xi, yi, zi] = type; } } } }
public void OnActivate(Block block, int x, int y, int z) { BlockTypes.GetBlockType(type).OnActivate(this, x, y, z); }
public static Type ConvertToType(BlockTypes enumType) => _enumToType[enumType];
private bool readTables() { int num2; byte[] lenTab = new byte[20]; byte[] buffer2 = new byte[Compress.HUFF_TABLE_SIZE]; if ((base.inAddr > (base.readTop - 0x19)) && !base.unpReadBuf()) { return(false); } base.AddBits((8 - base.inBit) & 7); long num = base.GetBits() & -1; if ((num & 0x8000L) != 0L) { this.unpBlockType = BlockTypes.BLOCK_PPM; return(this.ppm.decodeInit(this, this.ppmEscChar)); } this.unpBlockType = BlockTypes.BLOCK_LZ; this.prevLowDist = 0; this.lowDistRepCount = 0; if ((num & 0x4000L) == 0L) { Utility.Fill <byte>(this.unpOldTable, 0); } base.AddBits(2); for (num2 = 0; num2 < 20; num2++) { int num3 = Utility.URShift(base.GetBits(), 12) & 0xff; base.AddBits(4); if (num3 == 15) { int num4 = Utility.URShift(base.GetBits(), 12) & 0xff; base.AddBits(4); if (num4 == 0) { lenTab[num2] = 15; } else { num4 += 2; while ((num4-- > 0) && (num2 < lenTab.Length)) { lenTab[num2++] = 0; } num2--; } } else { lenTab[num2] = (byte)num3; } } UnpackUtility.makeDecodeTables(lenTab, 0, base.BD, 20); int num5 = Compress.HUFF_TABLE_SIZE; num2 = 0; while (num2 < num5) { if ((base.inAddr > (base.readTop - 5)) && !base.unpReadBuf()) { return(false); } int num6 = this.decodeNumber(base.BD); if (num6 < 0x10) { buffer2[num2] = (byte)((num6 + this.unpOldTable[num2]) & 15); num2++; } else { int num7; if (num6 < 0x12) { if (num6 == 0x10) { num7 = Utility.URShift(base.GetBits(), 13) + 3; base.AddBits(3); } else { num7 = Utility.URShift(base.GetBits(), 9) + 11; base.AddBits(7); } while ((num7-- > 0) && (num2 < num5)) { buffer2[num2] = buffer2[num2 - 1]; num2++; } } else { if (num6 == 0x12) { num7 = Utility.URShift(base.GetBits(), 13) + 3; base.AddBits(3); } else { num7 = Utility.URShift(base.GetBits(), 9) + 11; base.AddBits(7); } while ((num7-- > 0) && (num2 < num5)) { buffer2[num2++] = 0; } } } } this.tablesRead = true; if (base.inAddr > base.readTop) { return(false); } UnpackUtility.makeDecodeTables(buffer2, 0, base.LD, 0x12b); UnpackUtility.makeDecodeTables(buffer2, 0x12b, base.DD, 60); UnpackUtility.makeDecodeTables(buffer2, 0x167, base.LDD, 0x11); UnpackUtility.makeDecodeTables(buffer2, 0x178, base.RD, 0x1c); Buffer.BlockCopy(buffer2, 0, this.unpOldTable, 0, this.unpOldTable.Length); return(true); }
public bool isSolid() { return(BlockTypes.GetBlockType(type).isSolid(this)); }
public Unit(string texString, int x, int y, int texWidth, int texHeight, Countries country, BlockTypes blockType) : base(texString, x, y, texWidth, texHeight) { _country = country; _blockType = blockType; }
public GameAdapter498() { BlockTypes.Register(BlockRegistry); EntityRegistry.Register <IEntityPlayer>(Minecraft.Entities.Player); }
public override SKColor GetColor(TetrisField field, Nomino Element, NominoElement block, BlockTypes BlockType, BCT PixelType) { throw new NotImplementedException(); }
public abstract void GenerateColumn(int x, int y, bool forceType = false, BlockTypes type = BlockTypes.Stone);
private static IEnumerable <T> GetInstances <T>() => BlockTypes .Where(t => t.IsClass && typeof(T).IsAssignableFrom(t)) .Select(Activator.CreateInstance) .Cast <T>();
public override SKPointI GetBlockSize(TetrisField field, BlockTypes BlockType) { throw new NotImplementedException(); }
public BlockPrefabBuilder(BlockTypes PrefabFromResource, bool RemoveRenderers = true) =>
public static void IncreaseBlockDataLevel(BlockTypes type) { Data.blocks[type].level += 1; }
public static UserProgressBlockData GetBlockData(BlockTypes type) { return(Data.blocks[type]); }
private bool readTables() { int num2; byte[] lenTab = new byte[20]; byte[] buffer2 = new byte[Compress.HUFF_TABLE_SIZE]; if ((base.inAddr > (base.readTop - 0x19)) && !base.unpReadBuf()) { return false; } base.AddBits((8 - base.inBit) & 7); long num = base.GetBits() & -1; if ((num & 0x8000L) != 0L) { this.unpBlockType = BlockTypes.BLOCK_PPM; return this.ppm.decodeInit(this, this.ppmEscChar); } this.unpBlockType = BlockTypes.BLOCK_LZ; this.prevLowDist = 0; this.lowDistRepCount = 0; if ((num & 0x4000L) == 0L) { Utility.Fill<byte>(this.unpOldTable, 0); } base.AddBits(2); for (num2 = 0; num2 < 20; num2++) { int num3 = Utility.URShift(base.GetBits(), 12) & 0xff; base.AddBits(4); if (num3 == 15) { int num4 = Utility.URShift(base.GetBits(), 12) & 0xff; base.AddBits(4); if (num4 == 0) { lenTab[num2] = 15; } else { num4 += 2; while ((num4-- > 0) && (num2 < lenTab.Length)) { lenTab[num2++] = 0; } num2--; } } else { lenTab[num2] = (byte) num3; } } UnpackUtility.makeDecodeTables(lenTab, 0, base.BD, 20); int num5 = Compress.HUFF_TABLE_SIZE; num2 = 0; while (num2 < num5) { if ((base.inAddr > (base.readTop - 5)) && !base.unpReadBuf()) { return false; } int num6 = this.decodeNumber(base.BD); if (num6 < 0x10) { buffer2[num2] = (byte) ((num6 + this.unpOldTable[num2]) & 15); num2++; } else { int num7; if (num6 < 0x12) { if (num6 == 0x10) { num7 = Utility.URShift(base.GetBits(), 13) + 3; base.AddBits(3); } else { num7 = Utility.URShift(base.GetBits(), 9) + 11; base.AddBits(7); } while ((num7-- > 0) && (num2 < num5)) { buffer2[num2] = buffer2[num2 - 1]; num2++; } } else { if (num6 == 0x12) { num7 = Utility.URShift(base.GetBits(), 13) + 3; base.AddBits(3); } else { num7 = Utility.URShift(base.GetBits(), 9) + 11; base.AddBits(7); } while ((num7-- > 0) && (num2 < num5)) { buffer2[num2++] = 0; } } } } this.tablesRead = true; if (base.inAddr > base.readTop) { return false; } UnpackUtility.makeDecodeTables(buffer2, 0, base.LD, 0x12b); UnpackUtility.makeDecodeTables(buffer2, 0x12b, base.DD, 60); UnpackUtility.makeDecodeTables(buffer2, 0x167, base.LDD, 0x11); UnpackUtility.makeDecodeTables(buffer2, 0x178, base.RD, 0x1c); Buffer.BlockCopy(buffer2, 0, this.unpOldTable, 0, this.unpOldTable.Length); return true; }
public virtual void OnNPCAtJob(BlockJobInstance blockJobInstance, ref NPCState state) { state.JobIsDone = true; MinerJobInstance instance = (MinerJobInstance)blockJobInstance; if (instance.BlockTypeBelow == null || instance.BlockTypeBelow == BuiltinBlocks.Types.air) { if (World.TryGetTypeAt(instance.Position.Add(0, -1, 0), out ItemTypes.ItemType foundType)) { if (foundType == BuiltinBlocks.Types.air) { ThreadManager.InvokeOnMainThread(() => ServerManager.TryChangeBlock(instance.Position, instance.BlockType, BuiltinBlocks.Types.air, instance.Owner)); state.SetCooldown(3.0); // I don't know what's going on here, floating miner jobs return; } instance.BlockTypeBelow = foundType; } else { state.SetCooldown(5.0); return; } } if (instance.MiningCooldown <= 0f) { float cooldown = 0f; if (instance.BlockTypeBelow.CustomDataNode?.TryGetAs("minerMiningTime", out cooldown) ?? false) { instance.MiningCooldown = cooldown; } if (instance.MiningCooldown <= 0f) { ThreadManager.InvokeOnMainThread(() => ServerManager.TryChangeBlock(instance.Position, instance.BlockType, BuiltinBlocks.Types.air, instance.Owner)); state.SetCooldown(3.0); // loaded block below, but it turned out to be non-mineable return; } } if (BlockTypes.ContainsByReference(instance.BlockType, out int index)) { Vector3 rotate = instance.NPC.Position.Vector; switch (index) { case 1: rotate.x += 1f; break; case 2: rotate.x -= 1f; break; case 3: rotate.z += 1f; break; case 4: rotate.z -= 1f; break; } instance.NPC.LookAt(rotate); } AudioManager.SendAudio(instance.Position.Vector, "stoneDelete"); GatherResults.Clear(); var itemList = instance.BlockTypeBelow.OnRemoveItems; for (int i = 0; i < itemList.Count; i++) { GatherResults.Add(itemList[i]); } ModLoader.Callbacks.OnNPCGathered.Invoke(instance, instance.Position.Add(0, -1, 0), GatherResults); InventoryItem toShow = ItemTypes.ItemTypeDrops.GetWeightedRandom(GatherResults); if (toShow.Amount > 0) { state.SetIndicator(new Shared.IndicatorState(instance.MiningCooldown, toShow.Type)); } else { state.SetCooldown(instance.MiningCooldown); } state.Inventory.Add(GatherResults); instance.GatheredItemCount++; if (instance.GatheredItemCount >= MaxCraftsPerRun) { instance.ShouldTakeItems = true; } }
public void SetMapBlock(int x, int y, int z, BlockTypes type) { if (PointWithinMap(new Vector3(x, y, z))) { Chunk c = GetChunkAtPosition(x, z); int xb, yb, zb; xb = (x % Chunk.Size); yb = y; zb = (z % Chunk.Size); c.SetBlock(xb, yb, zb, Blocks[(int)type], false); } }
public void SetBlock(Block block) { ResultBlockType = block.BlockType; BlockData = JsonConvert.SerializeObject(block); }
public Block(BlockTypes t,bool c, byte w) { this.type = t; conn = c; wall = w; extra = 0; }
public Vector3 getTopLeftBlockCoordinate(Vector3 mousePosition, BlockTypes blockType) { Vector3 topLeftCoordinate; topLeftCoordinate = Vector3.one; switch (blockType) { case BlockTypes.zBlock: topLeftCoordinate.x = mousePosition.x - squareSize; topLeftCoordinate.y = mousePosition.y + (squareSize * 1.5f); topLeftCoordinate.z = mousePosition.z; break; case BlockTypes.sBlock: topLeftCoordinate.x = mousePosition.x - squareSize; topLeftCoordinate.y = mousePosition.y + (squareSize * 1.5f); topLeftCoordinate.z = mousePosition.z; break; case BlockTypes.lBlock: topLeftCoordinate.x = mousePosition.x - squareSize; topLeftCoordinate.y = mousePosition.y + (squareSize * 1.5f); topLeftCoordinate.z = mousePosition.z; break; case BlockTypes.reverseLBlock: topLeftCoordinate.x = mousePosition.x - squareSize; topLeftCoordinate.y = mousePosition.y + (squareSize * 1.5f); topLeftCoordinate.z = mousePosition.z; break; case BlockTypes.tBlock: topLeftCoordinate.x = mousePosition.x - (squareSize * 1.5f); topLeftCoordinate.y = mousePosition.y + squareSize; topLeftCoordinate.z = mousePosition.z; break; case BlockTypes.iBlock: topLeftCoordinate.x = mousePosition.x - (squareSize / 2); topLeftCoordinate.y = mousePosition.y + (squareSize * 2); topLeftCoordinate.z = mousePosition.z; break; case BlockTypes.flatIBlock: topLeftCoordinate.x = mousePosition.x - (squareSize * 2); topLeftCoordinate.y = mousePosition.y + (squareSize / 2); topLeftCoordinate.z = mousePosition.z; break; case BlockTypes.smallOBlock: topLeftCoordinate.x = mousePosition.x - (squareSize / 2); topLeftCoordinate.y = mousePosition.y + (squareSize / 2); topLeftCoordinate.z = mousePosition.z; break; case BlockTypes.oBlock: topLeftCoordinate.x = mousePosition.x - squareSize; topLeftCoordinate.y = mousePosition.y + squareSize; topLeftCoordinate.z = mousePosition.z; break; case BlockTypes.bigOBlock: topLeftCoordinate.x = mousePosition.x - (squareSize * 1.5f); topLeftCoordinate.y = mousePosition.y + (squareSize * 1.5f); topLeftCoordinate.z = mousePosition.z; break; default: topLeftCoordinate.x = 0; topLeftCoordinate.y = 0; topLeftCoordinate.z = 0; Debug.LogError("INVALID BLOCKTYPE PASSED TO FUNCTION getTopLeftBlockCoordinate"); break; } return(topLeftCoordinate); }
public Block(Point location, BlockTypes newBlockType) { // Create the new block if (newBlockType == BlockTypes.Undefined) { BlockType = (BlockTypes)(random.Next(7)) + 1; //BlockType = BlockTypes.Line; //force line block for testing } else { BlockType = newBlockType; } // Create each of the squares of the block // Set the square colors, based on the block type square1 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); square2 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); square3 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); square4 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); // Set the squares positions based on the block type switch (BlockType) { case BlockTypes.Square: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X + squareSize, location.Y); square3.Location = new Point(location.X, location.Y + squareSize); square4.Location = new Point(location.X + squareSize, location.Y + squareSize); break; case BlockTypes.Line: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X, location.Y + squareSize); square3.Location = new Point(location.X, location.Y + 2 * squareSize); square4.Location = new Point(location.X, location.Y + 3 * squareSize); break; case BlockTypes.J: square1.Location = new Point(location.X + squareSize, location.Y); square2.Location = new Point(location.X + squareSize, location.Y + squareSize); square3.Location = new Point(location.X + squareSize, location.Y + 2 * squareSize); square4.Location = new Point(location.X, location.Y + 2 * squareSize); break; case BlockTypes.L: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X, location.Y + squareSize); square3.Location = new Point(location.X, location.Y + 2 * squareSize); square4.Location = new Point(location.X + squareSize, location.Y + 2 * squareSize); break; case BlockTypes.T: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X + squareSize, location.Y); square3.Location = new Point(location.X + 2 * squareSize, location.Y); square4.Location = new Point(location.X + squareSize, location.Y + squareSize); break; case BlockTypes.Z: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X + squareSize, location.Y); square3.Location = new Point(location.X + squareSize, location.Y + squareSize); square4.Location = new Point(location.X + 2 * squareSize, location.Y + squareSize); break; case BlockTypes.S: square1.Location = new Point(location.X, location.Y + squareSize); square2.Location = new Point(location.X + squareSize, location.Y + squareSize); square3.Location = new Point(location.X + squareSize, location.Y); square4.Location = new Point(location.X + 2 * squareSize, location.Y); break; } }
public bool canDropBlock(Vector3 mousePosition, BlockTypes blockType) { Vector3 topLeftCoordinate = getTopLeftBlockCoordinate(mousePosition, blockType); Vector2 topLeftCoordinatev2 = new Vector2(topLeftCoordinate.x, topLeftCoordinate.y); Vector2 topLeftSquareIndex = new Vector2(); var raycastHit = Physics2D.BoxCast(topLeftCoordinatev2, Vector2.one * raycastSize, 0, Vector2.one); if (raycastHit.collider != null) { GameObject selectedCell = raycastHit.collider.gameObject; // Find index of selectedCell for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (gridColourArray[i, j] == selectedCell) { topLeftSquareIndex.x = j; topLeftSquareIndex.y = i; break; } } } //int quadrant = (selectedCell.GetComponent<GridCell>().getQuadrant(topLeftCoordinatev2)); bool canDrop = canBlockFit(topLeftSquareIndex, blockType); if (canDrop) { BlockSet(blockType, topLeftSquareIndex); } return(canDrop); } /* * // Check if topLeftCoordinate is within gridBoundriesExtended * if ((topLeftCoordinate.x >= gridBoundriesExtended.x) && (topLeftCoordinate.x <= gridBoundriesExtended.y) && * (topLeftCoordinate.y <= gridBoundriesExtended.z) && (topLeftCoordinate.y >= gridBoundriesExtended.w)) * { * Debug.Log("1"); * float xDifference = (topLeftCoordinate.x - gridBoundriesActual.x) / squareSize; * float yDifference = (gridBoundriesActual.z - topLeftCoordinate.y) / squareSize; * * // Find the square its most closely associated with * int col = Mathf.FloorToInt(xDifference); * int row = Mathf.FloorToInt(yDifference); * * // Check which quadrant of the square mousePosition is in * 1 2 * 3 4 * float quadrantXDifference = xDifference - col; * float quadrantYDifference = yDifference - row; * Vector2 topLeftSquareIndex; * * topLeftSquareIndex = new Vector2((float)col, (float)row); * * /* * if (quadrantXDifference <= 0.5f) * { * Debug.Log("2"); * // Lies in left quadrant * if (quadrantYDifference <= 0.5f) * { * // Lies in top left quadrant * topLeftSquareIndex = new Vector2((float)col, (float)row); * } * else * { * // Lies in bottom left quadrant * topLeftSquareIndex = new Vector2((float)col, (float)(row + 1)); * } * } * else * { * Debug.Log("3"); * // Lies in right quadrant * if (quadrantYDifference <= 0.5f) * { * // Lies in top right quadrant * topLeftSquareIndex = new Vector2((float)(col + 1), (float)row); * } * else * { * // Lies in bottom right quadrant * topLeftSquareIndex = new Vector2((float)(col + 1), (float)(row + 1)); * } * } * * bool canDrop = canBlockFit(topLeftSquareIndex, blockType); * * if (canDrop) * { * BlockSet(blockType, topLeftSquareIndex); * } * * * return canDrop; * } */ else { return(false); // Not within boundries } }
/// <summary> /// Retrieves the wallkick offsets for the given rotation. Uses SRS kick data. /// </summary> /// <param name="blockType">The type of block that is rotated.</param> /// <param name="oldOrientation">The starting orientation of the block.</param> /// <param name="newOrientation">The desired rotation of the block.</param> /// <remarks> /// Uses SRS (Super Rotation System) kick data. Specification was taken from: /// http://tetrisconcept.net/wiki/SRS at 05/26/2012. /// </remarks> public Point[] GetKickData(BlockTypes blockType, Orientation oldOrientation, Orientation newOrientation) { //Determine what the type of the block is, so we can read from the correct array. switch (blockType) { case BlockTypes.O: return kickDataO; case BlockTypes.I: return kickDataI[(int)oldOrientation, (int)newOrientation]; case BlockTypes.J: case BlockTypes.L: case BlockTypes.S: case BlockTypes.T: case BlockTypes.Z: return kickDataJLSTZ[(int)oldOrientation, (int)newOrientation]; default: return null; } //Type = J,L,S,T or Z. Old orient = spawn(up). New orient = Right //Point[] kickData = new Point[] //{ // new Point(0,0), // new Point(-1, 0), // new Point(-1, 1), // new Point(0, -2), // new Point(-1, -2) //}; }
private Color32 getColour(BlockTypes block) { return((Color32)colours[block]); }
/// <summary> /// ブロックのマテリアルを取得する /// </summary> /// <param name="type">ブロックの種類</param> /// <returns>マテリアル</returns> public Material GetBlockMaterial(BlockTypes type) => this.materialList[(int)type];
private Grid ParseGrid(string text) { var gridBlockType = BlockTypes.GetBlockTypeFor(typeof(List <MyObject>)); return((Grid)gridBlockType.Parse(text)); }
public Vector2 tex() { return(BlockTypes.GetBlockType(type).tex(this)); }
public void Update(GameTime gtime, InputHelper input) { if (_game.GameManager.Game.IsActive) { if (NoClip) //If noclipped { if (input.IsCurPress(Keys.LeftShift)) { Speed = 1.0f; } else { Speed = 0.5f; } if (input.IsCurPress((Keys)ClientKey.MoveForward)) { Position -= Cam.Forward * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveLeft)) { Position -= Cam.Right * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveBack)) { Position += Cam.Forward * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveRight)) { Position += Cam.Right * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveUp)) { Position += Vector3.Up * Speed; } if (input.IsCurPress((Keys)ClientKey.MoveDown)) { Position += Vector3.Down * Speed; } } else { //if (input.IsCurPress(Keys.W)) //{ // Position -= Cam.Forward * Speed; //} //if (input.IsCurPress(Keys.A)) //{ // Position -= Cam.Right * Speed; //} //if (input.IsCurPress(Keys.S)) //{ // Position += Cam.Forward * Speed; //} //if (input.IsCurPress(Keys.D)) //{ // Position += Cam.Right * Speed; //} ////Execute standard movement //Vector3 footPosition = Position + new Vector3(0f, -1.5f, 0f); //Vector3 headPosition = Position + new Vector3(0f, 0.1f, 0f); //Vector3 midPosition = Position + new Vector3(0f, -0.7f, 0f); //if (game.WorldManager.BlockAtPoint(headPosition) == BlockTypes.Water) //{ // bUnderwater = true; //} //else //{ // bUnderwater = false; //} //vPlayerVel.Y += Gravity * (float)gtime.ElapsedGameTime.TotalSeconds; //if (game.WorldManager.SolidAtPointForPlayer(footPosition) || game.WorldManager.SolidAtPointForPlayer(headPosition)) //{ // BlockTypes standingOnBlock = game.WorldManager.BlockAtPoint(footPosition); // BlockTypes hittingHeadOnBlock = game.WorldManager.BlockAtPoint(headPosition); // // If the player has their head stuck in a block, push them down. // if (game.WorldManager.SolidAtPointForPlayer(headPosition)) // { // int blockIn = (int)(headPosition.Y); // Position.Y = (blockIn - 0.15f); // } // // If the player is stuck in the ground, bring them out. // // This happens because we're standing on a block at -1.5, but stuck in it at -1.4, so -1.45 is the sweet spot. // if (game.WorldManager.SolidAtPointForPlayer(footPosition)) // { // int blockOn = (int)(footPosition.Y); // Position.Y = (float)(blockOn + 1 + 1.45); // } // vPlayerVel.Y = 0; //} } } //Re-initialize aim and aimblock vectors VAim = new Vector3(); VAimBlock = new Vector3(); //Check along a path stemming from the camera's forward if there is a collision for (float i = 0; i <= 6; i += 0.01f) { if (i < 5.5f) { VAim = Cam.Position - Cam.Forward * i; try { BaseBlock select = _game.WorldManager.BlockAtPoint(VAim); if (select.AimSolid) { break; //If there is, break the loop with the current aim vector } } catch { VAim = new Vector3(-10, -10, -10); break; } } else { VAim = new Vector3(-10, -10, -10); } } //Otherwise set it to be an empty vector if (VAim != new Vector3(-10, -10, -10)) { VAimBlock = new Vector3((int)Math.Floor(VAim.X), (int)Math.Floor(VAim.Y), (int)Math.Floor(VAim.Z)); //Get the aim block based off of that aim vector } Cam.Position = Position; if (_game.GameManager.Game.IsActive) { if (Mousehasfocus) { if (!input.IsCurPress(Keys.LeftAlt)) { Cam.Rotate( //Rotate the camera based off of mouse position, set mouse position to be screen center MathHelper.ToRadians((input.MousePosition.Y - _game.GameManager.Device.DisplayMode.Height / 2) * Sensitivity * 0.1f), MathHelper.ToRadians((input.MousePosition.X - _game.GameManager.Device.DisplayMode.Width / 2) * Sensitivity * 0.1f), 0.0f ); Mouse.SetPosition(_game.GameManager.Device.DisplayMode.Width / 2, _game.GameManager.Device.DisplayMode.Height / 2); } else { Mousehasfocus = false; } } else { Mousehasfocus = true; } } else { Mousehasfocus = false; } CreateFaceMarker(); //Create the face marker's vertices - I need to redo this method if (input.IsNewPress((MouseButtons)ClientKey.ActionOne)) { //We cant do a thing with empty hand if (LeftHand != null) { LeftHand.Use(); } } if (input.IsNewPress((MouseButtons)ClientKey.ActionTwo)) { //We cant do a thing with empty hand if (RightHand != null) { RightHand.Use(); } } if (input.MouseScrollWheelVelocity < 0f) { Selectedblock -= 1; if (Selectedblock < 0) { Selectedblock = 0; } Selectedblocktype = (BlockTypes)Selectedblock; } if (input.MouseScrollWheelVelocity > 0f) { Selectedblock += 1; if (Selectedblock > 63) { Selectedblock = 63; } Selectedblocktype = (BlockTypes)Selectedblock; } //Update our camera Cam.Update(); //Send our position to the server _game.ClientSender.SendMovementUpdate(); }
/// <summary> /// コンストラクタ <see cref="BlockAttribute" /> class. /// </summary> /// <param name="type">ブロックの種類</param> public BlockAttribute(BlockTypes type) { this.type = type; }
public static Tank LoadXMLAsTech(string path, Vector3 position, Quaternion rotation) { XmlDocument TechXML = new XmlDocument(); try { TechXML.Load(path); } catch { return(null); } var visible = Singleton.Manager <ManSpawn> .inst.SpawnEmptyTechRef(0, position, rotation, true, false, TechXML.GetElementsByTagName("Tech")[0].Attributes["Name"].Value).visible; Tank tech = visible.tank; for (int i = 0; i < TechXML.GetElementsByTagName("Block").Count; i++) { var BlockXML = TechXML.GetElementsByTagName("Block")[i]; try { if (BlockXML.Attributes["IsRootBlock"] != null) { BlockTypes blockType = (BlockTypes)Enum.Parse(typeof(BlockTypes), BlockXML.Attributes["Type"].Value); TankBlock block = Singleton.Manager <ManSpawn> .inst.SpawnBlock(blockType, position - Vector3.one, rotation); string OrthoRotationString = TechXML.SelectNodes("//BlockSpec/OrthoRotation")[i].InnerText; OrthoRotation.r OrthoRot = (OrthoRotation.r)Enum.Parse(typeof(OrthoRotation.r), OrthoRotationString); var cahedLocalPositionXML = TechXML.SelectNodes("//BlockSpec/IntVector3")[i].Attributes; IntVector3 localPositionIntVector = new IntVector3(int.Parse(cahedLocalPositionXML["x"].Value), int.Parse(cahedLocalPositionXML["y"].Value), int.Parse(cahedLocalPositionXML["z"].Value)); tech.blockman.AddBlock(ref block, localPositionIntVector, new OrthoRotation(OrthoRot)); var localPositionXML = TechXML.SelectNodes("//Transform/Position")[i].Attributes; Vector3 localPosition = new Vector3(float.Parse(localPositionXML["x"].Value), float.Parse(localPositionXML["y"].Value), float.Parse(localPositionXML["z"].Value)); var localRotationXML = TechXML.SelectNodes("//Transform/Rotation")[i].Attributes; Vector3 localRotation = new Vector3(float.Parse(localRotationXML["x"].Value), float.Parse(localRotationXML["y"].Value), float.Parse(localRotationXML["z"].Value)); var localScaleXML = TechXML.SelectNodes("//Transform/Scale")[i].Attributes; Vector3 localScale = new Vector3(float.Parse(localScaleXML["x"].Value), float.Parse(localScaleXML["y"].Value), float.Parse(localScaleXML["z"].Value)); block.trans.localPosition = localPosition; block.trans.localRotation = Quaternion.Euler(localRotation); block.trans.localScale = localScale; } } catch { break; } } for (int i = 0; i < TechXML.GetElementsByTagName("Block").Count; i++) { try { var BlockXML = TechXML.GetElementsByTagName("Block")[i]; if (BlockXML.Attributes["IsRootBlock"] != null) { continue; } BlockTypes blockType = (BlockTypes)Enum.Parse(typeof(BlockTypes), BlockXML.Attributes["Type"].Value); TankBlock block = Singleton.Manager <ManSpawn> .inst.SpawnBlock(blockType, position - Vector3.one, rotation); string OrthoRotationString = TechXML.SelectNodes("//BlockSpec/OrthoRotation")[i].InnerText; OrthoRotation.r OrthoRot = (OrthoRotation.r)Enum.Parse(typeof(OrthoRotation.r), OrthoRotationString); var cahedLocalPositionXML = TechXML.SelectNodes("//BlockSpec/IntVector3")[i].Attributes; IntVector3 localPositionIntVector = new IntVector3(int.Parse(cahedLocalPositionXML["x"].Value), int.Parse(cahedLocalPositionXML["y"].Value), int.Parse(cahedLocalPositionXML["z"].Value)); tech.blockman.AddBlock(ref block, localPositionIntVector, new OrthoRotation(OrthoRot)); //if (BlockXML.Attributes["IsRootBlock"] != null) tech.blockman.SetRootBlock(block); var localPositionXML = TechXML.SelectNodes("//Transform/Position")[i].Attributes; Vector3 localPosition = new Vector3(float.Parse(localPositionXML["x"].Value), float.Parse(localPositionXML["y"].Value), float.Parse(localPositionXML["z"].Value)); var localRotationXML = TechXML.SelectNodes("//Transform/Rotation")[i].Attributes; Vector3 localRotation = new Vector3(float.Parse(localRotationXML["x"].Value), float.Parse(localRotationXML["y"].Value), float.Parse(localRotationXML["z"].Value)); var localScaleXML = TechXML.SelectNodes("//Transform/Scale")[i].Attributes; Vector3 localScale = new Vector3(float.Parse(localScaleXML["x"].Value), float.Parse(localScaleXML["y"].Value), float.Parse(localScaleXML["z"].Value)); block.trans.localPosition = localPosition; block.trans.localRotation = Quaternion.Euler(localRotation); block.trans.localScale = localScale; } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); } } var newBlock = Singleton.Manager <ManSpawn> .inst.SpawnBlock(BlockTypes.GSOCockpit_111, Vector3.zero, Quaternion.identity); if (tech.blockman.blockCount == 0) { tech.blockman.AddBlock(ref newBlock, IntVector3.zero); } return(tech); }
private bool readTables() { byte[] bitLength = new byte[Compress.BC]; byte[] table = new byte[Compress.HUFF_TABLE_SIZE]; if (inAddr > readTop - 25) { if (!unpReadBuf()) { return(false); } } AddBits((8 - inBit) & 7); long bitField = GetBits() & unchecked ((int)0xffFFffFF); if ((bitField & 0x8000) != 0) { unpBlockType = BlockTypes.BLOCK_PPM; return(ppm.decodeInit(this, ppmEscChar)); } unpBlockType = BlockTypes.BLOCK_LZ; prevLowDist = 0; lowDistRepCount = 0; if ((bitField & 0x4000) == 0) { Utility.Fill(unpOldTable, (byte)0); // memset(UnpOldTable,0,sizeof(UnpOldTable)); } AddBits(2); for (int i = 0; i < Compress.BC; i++) { int length = (Utility.URShift(GetBits(), 12)) & 0xFF; AddBits(4); if (length == 15) { int zeroCount = (Utility.URShift(GetBits(), 12)) & 0xFF; AddBits(4); if (zeroCount == 0) { bitLength[i] = 15; } else { zeroCount += 2; while (zeroCount-- > 0 && i < bitLength.Length) { bitLength[i++] = 0; } i--; } } else { bitLength[i] = (byte)length; } } UnpackUtility.makeDecodeTables(bitLength, 0, BD, Compress.BC); int TableSize = Compress.HUFF_TABLE_SIZE; for (int i = 0; i < TableSize;) { if (inAddr > readTop - 5) { if (!unpReadBuf()) { return(false); } } int Number = this.decodeNumber(BD); if (Number < 16) { table[i] = (byte)((Number + unpOldTable[i]) & 0xf); i++; } else if (Number < 18) { int N; if (Number == 16) { N = (Utility.URShift(GetBits(), 13)) + 3; AddBits(3); } else { N = (Utility.URShift(GetBits(), 9)) + 11; AddBits(7); } while (N-- > 0 && i < TableSize) { table[i] = table[i - 1]; i++; } } else { int N; if (Number == 18) { N = (Utility.URShift(GetBits(), 13)) + 3; AddBits(3); } else { N = (Utility.URShift(GetBits(), 9)) + 11; AddBits(7); } while (N-- > 0 && i < TableSize) { table[i++] = 0; } } } tablesRead = true; if (inAddr > readTop) { return(false); } UnpackUtility.makeDecodeTables(table, 0, LD, Compress.NC); UnpackUtility.makeDecodeTables(table, Compress.NC, DD, Compress.DC); UnpackUtility.makeDecodeTables(table, Compress.NC + Compress.DC, LDD, Compress.LDC); UnpackUtility.makeDecodeTables(table, Compress.NC + Compress.DC + Compress.LDC, RD, Compress.RC); // memcpy(unpOldTable,table,sizeof(unpOldTable)); #if !PORTABLE Buffer.BlockCopy(table, 0, unpOldTable, 0, unpOldTable.Length); #else Array.Copy(table, 0, unpOldTable, 0, unpOldTable.Length); #endif return(true); }
public Dictionary <ExitTypes, List <SchemaBlock> > AnalyzeBlock(int start, int end, List <SchemaBlock> lastElement) { Dictionary <ExitTypes, List <SchemaBlock> > dict = new Dictionary <ExitTypes, List <SchemaBlock> > { [ExitTypes.EndofBlock] = new List <SchemaBlock>(), [ExitTypes.Return] = new List <SchemaBlock>(), [ExitTypes.Continue] = new List <SchemaBlock>(), [ExitTypes.Break] = new List <SchemaBlock>() }; List <SchemaBlock> prev = new List <SchemaBlock>(lastElement); string currentBlockContent = ""; BlockTypes currentBlockType = BlockTypes.Operator; for (int i = start; i <= end; i++) { // Conditions handling // if (words[i] == "if") { #region "if" analyze i++; while (words[++i] != ")") { currentBlockContent += words[i] + " "; } SchemaBlock block = new SchemaBlock(currentBlockContent, BlockTypes.Condition); currentBlockContent = ""; foreach (SchemaBlock item in prev) { item.links.Add(block); } prev.Clear(); prev.Add(block); if (words[++i] == "{") { dict = DictMix(dict, AnalyzeBlock(i + 1, i = getEndBracket(i) - 1, prev)); i++; } else { dict = DictMix(dict, AnalyzeBlock(i, i = Array.IndexOf(words, ";", i), prev)); } #endregion #region "else if" analyze while (words[i + 1] == "else" && words[i + 2] == "if") { i += 3; while (words[++i] != ")") { currentBlockContent += words[i] + " "; } block = new SchemaBlock(currentBlockContent, BlockTypes.Condition); currentBlockContent = ""; foreach (SchemaBlock item in prev) { item.links.Add(block); } prev.Clear(); prev.Add(block); if (words[++i] == "{") { dict = DictMix(dict, AnalyzeBlock(i + 1, i = getEndBracket(i) - 1, prev)); i++; } else { dict = DictMix(dict, AnalyzeBlock(i, i = Array.IndexOf(words, ";", i), prev)); } } #endregion #region "else" analyze if (words[++i] == "else") { if (words[++i] == "{") { dict = DictMix(dict, AnalyzeBlock(i + 1, i = getEndBracket(i) - 1, prev)); i++; } else { dict = DictMix(dict, AnalyzeBlock(i, i = Array.IndexOf(words, ";", i), prev)); } } else { dict[ExitTypes.EndofBlock] = prev.Union(dict[ExitTypes.EndofBlock]).ToList(); currentBlockContent += words[i] + " "; } #endregion prev = new List <SchemaBlock>(dict[ExitTypes.EndofBlock]); dict[ExitTypes.EndofBlock].Clear(); continue; } if (words[i] == "while") { i++; while (words[++i] != ")") { currentBlockContent += words[i] + " "; } SchemaBlock block = new SchemaBlock(currentBlockContent, BlockTypes.Condition); block.isCycleCondition = true; currentBlockContent = ""; foreach (SchemaBlock item in prev) { item.links.Add(block); } prev.Clear(); prev.Add(block); if (words[++i] == "{") { dict = DictMix(dict, AnalyzeBlock(i + 1, i = getEndBracket(i) - 1, prev)); i++; } else { dict = DictMix(dict, AnalyzeBlock(i, i = Array.IndexOf(words, ";", i), prev)); } foreach (SchemaBlock item in dict[ExitTypes.EndofBlock]) { item.links.Add(block); } dict[ExitTypes.EndofBlock].Clear(); foreach (SchemaBlock item in dict[ExitTypes.Continue]) { item.links.Add(block); } dict[ExitTypes.Continue].Clear(); prev = prev.Union(dict[ExitTypes.Break]).ToList(); continue; } if (words[i] == "for") { i++; while (words[++i] != ";") { currentBlockContent += words[i] + " "; } SchemaBlock block = new SchemaBlock(currentBlockContent, BlockTypes.Operator); currentBlockContent = ""; foreach (SchemaBlock item in prev) { item.links.Add(block); } prev.Clear(); prev.Add(block); while (words[++i] != ";") { currentBlockContent += words[i] + " "; } block = new SchemaBlock(currentBlockContent, BlockTypes.Condition); block.isCycleCondition = true; currentBlockContent = ""; foreach (SchemaBlock item in prev) { item.links.Add(block); } prev.Clear(); prev.Add(block); while (words[++i] != ")") { currentBlockContent += words[i] + " "; } SchemaBlock endBlock = new SchemaBlock(currentBlockContent, BlockTypes.Operator); currentBlockContent = ""; endBlock.links.Add(block); if (words[++i] == "{") { dict = DictMix(dict, AnalyzeBlock(i + 1, i = getEndBracket(i) - 1, prev)); i++; } else { dict = DictMix(dict, AnalyzeBlock(i, i = Array.IndexOf(words, ";", i), prev)); } foreach (SchemaBlock item in dict[ExitTypes.EndofBlock]) { item.links.Add(endBlock); } dict[ExitTypes.EndofBlock].Clear(); foreach (SchemaBlock item in dict[ExitTypes.Continue]) { item.links.Add(endBlock); } dict[ExitTypes.Continue].Clear(); prev = prev.Union(dict[ExitTypes.Break]).ToList(); continue; } //Not working correct!!! if (words[i] == "do") { if (words[++i] == "{") { dict = DictMix(dict, AnalyzeBlock(++i, i = getEndBracket(i - 1) - 1, prev)); i++; } else { dict = DictMix(dict, AnalyzeBlock(++i, i = Array.IndexOf(words, ";", i), prev)); } i += 2; while (words[++i] != ")") { currentBlockContent += words[i] + " "; } SchemaBlock block = new SchemaBlock(currentBlockContent, BlockTypes.Condition); currentBlockContent = ""; SchemaBlock startBlock = prev[0].links[prev[0].links.Count - 1]; block.links.Add(startBlock); foreach (SchemaBlock item in dict[ExitTypes.EndofBlock]) { item.links.Add(block); } dict[ExitTypes.EndofBlock].Clear(); foreach (SchemaBlock item in dict[ExitTypes.Continue]) { item.links.Add(block); } dict[ExitTypes.Continue].Clear(); prev.Clear(); prev.Add(block); prev = prev.Union(dict[ExitTypes.Break]).ToList(); dict[ExitTypes.EndofBlock] = prev; continue; } if (words[i] == "break") { dict[ExitTypes.Break] = dict[ExitTypes.Break].Union(prev).ToList(); return(dict); } if (words[i] == "continue") { dict[ExitTypes.Continue] = dict[ExitTypes.Continue].Union(prev).ToList(); return(dict); } if (words[i] == "return") { dict[ExitTypes.Return] = dict[ExitTypes.Return].Union(prev).ToList(); return(dict); } if (words[i] != ";") { if (Array.IndexOf(IOtags, words[i]) != -1) { currentBlockType = BlockTypes.IO; } else if (Array.IndexOf(ProcedureTags, words[i]) != -1) { currentBlockType = currentBlockType == BlockTypes.Operator ? BlockTypes.Procedure : currentBlockType; } currentBlockContent += words[i] + " "; } else { if (currentBlockContent != "") { SchemaBlock block = new SchemaBlock(currentBlockContent, currentBlockType); currentBlockContent = ""; currentBlockType = BlockTypes.Operator; foreach (SchemaBlock item in prev) { item.links.Add(block); } prev.Clear(); prev.Add(block); } } } dict[ExitTypes.EndofBlock] = prev.Union(dict[ExitTypes.EndofBlock]).ToList(); return(dict); }
public void SetBlock(int x,int y, int z, BlockTypes type) { ////If its outside the map then ignore it if (x < 0 || x >= Mapsize || y < 0 || y >= Chunk.Height || z < 0 || z >= Mapsize) { return; } Chunk c = GetChunkAtPosition(x, z); int xb,yb,zb; xb = (x % Chunk.Size); yb = y; zb = (z % Chunk.Size); c.SetBlock(xb, yb, zb, Blocks[(int)type],true); }
//SurfaceNetNode[,,] surfaceNodes; public Block() { this.BlockType = BlockTypes.Empty; //surfaceNodes = new SurfaceNetNode[2,2,2]; }
public Block(Point thisLocation,BlockTypes bType) { //当blockType为undefined时,随机产生方块形状 Random rand=new Random(); if (bType == BlockTypes.undefined) { blockType = (BlockTypes)(rand.Next(7) + 1); } else blockType = bType; //设置四小方块的颜色 int i=(int)blockType-1; foreColor = GameField.BlockForeColor[i]; backColor = GameField.BlockBackColor[i]; Size squareS=new Size(squareSize,squareSize); square1 = new Square(squareS, foreColor, backColor); square2 = new Square(squareS, foreColor, backColor); square3 = new Square(squareS, foreColor, backColor); square4 = new Square(squareS, foreColor, backColor); //设置小方块的位置,组合成指定形状的一个大方块 switch (blockType) { case BlockTypes.square: //组合成正方形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square3.location = new Point(thisLocation.X,thisLocation.Y+squareSize); square4.location = new Point(thisLocation.X+squareSize,thisLocation.Y+squareSize); break; case BlockTypes.line: //组合成线形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square3.location = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y); square4.location = new Point(thisLocation.X + 3 * squareSize, thisLocation.Y); break; case BlockTypes.J: //组合成J形 square1.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); square3.location = new Point(thisLocation.X + squareSize, thisLocation.Y + 2 * squareSize); square4.location = new Point(thisLocation.X, thisLocation.Y + 2 * squareSize); break; case BlockTypes.L: //组合成l形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X, thisLocation.Y + squareSize); square3.location = new Point(thisLocation.X, thisLocation.Y + 2 * squareSize); square4.location = new Point(thisLocation.X + squareSize, thisLocation.Y + 2 * squareSize); break; case BlockTypes.T: //组合成T形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square3.location = new Point(thisLocation.X + 2*squareSize, thisLocation.Y); square4.location = new Point(thisLocation.X + squareSize, thisLocation.Y +squareSize); break; case BlockTypes.Z: //组合成z形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square3.location = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); square4.location = new Point(thisLocation.X + 2*squareSize, thisLocation.Y + squareSize); break; case BlockTypes.S: //组合成S形 square1.location = new Point(thisLocation.X, thisLocation.Y + squareSize); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); square3.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square4.location = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y); break; } }
private void CreateFormat(BlockTypes type, int x, int y, int z, FormationType format) { switch (format) { case FormationType.ThreeDCross: //3D Cross SetBlocktype(x, y, z, (byte)type); SetBlocktype(x - 1, y, z, (byte)type); SetBlocktype(x + 1, y, z, (byte)type); SetBlocktype(x, y, z + 1, (byte)type); SetBlocktype(x, y, z - 1, (byte)type); SetBlocktype(x, y - 1, z, (byte)type); SetBlocktype(x, y + 1, z, (byte)type); break; case FormationType.BigL: //Kind of laying big "L" SetBlocktype(x, y, z, (byte)type); SetBlocktype(x + 1, y + 1, z, (byte)type); SetBlocktype(x - 1, y, z, (byte)type); SetBlocktype(x + 1, y, z, (byte)type); break; case FormationType.Cube: //Cube SetBlocktype(x, y + 1, z, (byte)type); SetBlocktype(x, y - 1, z, (byte)type); SetBlocktype(x, y - 1, z - 1, (byte)type); SetBlocktype(x, y + 1, z - 1, (byte)type); break; case FormationType.SmallL: //Kind of staying small "L" SetBlocktype(x, y + 2, z, (byte)type); SetBlocktype(x, y + 1, z, (byte)type); SetBlocktype(x, y, z - 1, (byte)type); break; } }
private bool readTables() { byte[] bitLength = new byte[Compress.BC]; byte[] table = new byte[Compress.HUFF_TABLE_SIZE]; if (inAddr > readTop - 25) { if (!unpReadBuf()) { return (false); } } AddBits((8 - inBit) & 7); long bitField = GetBits() & unchecked((int)0xffFFffFF); if ((bitField & 0x8000) != 0) { unpBlockType = BlockTypes.BLOCK_PPM; return (ppm.decodeInit(this, ppmEscChar)); } unpBlockType = BlockTypes.BLOCK_LZ; prevLowDist = 0; lowDistRepCount = 0; if ((bitField & 0x4000) == 0) { Utility.Fill(unpOldTable, (byte)0); // memset(UnpOldTable,0,sizeof(UnpOldTable)); } AddBits(2); for (int i = 0; i < Compress.BC; i++) { int length = (Utility.URShift(GetBits(), 12)) & 0xFF; AddBits(4); if (length == 15) { int zeroCount = (Utility.URShift(GetBits(), 12)) & 0xFF; AddBits(4); if (zeroCount == 0) { bitLength[i] = 15; } else { zeroCount += 2; while (zeroCount-- > 0 && i < bitLength.Length) { bitLength[i++] = 0; } i--; } } else { bitLength[i] = (byte)length; } } UnpackUtility.makeDecodeTables(bitLength, 0, BD, Compress.BC); int TableSize = Compress.HUFF_TABLE_SIZE; for (int i = 0; i < TableSize; ) { if (inAddr > readTop - 5) { if (!unpReadBuf()) { return (false); } } int Number = this.decodeNumber(BD); if (Number < 16) { table[i] = (byte)((Number + unpOldTable[i]) & 0xf); i++; } else if (Number < 18) { int N; if (Number == 16) { N = (Utility.URShift(GetBits(), 13)) + 3; AddBits(3); } else { N = (Utility.URShift(GetBits(), 9)) + 11; AddBits(7); } while (N-- > 0 && i < TableSize) { table[i] = table[i - 1]; i++; } } else { int N; if (Number == 18) { N = (Utility.URShift(GetBits(), 13)) + 3; AddBits(3); } else { N = (Utility.URShift(GetBits(), 9)) + 11; AddBits(7); } while (N-- > 0 && i < TableSize) { table[i++] = 0; } } } tablesRead = true; if (inAddr > readTop) { return (false); } UnpackUtility.makeDecodeTables(table, 0, LD, Compress.NC); UnpackUtility.makeDecodeTables(table, Compress.NC, DD, Compress.DC); UnpackUtility.makeDecodeTables(table, Compress.NC + Compress.DC, LDD, Compress.LDC); UnpackUtility.makeDecodeTables(table, Compress.NC + Compress.DC + Compress.LDC, RD, Compress.RC); // memcpy(unpOldTable,table,sizeof(unpOldTable)); #if !PORTABLE Buffer.BlockCopy(table, 0, unpOldTable, 0, unpOldTable.Length); #else Array.Copy(table, 0, unpOldTable, 0, unpOldTable.Length); #endif return (true); }
/// <summary> /// Initializes a new instance of the <see cref="RocksBlock" /> class. /// </summary> /// <param name="blockType">Type of the block.</param> public RocksBlock(BlockTypes blockType) { this.BlockType = blockType; this.entity = new Entity() .AddComponent(new Transform2D()); // Cached this.Transform2D = this.entity.FindComponent<Transform2D>(); this.rocks = new List<Rock>(); this.jellyFishs = new List<JellyFish>(); this.stars = new List<StarFish>(); switch (blockType) { case BlockTypes.One: this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Little, new Vector2(176, 154))); this.rocks.Add(new Rock(Rock.RockType.Left, new Vector2(0, 616))); this.rocks.Add(new Rock(Rock.RockType.Right, new Vector2(WaveServices.ViewportManager.VirtualWidth, 163))); this.stars.Add(new StarFish(new Vector2(711, 640))); this.stars.Add(new StarFish(new Vector2(49, 460))); break; case BlockTypes.Two: this.rocks.Add(new Rock(Rock.RockType.Center, new Vector2(231, 233))); this.rocks.Add(new Rock(Rock.RockType.Center, new Vector2(546, 739))); this.stars.Add(new StarFish(new Vector2(178, 664))); this.stars.Add(new StarFish(new Vector2(571, 209))); break; case BlockTypes.Three: this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Big, new Vector2(170, 212))); this.rocks.Add(new Rock(Rock.RockType.Center, new Vector2(570, 512))); this.stars.Add(new StarFish(new Vector2(625, 857))); this.stars.Add(new StarFish(new Vector2(91, 506))); this.stars.Add(new StarFish(new Vector2(380, 198))); break; case BlockTypes.Four: this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Little, new Vector2(170, 807))); this.rocks.Add(new Rock(Rock.RockType.Left, new Vector2(0, 163))); this.rocks.Add(new Rock(Rock.RockType.Right, new Vector2(WaveServices.ViewportManager.VirtualWidth + 60, 616))); this.stars.Add(new StarFish(new Vector2(130, 580))); this.stars.Add(new StarFish(new Vector2(573, 478))); this.stars.Add(new StarFish(new Vector2(110, 68))); break; case BlockTypes.Five: this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Little, new Vector2(165, 769))); this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Little, new Vector2(620, 912), false)); this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Big, new Vector2(194, 208))); this.stars.Add(new StarFish(new Vector2(86, 326))); this.stars.Add(new StarFish(new Vector2(195, 630))); this.stars.Add(new StarFish(new Vector2(648, 423))); break; case BlockTypes.Six: this.rocks.Add(new Rock(Rock.RockType.Right, new Vector2(WaveServices.ViewportManager.VirtualWidth, 171))); this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Little, new Vector2(98, 418))); this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Little, new Vector2(165, 807))); this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Big, new Vector2(553, 835), false)); this.stars.Add(new StarFish(new Vector2(243, 174))); this.stars.Add(new StarFish(new Vector2(203, 616))); break; case BlockTypes.Seven: this.rocks.Add(new Rock(Rock.RockType.Left, new Vector2(-193, 469))); this.rocks.Add(new Rock(Rock.RockType.Right, new Vector2(WaveServices.ViewportManager.VirtualWidth + 119, 74))); this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Big, new Vector2(152, 235))); this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Little, new Vector2(444, 433), false)); this.jellyFishs.Add(new JellyFish(JellyFish.JellyFishType.Little, new Vector2(316, 835))); this.stars.Add(new StarFish(new Vector2(379, 232))); this.stars.Add(new StarFish(new Vector2(379, 616))); break; } foreach (Rock rock in this.rocks) { this.entity.AddChild(rock.Entity); } foreach (JellyFish jellyFish in this.jellyFishs) { this.entity.AddChild(jellyFish.Entity); } foreach (StarFish star in this.stars) { this.entity.AddChild(star.Entity); } }
public Block(Point thisLocation, BlockTypes bType) { //当blockType为undefined时,随机产生方块形状 Random rand = new Random(); if (bType == BlockTypes.undefined) { blockType = (BlockTypes)(rand.Next(7) + 1); } else { blockType = bType; } //设置四小方块的颜色 int i = (int)blockType - 1; foreColor = GameField.BlockForeColor[i]; backColor = GameField.BlockBackColor[i]; Size squareS = new Size(squareSize, squareSize); square1 = new Square(squareS, foreColor, backColor); square2 = new Square(squareS, foreColor, backColor); square3 = new Square(squareS, foreColor, backColor); square4 = new Square(squareS, foreColor, backColor); //设置小方块的位置,组合成指定形状的一个大方块 switch (blockType) { case BlockTypes.square: //组合成正方形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square3.location = new Point(thisLocation.X, thisLocation.Y + squareSize); square4.location = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); break; case BlockTypes.line: //组合成线形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square3.location = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y); square4.location = new Point(thisLocation.X + 3 * squareSize, thisLocation.Y); break; case BlockTypes.J: //组合成J形 square1.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); square3.location = new Point(thisLocation.X + squareSize, thisLocation.Y + 2 * squareSize); square4.location = new Point(thisLocation.X, thisLocation.Y + 2 * squareSize); break; case BlockTypes.L: //组合成l形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X, thisLocation.Y + squareSize); square3.location = new Point(thisLocation.X, thisLocation.Y + 2 * squareSize); square4.location = new Point(thisLocation.X + squareSize, thisLocation.Y + 2 * squareSize); break; case BlockTypes.T: //组合成T形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square3.location = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y); square4.location = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); break; case BlockTypes.Z: //组合成z形 square1.location = new Point(thisLocation.X, thisLocation.Y); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square3.location = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); square4.location = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y + squareSize); break; case BlockTypes.S: //组合成S形 square1.location = new Point(thisLocation.X, thisLocation.Y + squareSize); square2.location = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); square3.location = new Point(thisLocation.X + squareSize, thisLocation.Y); square4.location = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y); break; } }
//含有自定义颜色的重载 public Block(Point thisLocation, BlockTypes bType, Color fc, Color bc) { //当blockType为undefined时,随机产生方块形状 Random rand = new Random(); if (bType == BlockTypes.undefined) { blockType = (BlockTypes)(rand.Next(7) + 1); } else { blockType = bType; } //设置四小方块的颜色 Size squareS = new Size(squareSize, squareSize); sq1 = new Square(squareS, fc, bc); sq2 = new Square(squareS, fc, bc); sq3 = new Square(squareS, fc, bc); sq4 = new Square(squareS, fc, bc); //设置小方块的位置,组合成指定形状的一个大方块 switch (blockType) { case BlockTypes.O: //组合成正方形 sq1.loct = new Point(thisLocation.X, thisLocation.Y); sq2.loct = new Point(thisLocation.X + squareSize, thisLocation.Y); sq3.loct = new Point(thisLocation.X, thisLocation.Y + squareSize); sq4.loct = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); break; case BlockTypes.I: //组合成线形 sq1.loct = new Point(thisLocation.X, thisLocation.Y); sq2.loct = new Point(thisLocation.X + squareSize, thisLocation.Y); sq3.loct = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y); sq4.loct = new Point(thisLocation.X + 3 * squareSize, thisLocation.Y); break; case BlockTypes.J: //组合成J形 sq1.loct = new Point(thisLocation.X + squareSize, thisLocation.Y); sq2.loct = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); sq3.loct = new Point(thisLocation.X + squareSize, thisLocation.Y + 2 * squareSize); sq4.loct = new Point(thisLocation.X, thisLocation.Y + 2 * squareSize); break; case BlockTypes.L: //组合成l形 sq1.loct = new Point(thisLocation.X, thisLocation.Y); sq2.loct = new Point(thisLocation.X, thisLocation.Y + squareSize); sq3.loct = new Point(thisLocation.X, thisLocation.Y + 2 * squareSize); sq4.loct = new Point(thisLocation.X + squareSize, thisLocation.Y + 2 * squareSize); break; case BlockTypes.T: //组合成T形 sq1.loct = new Point(thisLocation.X, thisLocation.Y); sq2.loct = new Point(thisLocation.X + squareSize, thisLocation.Y); sq3.loct = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y); sq4.loct = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); break; case BlockTypes.Z: //组合成z形 sq1.loct = new Point(thisLocation.X, thisLocation.Y); sq2.loct = new Point(thisLocation.X + squareSize, thisLocation.Y); sq3.loct = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); sq4.loct = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y + squareSize); break; case BlockTypes.S: //组合成S形 sq1.loct = new Point(thisLocation.X, thisLocation.Y + squareSize); sq2.loct = new Point(thisLocation.X + squareSize, thisLocation.Y + squareSize); sq3.loct = new Point(thisLocation.X + squareSize, thisLocation.Y); sq4.loct = new Point(thisLocation.X + 2 * squareSize, thisLocation.Y); break; } }
//Song currentsong; public MusicBlock(Vector2 top, Vector2 forward, Vector2 backward, Vector2 right, Vector2 left, Vector2 bottom, BlockModel modelIn, bool solidIn, bool transparentIn, bool aimSolidIn, BlockTypes typeIn,ContentManager content) : base(top,forward,backward,right,left,bottom,modelIn,solidIn,transparentIn,aimSolidIn,typeIn) { //currentsong = content.Load<Song>("testsong"); }
public void AddBlock(BlockTypes type, string content) { _elements.Add(new Block() { Content = content, Id = _elements.Max(x => x.Id) + 1, Type = type }); }
public void ChangeTypeBlock(ulong id, BlockTypes type) { _elements.First(e => e.Id == id).Type = type; }
public IAuthorizer this[BlockTypes blockType] => _authorizerInstances[blockType];
public Block(Point location, BlockTypes newBlockType) { // Create the new block if (newBlockType==BlockTypes.Undefined) { //BlockType = (BlockTypes)(random.Next(7)) + 1; BlockType = BlockTypes.Line; //force line block for testing } else { BlockType = newBlockType; } // Create each of the squares of the block // Set the square colors, based on the block type square1 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); square2 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); square3 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); square4 = new Square(new Size(squareSize, squareSize), backColors[(int)BlockType], foreColors[(int)BlockType]); // Set the squares positions based on the block type switch(BlockType) { case BlockTypes.Square: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X+squareSize, location.Y); square3.Location = new Point(location.X, location.Y+squareSize); square4.Location = new Point(location.X+squareSize, location.Y+squareSize); break; case BlockTypes.Line: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X, location.Y+squareSize); square3.Location = new Point(location.X, location.Y+2*squareSize); square4.Location = new Point(location.X, location.Y+3*squareSize); break; case BlockTypes.J: square1.Location = new Point(location.X+squareSize, location.Y); square2.Location = new Point(location.X+squareSize, location.Y+squareSize); square3.Location = new Point(location.X+squareSize, location.Y+2*squareSize); square4.Location = new Point(location.X, location.Y+2*squareSize); break; case BlockTypes.L: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X, location.Y+squareSize); square3.Location = new Point(location.X, location.Y+2*squareSize); square4.Location = new Point(location.X+squareSize, location.Y+2*squareSize); break; case BlockTypes.T: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X+squareSize, location.Y); square3.Location = new Point(location.X+2*squareSize, location.Y); square4.Location = new Point(location.X+squareSize, location.Y+squareSize); break; case BlockTypes.Z: square1.Location = new Point(location.X, location.Y); square2.Location = new Point(location.X+squareSize, location.Y); square3.Location = new Point(location.X+squareSize, location.Y+squareSize); square4.Location = new Point(location.X+2*squareSize, location.Y+squareSize); break; case BlockTypes.S: square1.Location = new Point(location.X, location.Y+squareSize); square2.Location = new Point(location.X+squareSize, location.Y+squareSize); square3.Location = new Point(location.X+squareSize, location.Y); square4.Location = new Point(location.X+2*squareSize, location.Y); break; } }
public static Type GetBlockType(BlockTypes type) { return _blocks[type]; }