void AddBlock(string blockType, Vector3 pos, Vector3 rot, int pSys, int optSlot, int optBonus) { Quaternion q = new Quaternion(); q.eulerAngles = rot; GameObject go = (GameObject)Instantiate(blockAps[blockType], pos + poff, q); BBlock bb = new BBlock(); bb.blockType = blockType; bb.position = pos; bb.rotation = rot; bb.pSys = pSys; bb.optSlot = optSlot; bb.optBonus = optBonus; bb.repreObj = go; blocks.Add(bb); go.GetComponent <PreviewBlock>().myShip = this; }
public BLevel(int width, int height) { grid = new BBlock[width, height]; entities = new List <BEntity>(); mapname = "none"; playerStartPos = new Point((int)(width / AppInfo.TILESIZE), (int)(height / AppInfo.TILESIZE)); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (x == 0 || y == 0 || x == width - 1 || y == height - 1) { BBlockTemplate block = BBlocks.GetBlock(1); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); } else { BBlockTemplate block = BBlocks.GetBlock(2); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); } } } }
public BLevel(string mapname) { try { if (!Directory.Exists("Content/Maps")) { Directory.CreateDirectory("Content/Maps"); } if (!File.Exists($"Content/Maps/{mapname}.ls")) { throw new FileNotFoundException($"No map found with name '{mapname}'."); } var Map = BLevelFile.FromJson(File.ReadAllText($"Content/Maps/{mapname}.ls")); int width = Map.Width; int height = Map.Height; grid = new BBlock[width, height]; entities = new List <BEntity>(); this.mapname = mapname; playerStartPos = new Point(1, 1); int[] Tiles = Map.Layers[0].Data; int x = 0; int y = 0; for (int i = 0; i < Tiles.Length; i++) { BBlockTemplate block = BBlocks.GetBlock(Tiles[i]); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); x++; if (x >= width) { x = 0; y++; } } playerStartPos = new Point(width / 2, height / 2); } catch (Exception e) { Console.WriteLine(e.Message); int width = 20; int height = 20; grid = new BBlock[width, height]; entities = new List <BEntity>(); this.mapname = "none"; playerStartPos = new Point(1, 1); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (x == 0 || y == 0 || x == width - 1 || y == height - 1) { BBlockTemplate block = BBlocks.GetBlock(1); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); } else { BBlockTemplate block = BBlocks.GetBlock(2); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); } } } } }
private BTempletes CreateTemplete() { BTempletes bt = new BTempletes(); bt.Name = "Test"; BBlock bb = new BBlock() { Name = "T1", Description = "A test for bb", Repeat = 1, }; bb.AddVariable(new BVariable() { Name = "ID", Length = 1, Unit = LengthUnit.Byte, ValueType = BitexValueType.Number, }); bb.AddVariable(new BVariable() { Name = "Value", Length = 4, Unit = LengthUnit.Byte, ValueType = BitexValueType.Number, }); bb.AddBlock(new BBlock() { Name = "OneBits", Description = "8 one-bit variables", Repeat = 8, }); bb.Blocks["OneBits"].AddVariable(new BVariable() { Name = "OneBitss", Length = 1, Unit = LengthUnit.Bit, ValueType = BitexValueType.Number, }); bb.AddBlock(new BBlock() { Name = "TwoBits", Description = "4 two-bits variables", Repeat = 4, }); bb.Blocks["TwoBits"].AddVariable(new BVariable() { Name = "TwoBitss", Length = 2, Unit = LengthUnit.Bit, ValueType = BitexValueType.Number, }); bb.AddVariable(new BVariable() { Name = "Hello", Length = 5, Unit = LengthUnit.Byte, ValueType = BitexValueType.String }); bt.Add(bb); return(bt); }