// PUBLIC METHODS public BlockInfo GetBlockInfo(EBlockType blockType) { if (m_CachedBlockInfos.TryGetValue(blockType, out var blockInfo) == true) { return(blockInfo); } var settings = System.Array.Find(m_BlockSettings, obj => obj.BlockType == blockType); if (settings == null) { throw new System.ArgumentOutOfRangeException("No settings for block type " + blockType); } var newBlockInfo = new BlockInfo ( GetUVs(settings.TileTop), GetUVs(settings.TileSide), GetUVs(settings.TileBottom), settings.Health ); m_CachedBlockInfos[blockType] = newBlockInfo; return(newBlockInfo); }
public void ReloadList(EBlockType type) { PatternPartsList.Items.Clear(); switch (type) { case EBlockType.IfStatement: foreach (var part in PatternMaker.IfStatements) { PatternPartsList.Items.Add(part.Comment); } break; case EBlockType.Behaviour: foreach (var part in PatternMaker.Behaviours) { PatternPartsList.Items.Add(part.Comment); } break; default: break; } Type = type; }
public void BuildingBlock(EBlockType blockType) { switch (blockType) { case EBlockType.Light: { mTexture = "block2"; mHealth = 100; break; } case EBlockType.Normal: { mTexture = "block"; mHealth = 200; break; } case EBlockType.Hard: { mTexture = "block3"; mHealth = 300; break; } default: break; } }
public static GameObject Create(EBlockType type, Vector3 location, Vector3 eurlerAngles) { Transform resultantGO; switch (type) { case EBlockType.Rectangle: resultantGO = Instantiate(GameAssets.i.RBlock, location, Quaternion.Euler(eurlerAngles)); break; case EBlockType.LShape: resultantGO = Instantiate(GameAssets.i.LBlock, location, Quaternion.Euler(eurlerAngles)); break; case EBlockType.Cube: resultantGO = Instantiate(GameAssets.i.Block, location, Quaternion.Euler(eurlerAngles)); break; case EBlockType.Start: resultantGO = Instantiate(GameAssets.i.Start, location - new Vector3(0, 0.9f, 0), Quaternion.Euler(eurlerAngles)); break; case EBlockType.Goal: resultantGO = Instantiate(GameAssets.i.Goal, location - new Vector3(0, 0.9f, 0), Quaternion.Euler(eurlerAngles)); break; default: throw new System.Exception("No EBlockType assigned"); } return(resultantGO.gameObject); }
virtual protected void UpdateData() { if (blockType != BlockType) { blockType = BlockType; switch (blockType) { case EBlockType.EBT_Empty: stateMgr.SetStateType(State.EStateType.EST_Disappear); break; case EBlockType.EBT_Snow: stateMgr.RegistState(new AccumulateState()); stateMgr.RegistState(new MeltState()); break; default: { this.gameObject.GetComponent <Renderer>().sharedMaterial.mainTexture = TextureArray[(int)blockType]; stateMgr.SetStateType(State.EStateType.EST_Normal); } break; } } }
public static Sprite GetSpriteAssetsByType(EBlockType type) { Sprite sprite = null; if (!randomSprites.ContainsKey(type)) { switch (type) { case EBlockType.Apple: sprite = Resources.Load <Sprite>("Texture/Eliminate/1"); break; case EBlockType.Banana: sprite = Resources.Load <Sprite>("Texture/Eliminate/2"); break; case EBlockType.Grape: sprite = Resources.Load <Sprite>("Texture/Eliminate/3"); break; case EBlockType.Lemon: sprite = Resources.Load <Sprite>("Texture/Eliminate/4"); break; case EBlockType.Pear: sprite = Resources.Load <Sprite>("Texture/Eliminate/5"); break; } randomSprites[type] = sprite; } return(randomSprites[type]); }
public BlockData(EBlockType _eBlockType, int _iBlockValue) { this.m_eBlockType = _eBlockType; this.m_iBlockValue = _iBlockValue; int iNumber = System.Enum.GetNames(typeof(GamingLogic2048.EPushingDirection)).Length;//取得邏輯層所擁有的 "推動方向" 數量 m_arrNeighbor = new BlockData[iNumber]; }
public CircleObstacleAngleData(TSVector2 center, FP r) { _center = center; _radius = r; quadrant = 4; cos = 1; sin = 0; _blockType = EBlockType.none; }
public Block(EBlockType _b, Vector3 _pos, GameObject _p, Chunk _owner, Material _atlas) { m_BlockType = _b; m_parent = _p; m_position = _pos; m_owner = _owner; m_Atlas = _atlas; m_HasMesh = true; }
private void ShowSelection(PictureBox aPicBox) { this.ClearSelection(); aPicBox.BackColor = Color.Red; aPicBox.Padding = new System.Windows.Forms.Padding(1); EBlockType aBlockType = levelManager.BlockType(ci, cj); //aPicBox.Image = GetImage(aBlockType); }
public void SetBlockType(EBlockType blockType) { if (m_BlockType == blockType) { return; } m_BlockType = blockType; UpdateUVs(); }
// PUBLIC METHODS public void AddBlock(Vector3Int position, EBlockType blockType) { var(chunk, positionInChunkX, positionInChunkY, positionInChunkZ) = GetTargetChunk(position); if (chunk == null) { return; } chunk.SetBlock(positionInChunkX, positionInChunkY, positionInChunkZ, blockType); }
public Block(int id, string comment, EBlockType type) { ID = id; Comment = comment; Type = type; Width = 200.0; Height = 125.0; switch (Type) { case EBlockType.IfStatement: Background = Brushes.LightBlue; break; case EBlockType.Behaviour: Background = Brushes.LightYellow; break; default: break; } Child = mGrid; mGrid.Children.Add(mTextBlock); mGrid.Children.Add(mTextBox); mGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); mGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); Grid.SetRow(mTextBlock, 0); Grid.SetColumn(mTextBlock, 0); Grid.SetRowSpan(mTextBlock, 1); Grid.SetColumnSpan(mTextBlock, 1); Grid.SetRow(mTextBox, 1); Grid.SetColumn(mTextBox, 0); Grid.SetRowSpan(mTextBox, 1); Grid.SetColumnSpan(mTextBox, 1); mTextBlock.Text = comment; mTextBlock.TextAlignment = TextAlignment.Center; mTextBlock.VerticalAlignment = VerticalAlignment.Center; mTextBox.Width = 100.0; mTextBox.Height = 25.0; mTextBox.HorizontalAlignment = HorizontalAlignment.Center; mTextBox.VerticalAlignment = VerticalAlignment.Center; mTextBox.HorizontalContentAlignment = HorizontalAlignment.Center; mTextBox.VerticalContentAlignment = VerticalAlignment.Center; }
public static byte ComputeBlockChecksum( byte iConst, EBlockType BlkType, byte hdrSize, byte[] buffer ) { byte crc = (byte)((iConst+((byte)BlkType)+hdrSize)); byte[] bfMyBuff = buffer; int iCounter = 0; do { crc = (byte)(crc + bfMyBuff[iCounter++]); } while ( iCounter < bfMyBuff.Length ); return ( byte ) ( 0xff - crc ); }
public PropPoint(EBlockType _type, Vector3 _pos, GameObject _parent, Chunk _owner, Material _atlas) { m_BlockType = EBlockType.PROP; m_parent = _parent; m_position = _pos; m_owner = _owner; m_Atlas = _atlas; m_HasMesh = false; m_IsSolid = false; m_RootBlock = _type; m_BlockUVs = myUVs; }
/// <summary> /// Reads the type of the next desciptor block. Does not advance stream position. /// </summary> public EBlockType PeekNextBlockType() { // Check for EOF if (BaseStream.Position + 4 >= BaseStream.Length) { return(0); } EBlockType et = (EBlockType)ReadUInt32(); BaseStream.Seek(-4, System.IO.SeekOrigin.Current); return(et); }
private void UpdateTile(int i, int j) { PictureBox aPicBox = sTiles[i, j]; aPicBox.Left = i * imageWidth + 10; aPicBox.Top = j * imageHeight + 30; aPicBox.Width = imageWidth; aPicBox.Height = imageHeight; aPicBox.SizeMode = PictureBoxSizeMode.StretchImage; EBlockType aBlockType = levelManager.BlockType(i, j); aPicBox.Image = GetImage(aBlockType); }
public void SetBlock(int x, int y, int z, EBlockType blockType) { if (CheckBounds(x, y, z) == false) { return; } m_BlockData[x, y, z].BlockType = blockType; m_BlockData[x, y, z].Health = m_BlockSettings.GetBlockInfo(blockType).Health; UpdateMesh(); Changed = true; }
private void DeleteType(EBlockType type, Action <int, int> callback = null) { for (int i = 0; i < _size; i++) { for (int j = 0; j < _size; j++) { if (_blockTypes[i, j] == type) { _blockTypes[i, j] = EBlockType.None; } callback?.Invoke(i, j); } } }
void aBlockType_Click(object sender, EventArgs e) { if (ci == -1) { return; } if (cj == -1) { return; } PictureBox aPicBox = (PictureBox)sender; EBlockType aBlockType = (EBlockType)aPicBox.Tag; Select(aBlockType); }
/// <summary> /// Reads a descriptor block from the stream. /// </summary> public CDescriptorBlock ReadDBLK() { // Read block type EBlockType bt = PeekNextBlockType(); switch (bt) { case EBlockType.MTF_TAPE: // TAPE descriptor block return(new CTapeHeaderDescriptorBlock(this)); case EBlockType.MTF_SSET: // Start of data SET descriptor block return(new CStartOfDataSetDescriptorBlock(this)); case EBlockType.MTF_VOLB: // VOLume descriptor Block return(new CVolumeDescriptorBlock(this)); case EBlockType.MTF_DIRB: // DIRectory descriptor Block return(new CDirectoryDescriptorBlock(this)); case EBlockType.MTF_FILE: // FILE descriptor block return(new CFileDescriptorBlock(this)); case EBlockType.MTF_CFIL: // Corrupt object descriptor block return(new CCorruptObjectDescriptorBlock(this)); case EBlockType.MTF_ESPB: // End of Set Pad descriptor Block return(new CEndOfPadSetDescriptorBlock(this)); case EBlockType.MTF_ESET: // End of SET descriptor block return(new CEndOfDataSetDescriptorBlock(this)); case EBlockType.MTF_EOTM: // End Of Tape Marker descriptor block return(new CEndOfTapeMarkerDescriptorBlock(this)); case EBlockType.MTF_SFMB: // Soft FileMark descriptor Block return(new CSoftFilemarkDescriptorBlock(this)); } return(null); }
private void OnMouseDown(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Middle: _dragPoint = e.Location; _dragEnabled = true; break; case MouseButtons.Left: _paintEnabled = true; _paintType = EBlockType.Wall; break; case MouseButtons.Right: _paintEnabled = true; _paintType = EBlockType.None; break; } Invalidate(); }
private void Awake() { if (_levelData != null) { string[] stringSeparators = new string[] { "\r\n" }; string[] lines = _levelData.text.Split(stringSeparators, System.StringSplitOptions.None); foreach (var line in lines) { if (line.Contains(":")) { var split = line.Split(new string[] { ":" }, StringSplitOptions.None); EBlockType blockType = (EBlockType)Enum.Parse(typeof(EBlockType), split[1]); var splitPos = split[2].Split(new string[] { "," }, StringSplitOptions.None); Vector3 location = new Vector3(float.Parse(splitPos[0]), float.Parse(splitPos[1]), float.Parse(splitPos[2])); var splitRot = split[3].Split(new string[] { "," }, StringSplitOptions.None); Vector3 rot = new Vector3(float.Parse(splitRot[0]), float.Parse(splitRot[1]), float.Parse(splitRot[2])); if (blockType == EBlockType.Start || blockType == EBlockType.Goal) { Block.Create(blockType, new Vector3(location.x, 1, location.z), rot); } else { var t = Block.Create(blockType, new Vector3(location.x, 0.5f, location.z), rot); t.GetComponent <Rigidbody>().useGravity = true; t.GetComponent <Block>()._canMove = bool.Parse(split[4]); } } } var start = GameObject.FindGameObjectWithTag("Spawn"); GetComponent <Timer>().playerObject = Instantiate(GameAssets.i.Player.gameObject, start.transform.position, Quaternion.identity); } }
/// <summary> /// Read block header. /// </summary> protected void ReadData(CBackupStream Reader) { StartPosition = Reader.BaseStream.Position; Streams = new System.Collections.Generic.List <CDataStream>(); BlockType = (EBlockType)Reader.ReadUInt32(); Attributes = (EBlockAttributes)Reader.ReadUInt32(); OffsetToFirstEvent = Reader.ReadUInt16(); OSID = (EOSID)Reader.ReadByte(); OSVersion = Reader.ReadByte(); DisplayableSize = Reader.ReadUInt64(); FormatLogicalAddress = Reader.ReadUInt64(); ReservedMBC = Reader.ReadUInt16(); Reserved1 = Reader.ReadUInt16(); Reserved2 = Reader.ReadUInt16(); Reserved3 = Reader.ReadUInt16(); ControlBlock = Reader.ReadUInt32(); Reserved4 = Reader.ReadUInt32(); OsSpecificData = Reader.ReadOsSpecificData(StartPosition, OSID, OSVersion, BlockType); StringType = (EStringType)Reader.ReadByte(); Reserved5 = Reader.ReadByte(); HeaderChecksum = Reader.ReadUInt16(); }
/// <summary> /// Read block header. /// </summary> protected void ReadData(CBackupStream Reader) { StartPosition = Reader.BaseStream.Position; Streams = new System.Collections.Generic.List<CDataStream>(); BlockType = (EBlockType)Reader.ReadUInt32(); Attributes = (EBlockAttributes)Reader.ReadUInt32(); OffsetToFirstEvent = Reader.ReadUInt16(); OSID = (EOSID)Reader.ReadByte(); OSVersion = Reader.ReadByte(); DisplayableSize = Reader.ReadUInt64(); FormatLogicalAddress = Reader.ReadUInt64(); ReservedMBC = Reader.ReadUInt16(); Reserved1 = Reader.ReadUInt16(); Reserved2 = Reader.ReadUInt16(); Reserved3 = Reader.ReadUInt16(); ControlBlock = Reader.ReadUInt32(); Reserved4 = Reader.ReadUInt32(); OsSpecificData = Reader.ReadOsSpecificData(StartPosition, OSID, OSVersion, BlockType); StringType = (EStringType)Reader.ReadByte(); Reserved5 = Reader.ReadByte(); HeaderChecksum = Reader.ReadUInt16(); }
private Bitmap GetImage(EBlockType aBlockType) { switch (aBlockType) { case EBlockType.BLOCKTYPE_HARDWALL: return(Resource1.HardWall); case EBlockType.BLOCKTYPE_SOFTWALL: return(Resource1.SoftWall); case EBlockType.BLOCKTYPE_RANDOM: return(Resource1.Random); case EBlockType.BLOCKTYPE_FREE: return(Resource1.Free); case EBlockType.BLOCKTYPE_WHITEBOMBER: return(Resource1.WhiteBomber); case EBlockType.BLOCKTYPE_BLACKBOMBER: return(Resource1.BlackBomber); case EBlockType.BLOCKTYPE_REDBOMBER: return(Resource1.RedBomber); case EBlockType.BLOCKTYPE_BLUEBOMBER: return(Resource1.BlueBomber); case EBlockType.BLOCKTYPE_GREENBOMBER: return(Resource1.GreenBomber); case EBlockType.BLOCKTYPE_MOVEBOMB_RIGHT: return(Resource1.MoveRight); case EBlockType.BLOCKTYPE_MOVEBOMB_DOWN: return(Resource1.MoveDown); case EBlockType.BLOCKTYPE_MOVEBOMB_LEFT: return(Resource1.MoveLeft); case EBlockType.BLOCKTYPE_MOVEBOMB_UP: return(Resource1.MoveUp); case EBlockType.BLOCKTYPE_ITEM_BOMB: return(Resource1.ItemBomb); case EBlockType.BLOCKTYPE_ITEM_FLAME: return(Resource1.ItemFlame); case EBlockType.BLOCKTYPE_ITEM_ROLLER: return(Resource1.ItemRoller); case EBlockType.BLOCKTYPE_ITEM_KICK: return(Resource1.ItemKick); case EBlockType.BLOCKTYPE_ITEM_THROW: return(Resource1.ItemThrow); case EBlockType.BLOCKTYPE_ITEM_PUNCH: return(Resource1.ItemPunch); case EBlockType.BLOCKTYPE_ITEM_SKULL: return(Resource1.ItemSkull); case EBlockType.BLOCKTYPE_ITEM_REMOTE: return(Resource1.ItemRemote); case EBlockType.BLOCKTYPE_ITEM_SHIELD: return(Resource1.ItemShield); case EBlockType.BLOCKTYPE_ITEM_STRONGWEAK: return(Resource1.ItemStrongWeak); default: break; } return(Resource1.Free); }
public static TBlockHeader GenBlkHeader(BinaryReader br, EContentType type1, EBlockType type4) { EContentType type; EBlockType type2; EBlockType type3; type = type1; if ((type == EContentType.Code) || (type == EContentType.Data)) { type2 = type4; switch (type2) { case EBlockType.BlockType2E: return new TBlockType2E(); case (EBlockType)0x2f: throw new NotImplementedException(); case EBlockType.BlockType30: return new TBlockType30(); } return new TBlockType17(); } type3 = type4; switch (type3) { case EBlockType.BlockType28_CORE_Cert: return new TBlockType28_CORE_Cert(); } return new TBlockType27_ROFS_Hash(); }
public void NewRead(BinaryReader br) { contentType = (EContentType)br.ReadByte(); const01 = br.ReadByte(); if (const01 != 1) { throw new Exception("Hibás konstans érték!"); } blockType = (EBlockType)br.ReadByte(); blockHeaderSize = br.ReadByte(); byte[] buffer = br.ReadBytes(blockHeaderSize); br.BaseStream.Seek((long)-blockHeaderSize, SeekOrigin.Current); blockChecksum8 = Utils.ComputeBlockChecksum(const01, blockType, blockHeaderSize, buffer); long num = br.ReadInt64(); blockHeader = TBlockHeader.GenBlkHeader(br,contentType,blockType); blockHeader.Read(br); blockChecksum8 = br.ReadByte(); content = br.ReadBytes((int)blockHeader.contentSize); //blockHeader.contentLength }
public override void Read(BinaryReader br) { blockType = (EBlockType)br.ReadByte(); const01 = br.ReadByte(); Debug.Assert(const01 == 01, "Const != 01"); contentType = (EContentType)br.ReadByte(); blockSize = br.ReadByte(); // Useful to check for errors long currPos = br.BaseStream.Position; blockHeader = TBlockHeader.GenBlkHeader(br,contentType,blockType); blockHeader.Read(br); if (br.BaseStream.Position != currPos + blockSize) { long missing = (currPos + blockSize - br.BaseStream.Position); Debug.Assert(false, "Error Reading Header! ", missing + " bytes left."); // Fixes the offset and continue... br.BaseStream.Seek(missing, SeekOrigin.Current); } blockChecksum8 = br.ReadByte(); content = br.ReadBytes((int)blockHeader.contentSize); ROFSTracer.WriteTextBlock( this ); }
/// <summary> /// Reads OS specific data. It is assumed that a MTF_MEDIA_ADDRESS structure is next in the stream. /// </summary> public COSSpecificData ReadOsSpecificData(long StartPosition, EOSID OSID, byte OSVersion, EBlockType Type) { long oldpos = BaseStream.Position; ushort sz = ReadUInt16(); ushort off = ReadUInt16(); BaseStream.Seek(StartPosition + off, System.IO.SeekOrigin.Begin); if ((OSID == EOSID.NetWare) && (OSVersion == 0)) { if (Type == EBlockType.MTF_DIRB) { return(new CNetwareDirB(this)); } if (Type == EBlockType.MTF_FILE) { return(new CNetwareFile(this)); } } if ((OSID == EOSID.NetWare_SMS) && (OSVersion == 1)) { if (Type == EBlockType.MTF_DIRB) { return(new CNetwareSMSDirB(this)); } if (Type == EBlockType.MTF_FILE) { return(new CNetwareSMSFile(this)); } } if ((OSID == EOSID.NetWare_SMS) && (OSVersion == 2)) { if (Type == EBlockType.MTF_DIRB) { return(new CNetwareSMEDirB(this)); } if (Type == EBlockType.MTF_FILE) { return(new CNetwareSMEFile(this)); } } if ((OSID == EOSID.Windows_NT) && (OSVersion == 0)) { if (Type == EBlockType.MTF_DIRB) { return(new CWindowsNT0DirB(this)); } if (Type == EBlockType.MTF_FILE) { return(new CWindowsNT0File(this)); } } if ((OSID == EOSID.Windows_NT) && (OSVersion == 1)) { if (Type == EBlockType.MTF_VOLB) { return(new CWindowsNT1VolB(this)); } if (Type == EBlockType.MTF_DIRB) { return(new CWindowsNT1DirB(this)); } if (Type == EBlockType.MTF_FILE) { return(new CWindowsNT1File(this)); } } if ((OSID == EOSID.OS_2) && (OSVersion == 0)) { if (Type == EBlockType.MTF_DIRB) { return(new COS2DirB(this)); } if (Type == EBlockType.MTF_FILE) { return(new COS2File(this)); } } if ((OSID == EOSID.Windows_95) && (OSVersion == 0)) { if (Type == EBlockType.MTF_DIRB) { return(new CWindows95DirB(this)); } if (Type == EBlockType.MTF_FILE) { return(new CWindows95File(this)); } } if ((OSID == EOSID.Macintosh) && (OSVersion == 0)) { if (Type == EBlockType.MTF_VOLB) { return(new CMacintoshVolB(this)); } if (Type == EBlockType.MTF_DIRB) { return(new CMacintoshDirB(this)); } if (Type == EBlockType.MTF_FILE) { return(new CMacintoshFile(this)); } } BaseStream.Seek(oldpos + 4, System.IO.SeekOrigin.Begin); return(new COSSpecificData()); }
/// <summary> /// Reads OS specific data. It is assumed that a MTF_MEDIA_ADDRESS structure is next in the stream. /// </summary> public COSSpecificData ReadOsSpecificData(long StartPosition, EOSID OSID, byte OSVersion, EBlockType Type) { long oldpos = BaseStream.Position; ushort sz = ReadUInt16(); ushort off = ReadUInt16(); BaseStream.Seek(StartPosition + off, System.IO.SeekOrigin.Begin); if ((OSID == EOSID.NetWare) && (OSVersion == 0)) { if (Type == EBlockType.MTF_DIRB) return new CNetwareDirB(this); if (Type == EBlockType.MTF_FILE) return new CNetwareFile(this); } if ((OSID == EOSID.NetWare_SMS) && (OSVersion == 1)) { if (Type == EBlockType.MTF_DIRB) return new CNetwareSMSDirB(this); if (Type == EBlockType.MTF_FILE) return new CNetwareSMSFile(this); } if ((OSID == EOSID.NetWare_SMS) && (OSVersion == 2)) { if (Type == EBlockType.MTF_DIRB) return new CNetwareSMEDirB(this); if (Type == EBlockType.MTF_FILE) return new CNetwareSMEFile(this); } if ((OSID == EOSID.Windows_NT) && (OSVersion == 0)) { if (Type == EBlockType.MTF_DIRB) return new CWindowsNT0DirB(this); if (Type == EBlockType.MTF_FILE) return new CWindowsNT0File(this); } if ((OSID == EOSID.Windows_NT) && (OSVersion == 1)) { if (Type == EBlockType.MTF_VOLB) return new CWindowsNT1VolB(this); if (Type == EBlockType.MTF_DIRB) return new CWindowsNT1DirB(this); if (Type == EBlockType.MTF_FILE) return new CWindowsNT1File(this); } if ((OSID == EOSID.OS_2) && (OSVersion == 0)) { if (Type == EBlockType.MTF_DIRB) return new COS2DirB(this); if (Type == EBlockType.MTF_FILE) return new COS2File(this); } if ((OSID == EOSID.Windows_95) && (OSVersion == 0)) { if (Type == EBlockType.MTF_DIRB) return new CWindows95DirB(this); if (Type == EBlockType.MTF_FILE) return new CWindows95File(this); } if ((OSID == EOSID.Macintosh) && (OSVersion == 0)) { if (Type == EBlockType.MTF_VOLB) return new CMacintoshVolB(this); if (Type == EBlockType.MTF_DIRB) return new CMacintoshDirB(this); if (Type == EBlockType.MTF_FILE) return new CMacintoshFile(this); } BaseStream.Seek(oldpos + 4, System.IO.SeekOrigin.Begin); return new COSSpecificData(); }
public BlockData(EBlockType _eBlockType) : this(_eBlockType, 0) //假如只給格子種類的話就預設數值為0 { }
public static int EBlockTypeToInt(EBlockType type) { return((int)type); }
/// <summary> /// Reads the entire backup file and returns a root catalog node. /// The root node contains backup sets/volumes/directories/files /// as child nodes. /// </summary> public CCatalogNode ReadCatalog() { // Set to true to cancel reading mCancel = false; // Read the media header CTapeHeaderDescriptorBlock tape = (CTapeHeaderDescriptorBlock)mStream.ReadDBLK(); // Read soft file mark CSoftFilemarkDescriptorBlock file = (CSoftFilemarkDescriptorBlock)mStream.ReadDBLK(); // Create the root catalog node CCatalogNode node = new CCatalogNode(tape.MediaName, ENodeType.Root, 0); CCatalogNode nLastSet = null; CCatalogNode nLastVolume = null; CCatalogNode nLastDir = null; // Get next block type EBlockType bt = mStream.PeekNextBlockType(); while ((bt != EBlockType.MTF_EOTM) && (bt != 0) && (mCancel == false)) { // Read next block CDescriptorBlock block = mStream.ReadDBLK(); // Add to catalog if (bt == EBlockType.MTF_SSET) { CStartOfDataSetDescriptorBlock sset = (CStartOfDataSetDescriptorBlock)block; CCatalogNode cnode = node.AddSet("Set: " + sset.DataSetNumber + " - " + sset.DataSetName, block.StartPosition); nLastSet = cnode; } else if (bt == EBlockType.MTF_VOLB) { CVolumeDescriptorBlock vol = (CVolumeDescriptorBlock)block; CCatalogNode cnode = nLastSet.AddVolume(vol.DeviceName, block.StartPosition); nLastVolume = cnode; } else if (bt == EBlockType.MTF_DIRB) { CDirectoryDescriptorBlock dir = (CDirectoryDescriptorBlock)block; // Check if the directory name is contained in a data stream CCatalogNode cnode = null; if ((dir.DIRBAttributes & EDIRBAttributes.DIRB_PATH_IN_STREAM_BIT) != 0) { foreach (CDataStream data in dir.Streams) { if (data.Header.StreamID == "PNAM") { if (dir.StringType == EStringType.ANSI) { System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); string str = encoding.GetString(data.Data); str = str.Substring(0, str.Length - 1); cnode = nLastVolume.AddFolder(str, block.StartPosition); } else if (dir.StringType == EStringType.Unicode) { System.Text.UnicodeEncoding encoding = new System.Text.UnicodeEncoding(); string str = encoding.GetString(data.Data); str = str.Substring(0, str.Length - 1); cnode = nLastVolume.AddFolder(str, block.StartPosition); } } } } else { cnode = nLastVolume.AddFolder(dir.DirectoryName.Substring(0, dir.DirectoryName.Length - 1), block.StartPosition); } if (cnode != null) { nLastDir = cnode; } } else if (bt == EBlockType.MTF_FILE) { CFileDescriptorBlock fil = (CFileDescriptorBlock)block; // Check if the file name is contained in a data stream CCatalogNode cnode = null; if ((fil.FileAttributes & EFileAttributes.FILE_NAME_IN_STREAM_BIT) != 0) { foreach (CDataStream data in fil.Streams) { if (data.Header.StreamID == "FNAM") { if (fil.StringType == EStringType.ANSI) { System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); string str = encoding.GetString(data.Data); cnode = nLastDir.AddFile(str, block.StartPosition); } else if (fil.StringType == EStringType.Unicode) { System.Text.UnicodeEncoding encoding = new System.Text.UnicodeEncoding(); string str = encoding.GetString(data.Data); cnode = nLastDir.AddFile(str, block.StartPosition); } } } } else { cnode = nLastDir.AddFile(fil.FileName, block.StartPosition); } } // Get next block type bt = mStream.PeekNextBlockType(); // Check progress if (mStream.BaseStream.Position > mLastPos + mIncrement) { mLastPos = mStream.BaseStream.Position; OnProgressChange((int)((float)mLastPos / (float)mStream.BaseStream.Length * 100.0f)); } } return(node); }
public void SetBlockType(int i, int j, EBlockType aBlockType) { if (anIniFile == null) { return; } string aLine = anIniFile.IniReadValue("Map", String.Format("Line.{0:00}", j)); char aNewChar = ' '; switch (aBlockType) { case EBlockType.BLOCKTYPE_HARDWALL: aNewChar = '*'; break; case EBlockType.BLOCKTYPE_SOFTWALL: aNewChar = '-'; break; case EBlockType.BLOCKTYPE_RANDOM: aNewChar = '?'; break; case EBlockType.BLOCKTYPE_FREE: aNewChar = ' '; break; case EBlockType.BLOCKTYPE_WHITEBOMBER: aNewChar = '1'; break; case EBlockType.BLOCKTYPE_BLACKBOMBER: aNewChar = '2'; break; case EBlockType.BLOCKTYPE_REDBOMBER: aNewChar = '3'; break; case EBlockType.BLOCKTYPE_BLUEBOMBER: aNewChar = '4'; break; case EBlockType.BLOCKTYPE_GREENBOMBER: aNewChar = '5'; break; case EBlockType.BLOCKTYPE_MOVEBOMB_RIGHT: aNewChar = 'R'; break; case EBlockType.BLOCKTYPE_MOVEBOMB_DOWN: aNewChar = 'D'; break; case EBlockType.BLOCKTYPE_MOVEBOMB_LEFT: aNewChar = 'L'; break; case EBlockType.BLOCKTYPE_MOVEBOMB_UP: aNewChar = 'U'; break; case EBlockType.BLOCKTYPE_ITEM_BOMB: aNewChar = 'B'; break; case EBlockType.BLOCKTYPE_ITEM_FLAME: aNewChar = 'F'; break; case EBlockType.BLOCKTYPE_ITEM_ROLLER: aNewChar = 'S'; break; case EBlockType.BLOCKTYPE_ITEM_KICK: aNewChar = 'K'; break; case EBlockType.BLOCKTYPE_ITEM_THROW: aNewChar = 'T'; break; case EBlockType.BLOCKTYPE_ITEM_PUNCH: aNewChar = 'P'; break; case EBlockType.BLOCKTYPE_ITEM_SKULL: aNewChar = 'C'; break; case EBlockType.BLOCKTYPE_ITEM_REMOTE: aNewChar = 'Z'; break; case EBlockType.BLOCKTYPE_ITEM_SHIELD: aNewChar = 'V'; break; case EBlockType.BLOCKTYPE_ITEM_STRONGWEAK: aNewChar = 'I'; break; default: break; } StringBuilder sbLine = new StringBuilder(aLine); sbLine[i] = aNewChar; aLine = sbLine.ToString().Trim(); if (aLine.Length == 15) { anIniFile.IniWriteValue("Map", String.Format("Line.{0:00}", j), aLine); } }
private void Select(EBlockType aBlockType) { levelManager.SetBlockType(ci, cj, aBlockType); this.UpdateTile(ci, cj); }
public static TBlockHeader Factory(BinaryReader br, EBlockType blockType, EContentType contentType) { switch (blockType) { case EBlockType.Code: { switch (contentType) { case EContentType.PlainCode: return new TCodeBlock(); case EContentType.SignedCode: return new TSignedCodeBlock(); } throw new Exception("Unknown Code Content"); } case EBlockType.Data: { switch (contentType) { case EContentType.PlainData: return new TDataBlock(); case EContentType.SignedData: return new TSignedDataBlock(); } throw new Exception("Unknown Data Content"); } } throw new Exception("Unknown block"); }