private void ChangeCurrentBlock(BlockType blk) { m_enumCurrentBlock = blk; switch (blk) { case BlockType.Blank: this.空白ToolStripMenuItem.CheckState = CheckState.Checked; this.机器人ToolStripMenuItem.CheckState = CheckState.Unchecked; this.墙ToolStripMenuItem.CheckState = CheckState.Unchecked; this.终止点ToolStripMenuItem.CheckState = CheckState.Unchecked; break; case BlockType.Wall: this.空白ToolStripMenuItem.CheckState = CheckState.Unchecked; this.机器人ToolStripMenuItem.CheckState = CheckState.Unchecked; this.墙ToolStripMenuItem.CheckState = CheckState.Checked; this.终止点ToolStripMenuItem.CheckState = CheckState.Unchecked; break; case BlockType.Robot: this.空白ToolStripMenuItem.CheckState = CheckState.Unchecked; this.机器人ToolStripMenuItem.CheckState = CheckState.Checked; this.墙ToolStripMenuItem.CheckState = CheckState.Unchecked; this.终止点ToolStripMenuItem.CheckState = CheckState.Unchecked; break; case BlockType.Goal: this.空白ToolStripMenuItem.CheckState = CheckState.Unchecked; this.机器人ToolStripMenuItem.CheckState = CheckState.Unchecked; this.墙ToolStripMenuItem.CheckState = CheckState.Unchecked; this.终止点ToolStripMenuItem.CheckState = CheckState.Checked; break; default: break; } }
public void addFace(FACE face, int x, int y, int z, BlockType type) { //get the template vertices needed to draw this face Vector3[] vertices = BlockTemplate.vertices[(int)face]; //get the uv mapping for this block/face combination Vector2[] uv = BlockTypes.getUV(type, face); //Vector2[] uv = BlockTemplate.uv; //store the original vertex index int origin = _vertices.Count; for (int i=0;i<vertices.Length; i++) { Vector3 vertex = Vector3.Scale(vertices[i] + new Vector3(x,y,z), Block.SIZE); //translate and scale the vertex to the position of this block _vertices.Add(vertex); _uvs.Add(uv[i]); } //get a template face int[] triangles = BlockTemplate.face; for (int i=0; i<triangles.Length; i++) { //translate this index to point to the vertices we just added _triangles.Add(origin + triangles[i]); } }
public static uint GetCost(BlockType blockType) { switch (blockType) { case BlockType.BankRed: case BlockType.BankBlue: case BlockType.BeaconRed: case BlockType.BeaconBlue: return 50; case BlockType.SolidRed: case BlockType.SolidBlue: return 10; case BlockType.TransRed: case BlockType.TransBlue: return 25; case BlockType.Road: return 10; case BlockType.Jump: return 25; case BlockType.Ladder: return 25; case BlockType.Shock: return 50; case BlockType.Explosive: return 100; } return 1000; }
public override bool HandleTileEdit(TSPlayer player, TileEditType editType, BlockType blockType, DPoint location, int objectStyle) { if (this.IsDisposed) return false; if (base.HandleTileEdit(player, editType, blockType, location, objectStyle)) return true; if (editType == TileEditType.PlaceTile) return this.HandleTilePlace(player, blockType, location, objectStyle); if (editType == TileEditType.TileKill || editType == TileEditType.TileKillNoItem) return this.HandleTileDestruction(player, location); if (editType == TileEditType.PlaceWire || editType == TileEditType.PlaceWireBlue || editType == TileEditType.PlaceWireGreen) return this.HandleWirePlace(player, location); #if DEBUG || Testrun if (editType == TileEditType.DestroyWire) { player.SendMessage(location.ToString(), Color.Aqua); if (!TerrariaUtils.Tiles[location].active()) return false; ObjectMeasureData measureData = TerrariaUtils.Tiles.MeasureObject(location); player.SendInfoMessage(string.Format( "X: {0}, Y: {1}, FrameX: {2}, FrameY: {3}, Origin X: {4}, Origin Y: {5}, Active State: {6}", location.X, location.Y, TerrariaUtils.Tiles[location].frameX, TerrariaUtils.Tiles[location].frameY, measureData.OriginTileLocation.X, measureData.OriginTileLocation.Y, TerrariaUtils.Tiles.ObjectHasActiveState(measureData) )); } #endif return false; }
public void PushEntries(IEnumerable<WalletEntry> entries, BlockType? blockType) { foreach(var entry in entries) { PushEntry(entry, blockType); } }
public GameObject SpawnBlock(BlockType type , Vector3 location) { var game = Instantiate(Resources.Load(BlockTyper(type))) as GameObject; game.transform.SetParent(pieces); game.transform.position = location; return game; }
public void SetBlockAt(Vector3 position, BlockType block) { int x= Mathf.RoundToInt( position.x ); int y= Mathf.RoundToInt( position.y ); int z= Mathf.RoundToInt( position.z ); SetBlockAt(x,y,z,block); }
public BlockMatcher(BlockType type) { this.BlockType = type; _regex = new Regex( BlockMatcher.GetPattern(type), RegexOptions.Compiled | RegexOptions.Singleline); }
public static void ReadBlock(Stream stream, out BlockType blockType, out byte[] data) { blockType = (BlockType)stream.ReadByte(); var sizeBuffer = stream.ReadBytes(2); var size = (ushort)(sizeBuffer[0] | sizeBuffer[1] << 8); data = stream.ReadBytes(size - 2); }
public Block(BlockType type, int x, int y) : this() { Position = new Point(x, y); Type = type; Rotate = 0; }
// * Convert a block to a different type of block as a copy. // * // * @date 12.06.2011 23:33:50 // * @author Christian Scheiblich // * @param blockType // * the type of block to convert to // * @param block // * the pattern block keeping memory or not // * @return a new block object as a copy for the the requested type // * @throws BlockException // * if off sets or sizes are negative or out of bound public static Block convert(BlockType blockType, Block block) { Block newBlock = null; newBlock = create(blockType, block.getOffSetRow(), block.getOffSetCol(), block.getNoOfRows(), block.getNoOfCols()); if(block.isMemAllocated()) { newBlock.allocateMemory(); double[][] matrix = block.get(); for(int i = 0; i < block.getNoOfRows(); i++) { for(int j = 0; j < block.getNoOfCols(); j++) { double val = matrix[i][j]; if(val != 0.0) { newBlock.set(i, j, val); } } // for } // for } // if return newBlock; }
/// <summary> /// Give the start position of the agent and a goal, provide the Maze and a container to handle the pathfinding. can give different containers implementing IContainer interface /// to have different search results /// </summary> /// <param name="pos">Start position</param> /// <param name="GoalNode">Goal position</param> /// <param name="Grid">The Maze Grid</param> /// <param name="frontier">Container to use (i.e. Stack, Queue, PriorityQueue)</param> /// <returns></returns> public List<BlockPosition> GraphSearch(Node pos, Node GoalNode, BlockType[,] Grid, datastructures.IContainer<Node> frontier) { frontier.Push(pos); List<Node> explored = new List<Node>(); while (!frontier.isEmpty()) { Node currentNode = frontier.Pop(); if (isGoalState(currentNode, GoalNode)) //path found, return return currentNode.Path(); else //still searching.. { explored.Add(currentNode); foreach (Node n in getSuccesors(currentNode, Grid, PathFindSuccessor)) { if (!explored.Contains(n)) frontier.Push(n); } } } return null; //there are no more nodes, and the goal hasn't been reached. return null }
public BlockRequestBase(TaskId taskId, string taskExecutionId, BlockType blockType, string blockExecutionId) { TaskId = taskId; TaskExecutionId = taskExecutionId; BlockExecutionId = blockExecutionId; BlockType = blockType; }
public static Block create(BlockType blockType, int offSetRow, int offSetCol, int noOfRows, int noOfCols) { Block block = null; switch(blockType) { case BlockType.Dummy : block = new BlockDummy(offSetRow, offSetCol, noOfRows, noOfCols); break; case BlockType.Full : block = new BlockFull(offSetRow, offSetCol, noOfRows, noOfCols); break; case BlockType.Index : block = new BlockIndex(offSetRow, offSetCol, noOfRows, noOfCols); break; default : throw new BlockError("BlockBuilder#create -- given BlockType is not defined"); } // switch return block; }
public bool CanPlaceBlock(BlockType type, int[] chunkCoord, int[] blockCoord) { // Check first to see if we are attempting one of the overlap blocks that techinically "belongs" to the next chunk over bool changed = false; if (blockCoord[0] == Settings.CHUNK_SIZE) // x is actually in the next chunk { chunkCoord[0]++; blockCoord[0] = 0; changed = true; } if (blockCoord[1] == Settings.CHUNK_SIZE) { chunkCoord[1]++; blockCoord[1] = 0; changed = true; } if (blockCoord[2] == Settings.CHUNK_SIZE) { chunkCoord[2]++; blockCoord[2] = 0; changed = true; } if (changed) return CanPlaceBlock(type, chunkCoord, blockCoord); Chunk c; if (!allChunks.TryGetValue(Util.CoordsToString(chunkCoord), out c)) return false; // No chunk found return true; }
public void ExportJson() { var blockType = new BlockType { Name = "Foo" }; var result = blockType.ToJson(); const string key = "\"Name\": \"Foo\""; Assert.NotEqual( result.IndexOf( key ), -1 ); }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnSave_Click( object sender, EventArgs e ) { BlockType blockType; BlockTypeService blockTypeService = new BlockTypeService(); int blockTypeId = int.Parse( hfBlockTypeId.Value ); if ( blockTypeId == 0 ) { blockType = new BlockType(); blockTypeService.Add( blockType, CurrentPersonId ); } else { BlockTypeCache.Flush( blockTypeId ); blockType = blockTypeService.Get( blockTypeId ); } blockType.Name = tbName.Text; blockType.Path = tbPath.Text; blockType.Description = tbDescription.Text; if ( !blockType.IsValid ) { // Controls will render the error messages return; } blockTypeService.Save( blockType, CurrentPersonId ); BindGrid(); pnlDetails.Visible = false; pnlList.Visible = true; }
void SelectDirtBlock() { _selectedBlockType = BlockType.Dirt; _buttonBlockDirt.ForcePress(); _buttonBlockGrass.ForceRelease(); _buttonBlockStone.ForceRelease(); }
public InvalidBlockTypeException(BlockType blockType) : base(string.Format( "The given block type \"{0}\" was unexpected in this context.", blockType )) { this.BlockType = blockType; }
public BlockInfo(Vector2i position, BlockType type, float height, Vector3 normal) { Position = position; Type = type; Height = height; Normal = normal; }
public void RemoveBlockFromGrid(int i, int j, BlockType blockType) { gridMap[i, j] = false; gridMap[i + blockType.GetWidth() - 1, j] = false; gridMap[i, j + blockType.GetHeight() - 1] = false; gridMap[i + blockType.GetWidth() - 1, j + blockType.GetHeight() - 1] = false; }
static string ApplyScaleAndCritical(string pattern, Stat stat, BlockType type, float effectFactor, int criticalBuffId) { float ciriticalFactor = 0; if (stat != null) { if (type == BlockType.Attack1 || type == BlockType.Attack2) { bool isCritical = RandomTool.IsIn(stat.Get(HeroStatType.criticalHitChance)); if (isCritical) { int parenOpen; int parenclose; SearchParenIndexs(pattern, "PhysicalAttack", out parenOpen, out parenclose); pattern = pattern.Insert(parenclose, "; param=critical"); if (criticalBuffId > 0) { pattern = string.Format("Sequence({0}; Action(Contact; Buff; {1}) )", pattern, criticalBuffId); } ciriticalFactor = stat.Get(HeroStatType.criticalHitDamageFactor); } } } return string.Format(pattern, 1 + effectFactor + ciriticalFactor); }
public WorldData(int x, int y, int z, int s, BlockType[,,] d) { worldX = x; worldY = y; worldZ = z; chunkSize = s; data = d; }
public Block(int x, int y, BlockType type) { this.x = x; this.y = y; size = 10; this.type = type; }
public Blox(string i_szName, BlockType i_stBlockType) { m_szName = i_szName; m_stBlockType = i_stBlockType; m_arBlockVars = new List<BlockVar>(); m_arIndicators = new List<Indicator>(); }
private Blox readBlock(BlockType type, string szName) { Blox blox = new Blox(szName, type); UseType useType; foreach (XmlNode node in m_xmlDocBlox.ChildNodes[1].ChildNodes) { if (node.Name == "indicator") { blox.addIndicator(BloxReader.CreateIndicator(node)); } else if(node.Name != "script"){ switch(node.Name) { case "instrument_global": useType = UseType.InstrumentGlobal; break; case "block_global": useType = UseType.BlockGlobal; break; case "parameter": useType = UseType.Parameter; break; default: if (node.Name != "#comment") { if (log.IsWarnEnabled) log.Warn("Variable Type not recognized. Skipping! (" + node.Name + ")"); } continue; } blox.addVar(BloxReader.CreateVar(node, useType)); } } return blox; }
static BlockEntity2 GetBlock(BlockType blockType, int subClassCode) { var blockTable = TableLoader.GetTable<BlockEntity2>(); var subClassEntity = TableLoader.GetTable<SubClassEntity>().Get(subClassCode); switch (blockType) { case BlockType.Item: case BlockType.Gather: case BlockType.WildCard: return blockTable.Values.Single(x => x.blockType == blockType); case BlockType.Attack1: return blockTable.Get(subClassEntity.attackBlock1); case BlockType.Attack2: return blockTable.Get(subClassEntity.attackBlock2); case BlockType.Ability: return blockTable.Get(subClassEntity.abilityBlock); case BlockType.Defend: return blockTable.Get(subClassEntity.defendBlock); default: Assert.Fail(); return null; } }
public void BuildSideDown(int x, int y, int z, BlockType type) { vert0 = new Vector3(x + -0.5f, y + -0.5f, z + -0.5f); vertices.Add(vert0); verts++; v0 = verts - 1; vert1 = new Vector3(x + -0.5f, y + -0.5f, z + 0.5f); vertices.Add(vert1); verts++; v1 = verts - 1; vert2 = new Vector3(x + 0.5f, y + -0.5f, z + 0.5f); vertices.Add(vert2); verts++; v2 = verts - 1; vert3 = new Vector3(x + 0.5f, y + -0.5f, z + -0.5f); vertices.Add(vert3); verts++; v3 = verts - 1; triangles.Add(v1); triangles.Add(v0); triangles.Add(v3); triangles.Add(v1); triangles.Add(v3); triangles.Add(v2); AddUVRange(FaceUVs(Direction.down, type)); }
public MatchResult(Pattern pattern, int x, int y, BlockType type) { this.pattern = pattern; this.x = x; this.y = y; this.type = type; }
protected virtual bool AddBlock(Vector3 pos, BlockType type) { World world = (World)FindObjectOfType(typeof(World)); Chunk chunk = world.worldPointToClosestChunk(pos); return chunk.addBlockAtWorldPosition(pos, type); }
//Each block of compressed data begins with 3 header bits // containing the following data: // first bit BFINAL // next 2 bits BTYPE // Note that the header bits do not necessarily begin on a byte // boundary, since a block does not necessarily occupy an integral // number of bytes. // BFINAL is set if and only if this is the last block of the data // set. // BTYPE specifies how the data are compressed, as follows: // 00 - no compression // 01 - compressed with fixed Huffman codes // 10 - compressed with dynamic Huffman codes // 11 - reserved (error) // The only difference between the two compressed cases is how the // Huffman codes for the literal/length and distance alphabets are // defined. // // This function returns true for success (end of block or output window is full,) // false if we are short of input // private bool Decode() { var eob = false; var result = false; if (Finished()) { return(true); } if (hasFormatReader) { if (state == InflaterState.ReadingHeader) { if (!formatReader.ReadHeader(input)) { return(false); } state = InflaterState.ReadingBFinal; } else if (state == InflaterState.StartReadingFooter || state == InflaterState.ReadingFooter) { if (!formatReader.ReadFooter(input)) { return(false); } state = InflaterState.VerifyingFooter; return(true); } } if (state == InflaterState.ReadingBFinal) { // reading bfinal bit // Need 1 bit if (!input.EnsureBitsAvailable(1)) { return(false); } bfinal = input.GetBits(1); state = InflaterState.ReadingBType; } if (state == InflaterState.ReadingBType) { // Need 2 bits if (!input.EnsureBitsAvailable(2)) { state = InflaterState.ReadingBType; return(false); } blockType = (BlockType)input.GetBits(2); if (blockType == BlockType.Dynamic) { state = InflaterState.ReadingNumLitCodes; } else if (blockType == BlockType.Static) { literalLengthTree = HuffmanTree.StaticLiteralLengthTree; distanceTree = HuffmanTree.StaticDistanceTree; state = InflaterState.DecodeTop; } else if (blockType == BlockType.Uncompressed) { state = InflaterState.UncompressedAligning; } else { throw new InvalidDataException(SR.GetString(SR.UnknownBlockType)); } } if (blockType == BlockType.Dynamic) { if (state < InflaterState.DecodeTop) { result = DecodeDynamicBlockHeader(); } else { result = DecodeBlock(out eob); // this can returns true when output is full } } else if (blockType == BlockType.Static) { result = DecodeBlock(out eob); } else if (blockType == BlockType.Uncompressed) { result = DecodeUncompressedBlock(out eob); } else { throw new InvalidDataException(SR.GetString(SR.UnknownBlockType)); } // // If we reached the end of the block and the block we were decoding had // bfinal=1 (final block) // if (eob && bfinal != 0) { if (hasFormatReader) { state = InflaterState.StartReadingFooter; } else { state = InflaterState.Done; } } return(result); }
//Each block of compressed data begins with 3 header bits // containing the following data: // first bit BFINAL // next 2 bits BTYPE // Note that the header bits do not necessarily begin on a byte // boundary, since a block does not necessarily occupy an integral // number of bytes. // BFINAL is set if and only if this is the last block of the data // set. // BTYPE specifies how the data are compressed, as follows: // 00 - no compression // 01 - compressed with fixed Huffman codes // 10 - compressed with dynamic Huffman codes // 11 - reserved (error) // The only difference between the two compressed cases is how the // Huffman codes for the literal/length and distance alphabets are // defined. // // This function returns true for success (end of block or output window is full,) // false if we are short of input // private bool Decode() { bool eob = false; bool result = false; if (Finished()) { return true; } if (_usingGzip) { if (_state == InflaterState.ReadingGZIPHeader) { if (!_gZipDecoder.ReadGzipHeader()) { return false; } _state = InflaterState.ReadingBFinal; } else if (_state == InflaterState.StartReadingGZIPFooter || _state == InflaterState.ReadingGZIPFooter) { if (!_gZipDecoder.ReadGzipFooter()) return false; _state = InflaterState.VerifyingGZIPFooter; return true; } } if (_state == InflaterState.ReadingBFinal) { // reading bfinal bit // Need 1 bit if (!_input.EnsureBitsAvailable(1)) return false; _bfinal = _input.GetBits(1); _state = InflaterState.ReadingBType; } if (_state == InflaterState.ReadingBType) { // Need 2 bits if (!_input.EnsureBitsAvailable(2)) { _state = InflaterState.ReadingBType; return false; } blockType = (BlockType) _input.GetBits(2); if (blockType == BlockType.Dynamic) { _state = InflaterState.ReadingNumLitCodes; } else if (blockType == BlockType.Static) { _literalLengthTree = HuffmanTree.StaticLiteralLengthTree; _distanceTree = HuffmanTree.StaticDistanceTree; _state = InflaterState.DecodeTop; } else if (blockType == BlockType.Uncompressed) { _state = InflaterState.UncompressedAligning; } else { throw new InvalidDataException("SR.UnknownBlockType"); } } if (blockType == BlockType.Dynamic) { if (_state < InflaterState.DecodeTop) { // we are reading the header result = DecodeDynamicBlockHeader(); } else { result = DecodeBlock(out eob); // this can returns true when output is full } } else if (blockType == BlockType.Static) { result = DecodeBlock(out eob); } else if (blockType == BlockType.Uncompressed) { result = DecodeUncompressedBlock(out eob); } else { throw new InvalidDataException("SR.UnknownBlockType"); } // // If we reached the end of the block and the block we were decoding had // bfinal=1 (final block) // if (eob && (_bfinal != 0)) { if (_usingGzip) _state = InflaterState.StartReadingGZIPFooter; else _state = InflaterState.Done; } return result; }
void SerializeIntoBuffer(object?metadata, IReadOnlyList <object>?events, out int startOffset, out IDescriptorSerializerContext serializerContext, out BlockType blockType, out int lenWithoutEndPadding, out ByteBuffer block) { startOffset = (int)EndBufferLen + HeaderSize; var writer = new SpanWriter(); writer.WriteBlock(_zeroes.AsSpan(0, startOffset)); serializerContext = Mapping; if (metadata != null) { serializerContext = serializerContext.StoreNewDescriptors(metadata); } if (events != null) { foreach (var o in events) { serializerContext = serializerContext.StoreNewDescriptors(o); } if (events.Count == 0) { events = null; } } serializerContext.FinishNewDescriptors(ref writer); blockType = BlockType.FirstBlock; if (serializerContext.SomeTypeStored) { blockType |= BlockType.HasTypeDeclaration; } if (metadata != null) { serializerContext.StoreObject(ref writer, metadata); blockType |= BlockType.HasMetadata; } if (events != null) { if (events.Count == 1) { serializerContext.StoreObject(ref writer, events[0]); blockType |= BlockType.HasOneEvent; } else { writer.WriteVUInt32((uint)events.Count); foreach (var o in events) { serializerContext.StoreObject(ref writer, o); } blockType |= BlockType.HasMoreEvents; } } lenWithoutEndPadding = (int)writer.GetCurrentPosition(); writer.WriteBlock(_zeroes.AsSpan(0, (int)(SectorSize - 1))); block = writer.GetByteBufferAndReset(); if (CompressionStrategy.ShouldTryToCompress(lenWithoutEndPadding - startOffset)) { var compressedBlock = new ReadOnlySpan <byte>(block.Buffer, startOffset, lenWithoutEndPadding - startOffset); if (CompressionStrategy.Compress(ref compressedBlock)) { blockType |= BlockType.Compressed; compressedBlock.CopyTo(new Span <byte>(block.Buffer, startOffset, compressedBlock.Length)); lenWithoutEndPadding = startOffset + compressedBlock.Length; new Span <byte>(block.Buffer, lenWithoutEndPadding, (int)SectorSize - 1).Clear(); } } }
protected virtual void SingleSpanBlockTest(string document, BlockType blockType, SpanKind spanType, params RazorError[] expectedError) { SingleSpanBlockTest(document, document, blockType, spanType, expectedError); }
/// <summary> /// Creates a new <see cref="BlockType"/> instance. /// </summary> private protected BlockTypeInstruction() { this.Type = BlockType.Empty; }
public OreEntry(int minimumDepth, int howOftenGenerateBits, int oresPerXBlocks, BlockType type, bool isFluid = false) { MinimumDepth = minimumDepth; ChanceOfSpawn = howOftenGenerateBits; OresPerXBlocks = oresPerXBlocks; Type = type; IsFluid = isFluid; }
public void FromId_IdTooLarge_ThrowsOutOfRangeException(int id) { Assert.That(() => BlockType.FromId((ushort)id), Throws.InstanceOf <ArgumentOutOfRangeException>()); }
/// <summary> /// Create instance of the asynchronous queue (blocking collection version). /// </summary> /// <param name="name">Name of the asynchronous queue</param> /// <param name="blockType">Type of the blocking strategy</param> /// <param name="blockLimit">Blocking buffer limit</param> public AsyncQueueBlocking(string name, BlockType blockType = BlockType.Error, int blockLimit = 1000000) { Name = name; BlockType = blockType; BlockLimit = blockLimit; }
void Update() { //Asking TimeManger if we are at end of trial... if (_timer.EndTrial == true) { _currentTaskState = TaskState.EndTrial; } //asking TimeManager if we are at end of a block... if (_trialType == TrialType.Both) { if (_timer.SwitchBlock == true) { if (CurrentBlockType == BlockType.Baseline) { CurrentBlockType = BlockType.Reversal; _currentTaskState = TaskState.StartBlock; } else if (CurrentBlockType == BlockType.Reversal) { CurrentBlockType = BlockType.Baseline; _currentTaskState = TaskState.StartBlock; } } } // MAIN STATE MACHINE switch (_currentTaskState) { case TaskState.WaitForTrigger: if (!Hourglass.activeInHierarchy) { Hourglass.SetActive(true); } break; case TaskState.StartTrial: ClearFeedback(); _logger.Init(); switch (_trialType) { case TrialType.Both: CurrentBlockType = BlockType.Baseline; break; case TrialType.Baseline: CurrentBlockType = BlockType.Baseline; break; case TrialType.Reversal: CurrentBlockType = BlockType.Reversal; break; } _currentTaskState = TaskState.StartBlock; break; case TaskState.StartBlock: switch (CurrentBlockType) { case BlockType.Baseline: StartBaseline(); _blockLengthLimit = _baselineBlockLength; break; case BlockType.Reversal: StartReversal(); _blockLengthLimit = _reversalBlockLength; break; } //start the block timer here, check end in Timer script BlockTimerStart = DateTime.Now; _currentTaskState = TaskState.StartIteration; break; case TaskState.StartIteration: if (CurrentBlockType == BlockType.Baseline) { ClearFeedback(); StartBaseline(); } if (CurrentBlockType == BlockType.Reversal) { ClearFeedback(); StartReversal(); } _previousChoices = new List <ItemChoice>(); if (CurrentBlockType == BlockType.Baseline || _previousCorrectChoice == ItemChoice.None) { SetCorrectAnswerRandomly(); } else { SetCorrectAnswerToPrevious(); } if (CurrentBlockType == BlockType.Baseline) { DisplayHint(); } _iterationStartTime = Time.time; //start time of the iteration _currentTaskState = TaskState.ProcessChoice; break; case TaskState.ProcessChoice: // Filter out no choice or repeated choices if (_currentChoice != ItemChoice.None && !_previousChoices.Contains(_currentChoice)) { _previousChoices.Add(_currentChoice); if (_previousCorrectChoice == ItemChoice.None) { } if (CurrentBlockType == BlockType.Reversal && _interReversalIterationCount > _interReversalIterationNumber) // **RANDOMIZED # OF ITERATIONS BETWEEN REVERSAL BLOCKS** { SetCorrectAnswerBasedOnChoiceProb(_currentChoice); _reversalFlag = 1; //marks occurance of reversals } if (_currentChoice == _correctChoice) { UpdateDisplayForChoice(_currentChoice, ChoiceResult.Correct); if (CurrentBlockType == BlockType.Reversal) { _attemptCount++; //tally for total number of responses _correctAttemptCount++; //tally for totaly number of CORRECT responses } if (CurrentBlockType == BlockType.Baseline) { _baselineAttemptCount++; baselineCorrectAttemptCount++; } _iterationEndTime = Time.time; _currentTaskState = TaskState.ReinforceIteration; } else { UpdateDisplayForChoice(_currentChoice, ChoiceResult.Incorrect); if (CurrentBlockType == BlockType.Reversal) { _attemptCount++; //tally for total number of responses _incorrectAttemptCount++; //tally for totaly number of INCORRECT responses if (_reversalFlag == 1) { _incorrectAttemptOnReversalCount++; // tally for the number of INCORRECT responses in a REVERSAL condition } } if (CurrentBlockType == BlockType.Baseline) { _baselineAttemptCount++; baselineIncorrectAttemptCount++; } _currentTaskState = TaskState.ProcessChoice; } _currentChoice = ItemChoice.None; } break; case TaskState.ReinforceIteration: var tmpTime = Time.time; _currentTaskState = tmpTime - _iterationEndTime >= 1.5 ? TaskState.EndIteration : TaskState.ReinforceIteration; //FIX THIS : MAKE THE DELAY CONFIGURABLE break; case TaskState.EndIteration: //blockTimerEnd = DateTime.Now; _currentTrialLength = Time.timeSinceLevelLoad - ScannerDelay; _previousCorrectChoice = _correctChoice; _interReversalIterationCount++; _logger.LogRaw(_reversalIterationCount + " , " + _attemptCount + " , " + _correctAttemptCount + " , " + _incorrectAttemptCount + " , " + _incorrectAttemptOnReversalCount + " , " + _responseTime + " , " + _reversalCount + " , " + _reversalResponseTime + " , " + baselineIterationCount + " , " + baselineResponseTime + " , " + _baselineAttemptCount + " , " + baselineCorrectAttemptCount + " , " + baselineIncorrectAttemptCount); if (CurrentBlockType == BlockType.Reversal) { _reversalIterationCount++; //tally of the number of iterations presented _responseTime = _iterationEndTime - _iterationStartTime; //calculating time in between CORRECT responses (response time) _totalResponseTime = _totalResponseTime + _responseTime; //total response time compiler. compiles the time it takes to get the correct answer (the time taken to complete iteration) --> used to calculate average if (_reversalFlag == 1) // checking if reversal has occured and pulling that time frame from _responseTime { _interReversalIterationNumber = Random.Range(4, 7); _reversalResponseTime = _responseTime; _totalReversalResponseTime = _totalReversalResponseTime + _reversalResponseTime; //compiling total response time in reversal situation _reversalCount++; //compiles number of reversals as they occur _reversalFlag = 0; //resets reversal marker } } if (CurrentBlockType == BlockType.Baseline) //baseline block metrics { baselineIterationCount++; baselineResponseTime = _iterationEndTime - _iterationStartTime; _totalBaselineResponseTime = _totalBaselineResponseTime + baselineResponseTime; } if (_trialType != TrialType.Both) { _currentTaskState = TaskState.StartIteration; } //if (_trialType == TrialType.All && ((blockTimerEnd - blockTimerStart).Seconds > blockLengthLimit)) //{ // _currentTaskState = TaskState.EndBlock; //} else { _currentTaskState = TaskState.StartIteration; } // if (_trialLength > _trialLengthLimit) //**SET THIS TO A GIVEN TIME PERIOD (9 MIN WAS DISCUSSED - 540 sec)** //{ // _currentTaskState = TaskState.EndTrial; //} break; case TaskState.EndBlock: if (CurrentBlockType == BlockType.Baseline) { CurrentBlockType = BlockType.Reversal; } else if (CurrentBlockType == BlockType.Reversal) { CurrentBlockType = BlockType.Baseline; } _currentTaskState = TaskState.StartBlock; break; case TaskState.EndTrial: _averageResponseTime = _totalResponseTime / _reversalIterationCount; // average response time to get correct answer over course of the whole trial _averageReversalResponseTime = _totalReversalResponseTime / _reversalCount; // average response time to reversal condition averageBaselineResponseTime = _totalBaselineResponseTime / baselineIterationCount; // baseline block metrics _logger.LogReversalSummary("ReversalIterationCount , trialDuration , averageResponseTime , reversalCount , averageReversalResponseTime" + Environment.NewLine + _reversalIterationCount + " , " + _timer.CurrentTrialLength + " , " + _averageResponseTime + " , " + _reversalCount + " , " + _averageReversalResponseTime); // summery metrics for whole trial _logger.LogBaselineSummary("BaselineIterationCount , trialDuration , baselineCorrectCount , baselineIncorrectCount , averageBaselineResponseTime" + Environment.NewLine + baselineIterationCount + " , " + _timer.CurrentTrialLength + " , " + baselineCorrectAttemptCount + " , " + baselineIncorrectAttemptCount + " , " + averageBaselineResponseTime); _logger.Term(); SceneManager.LoadScene("GameEndScreen_Stimulation"); break; } }
private protected BlockTypeInstruction(BlockType type) { this.Type = type; }
/** * Considers center tile to have given type. Used for checking during building. */ public NeighbourPositionStream filterByAccessibilityWithFutureTile(BlockType type) { stream = stream.Where(position => passageMap.tileIsAccessibleFromNeighbour(center, position, type)); return(this); }
/// <summary> /// Restores the health of the block and removes the cracks by redrawing the chunk. /// </summary> public void Reset() { health = BlockType.NOCRACK; currentHealth = blockHealthMax[(int)blockType]; owner.Redraw(); }
internal Block(BlockType type, IEnumerable <SyntaxTreeNode> contents, IBlockCodeGenerator generator) { Type = type; CodeGenerator = generator; Children = contents; }
/// <summary> /// Creates a new <see cref="If"/> of the provided type. /// </summary> /// <param name="type">Becomes the block's <see cref="BlockTypeInstruction.Type"/>.</param> public If(BlockType type) : base(type) { }
public void SetBT(BlockType nbt) { bt = nbt; }
public PrimitiveBlock(int nx, int ny, BlockType nbt, Sprite nspr) : this(nx, ny, nbt) { spr = nspr; }
public PrimitiveBlock(int nx, int ny, BlockType nbt, Sprite nspr, bool nflipX, bool nFlipY) : this(nx, ny, nbt, nspr) { flipX = nflipX; flipY = nFlipY; }
public MarkupBlock(BlockType blockType, IBlockCodeGenerator codeGenerator, IEnumerable <SyntaxTreeNode> children) : base(blockType, children, codeGenerator) { }
public Block(int x, int y, int z, BlockType blockType) : this(x, y, z) { BlockID = blockType; }
internal WorldPortalBlock(BlockType type, int bid, string target, int spawn) : base(type, bid) { Target = target; Spawn = spawn; }
private List <Point> GetCellPossess(Point ind, BlockType type) { List <Point> datas = new List <Point>(); switch (type) { case BlockType.Square: datas.Add(new Point(0, 0)); datas.Add(new Point(1, 1)); datas.Add(new Point(1, 0)); datas.Add(new Point(0, 1)); break; case BlockType.Line: if (targetDirect == 0 || targetDirect == 2) { datas.Add(new Point(0, 0)); datas.Add(new Point(-1, 0)); datas.Add(new Point(1, 0)); datas.Add(new Point(2, 0)); } else { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(0, 1)); datas.Add(new Point(0, 2)); } break; case BlockType.T: if (targetDirect == 0) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(1, 0)); datas.Add(new Point(-1, 0)); } else if (targetDirect == 1) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(1, 0)); datas.Add(new Point(0, 1)); } else if (targetDirect == 2) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, 1)); datas.Add(new Point(1, 0)); datas.Add(new Point(-1, 0)); } else if (targetDirect == 3) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(-1, 0)); datas.Add(new Point(0, 1)); } break; case BlockType.Z: if (targetDirect == 0 || targetDirect == 2) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(-1, -1)); datas.Add(new Point(1, 0)); } else { datas.Add(new Point(0, 0)); datas.Add(new Point(0, 1)); datas.Add(new Point(1, 0)); datas.Add(new Point(1, -1)); } break; case BlockType.CZ: if (targetDirect == 0 || targetDirect == 2) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(1, -1)); datas.Add(new Point(-1, 0)); } else { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(1, 0)); datas.Add(new Point(1, 1)); } break; case BlockType.L: if (targetDirect == 0) { datas.Add(new Point(0, 0)); datas.Add(new Point(1, 0)); datas.Add(new Point(-1, 0)); datas.Add(new Point(-1, 1)); } else if (targetDirect == 1) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(0, 1)); datas.Add(new Point(-1, -1)); } else if (targetDirect == 2) { datas.Add(new Point(0, 0)); datas.Add(new Point(1, 0)); datas.Add(new Point(-1, 0)); datas.Add(new Point(1, -1)); } else if (targetDirect == 3) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(0, 1)); datas.Add(new Point(1, 1)); } break; case BlockType.CL: if (targetDirect == 0) { datas.Add(new Point(0, 0)); datas.Add(new Point(1, 0)); datas.Add(new Point(-1, 0)); datas.Add(new Point(-1, -1)); } else if (targetDirect == 1) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(0, 1)); datas.Add(new Point(1, -1)); } else if (targetDirect == 2) { datas.Add(new Point(0, 0)); datas.Add(new Point(1, 0)); datas.Add(new Point(-1, 0)); datas.Add(new Point(1, 1)); } else if (targetDirect == 3) { datas.Add(new Point(0, 0)); datas.Add(new Point(0, -1)); datas.Add(new Point(0, 1)); datas.Add(new Point(-1, 1)); } break; } for (int i = 0; i < datas.Count; i++) { datas[i] = new Point(datas[i].X + ind.X, datas[i].Y + ind.Y); } return(datas); }
public override string ToString() { return(BlockType.ToString() + " " + this.ConditionExpression); }
public static bool IsType(int bid, BlockType type) => (GetBlockType(bid) & type) == type;
void ReadVideoChunk(BitStream bs) { int current_block_x = 0, current_block_y = 0; int block_rez_x = (int)PaddedWidth / 4; int block_rez_y = (int)PaddedHeight / 4; Console.WriteLine("reading video chunk"); bs.DebugFirst(); while (true) { ushort type_descriptor = 0; if (type_Tree != null) { type_descriptor = (ushort)type_Tree.Decode(bs); } BlockType type = (BlockType)(type_descriptor & 0x3); uint chain_length = block_chain_size_table [(type_descriptor & 0xfc) >> 2]; Console.WriteLine("rendering {0} blocks of type {1}", chain_length, type); for (int i = 0; i < chain_length; i++) { switch (type) { case BlockType.Mono: ushort pixel = (ushort)mclr_Tree.Decode(bs); byte color1 = (byte)((pixel >> 8) & 0xff); byte color0 = (byte)(pixel & 0xff); ushort map = (ushort)mmap_Tree.Decode(bs); int mask = 1; int bx, by; bx = current_block_x * 4; by = current_block_y * 4; for (int bi = 0; bi < 16;) { if ((map & mask) == 0) { frameData[by * PaddedWidth + bx] = color0; } else { frameData[by * PaddedWidth + bx] = color1; } mask <<= 1; bx++; bi++; if ((bi % 4) == 0) { bx = current_block_x * 4; by++; } } break; case BlockType.Full: break; case BlockType.Void: break; case BlockType.Solid: break; } current_block_x++; if (current_block_x == block_rez_x) { current_block_x = 0; current_block_y++; if (current_block_y == block_rez_y) { return; } } } } }
protected virtual void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, params RazorError[] expectedErrors) { SingleSpanBlockTest(document, spanContent, blockType, spanType, AcceptedCharacters.Any, expectedErrors ?? new RazorError[0]); }
internal LabelBlock(BlockType type, int bid, string text, string color, int wrap) : base(type, bid) { Text = text; Color = color; Wrap = wrap; }
protected virtual void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters, params RazorError[] expectedErrors) { var builder = new BlockBuilder(); builder.Type = blockType; ParseBlockTest( document, ConfigureAndAddSpanToBlock( builder, Factory.Span(spanType, spanContent, spanType == SpanKind.Markup) .Accepts(acceptedCharacters)), expectedErrors ?? new RazorError[0]); }
protected virtual void SingleSpanBlockTest(string document, string spanContent, BlockType blockType, SpanKind spanType, AcceptedCharacters acceptedCharacters = AcceptedCharacters.Any) { SingleSpanBlockTest(document, spanContent, blockType, spanType, acceptedCharacters, expectedErrors: null); }
internal Block(BlockType type) { blockType = type; }
internal SignBlock(BlockType type, int bid, string text, int morph) : base(type, bid, morph) { Text = text; }