private BaseBlock BlocksFromXML(XmlElement element) { var blockNodeList = element.SelectNodes("Block"); var firstBlock = BaseBlock.LoadBlock(blockNodeList[0] as XmlElement, this); var prevBlock = firstBlock; for (int i = 1; i < blockNodeList.Count; i++) { var block = BaseBlock.LoadBlock(blockNodeList[i] as XmlElement, this) as StatementBlock; if (block == null) { throw new Exception("Statement가 아니면 붙일 수 없습니다."); } if (prevBlock is ScopeBlock) { (prevBlock as ScopeBlock).NextConnectHole.StatementBlock = block; } else if (prevBlock is PrevStatementBlock) { (prevBlock as PrevStatementBlock).NextConnectHole.StatementBlock = block; } else { throw new Exception("Statement를 붙일 수 없습니다."); } prevBlock = block; } return(firstBlock); }
public VariableConstantMap UpdateMap(BaseBlock baseBlock, VariableConstantMap map) { VariableConstantMap newM = map; foreach (var line in baseBlock.Enumerate()) { if (isAssignment(line.Operation)) { if (line.RightOperand == null) { //константа if (line.LeftOperand is NumericValue) { VariableValue newValue = new VariableValue(); newValue.type = VariableValueType.CONSTANT; newValue.value = (line.LeftOperand as NumericValue).Value; newM.variableTable[line.Destination as IdentificatorValue] = newValue; } //одна переменная в левой части else { newM.variableTable[line.Destination as IdentificatorValue] = CalculateTransmitionFunc(line, map); } } // в правой части выражения две переменные else { newM.variableTable[line.Destination as IdentificatorValue] = CalculateTransmitionFunc(line, map); } } } return(newM); }
/// <summary> /// 블럭 에디터에 블럭을 추가하고 필요한 내용을 추가합니다. /// </summary> /// <param name="block">추가할 블럭</param> public void AddBlock(BaseBlock block) { // 블럭 클릭 이벤트 추가 block.MouseLeftButtonDown += Block_MouseLeftButtonDown; block.MouseRightButtonDown += Block_MouseRightButtonDown; // 블럭을 캔버스에 추가 AttachToCanvas(block); block.BlockEditor = this; // 블럭의 HoleList를 가져와 BlockEditor에 추가 List <BaseHole> holeList = block.HoleList; foreach (BaseHole hole in holeList) { Type type = hole.GetType(); if (hole is NextConnectHole) { NextConnectHoleList.Add(hole as NextConnectHole); } else if (hole is SettableObjectHole) { SettableObjectHoleList.Add(hole as SettableObjectHole); } else if (hole is BaseObjectHole) { ObjectHoleList.Add(hole as BaseObjectHole); } } }
public void StartBlockMove(BaseBlock target, Point position = new Point()) { CaptureMouse(); SelectedBlock = target; SelectedPosition = position; IsSelectedBlockMoved = false; CanAttachHoleList.Clear(); if (SelectedBlock is ObjectBlock) { if (SelectedBlock is SettableObjectBlock) { CanAttachHoleList.AddRange(SettableObjectHoleList.Where(e => e.CanAttachBlock(SelectedBlock))); } CanAttachHoleList.AddRange(ObjectHoleList.Where((e) => e.CanAttachBlock(SelectedBlock))); } else if (SelectedBlock is StatementBlock) { CanAttachHoleList.AddRange(NextConnectHoleList.Where((e) => e.CanAttachBlock(SelectedBlock))); } Panel.SetZIndex(SelectedBlock, int.MaxValue - 2); }
public TextureItem Create(BaseBlock block) { var x = block.BlockId % map.Size; var y = map.Size - block.BlockId / map.Size - 1; return(map.GetItem(offset: new Vector2(x, y))); }
private bool TryOptimize(BaseBlock bblock, ExprSet input, IEnumerable <BaseBlock> prev) { for (int i = 0; i < bblock.Code.Count; ++i) { var line = bblock.Code[i]; if (ThreeAddrOpType.IsDefinition(line.OpType) && line.OpType != ThreeAddrOpType.Assign && line.OpType != ThreeAddrOpType.Read) { var expr = (line.LeftOp, line.OpType, line.RightOp); if (input.Contains(expr)) { if (TryExtract(prev, expr)) { line.RightOp = "tt" + _tempcount.ToString(); _tempcount++; line.OpType = ThreeAddrOpType.Assign; line.LeftOp = null; return(true); } } } input = TransferByLine(input, line); } return(false); }
private RawMesh initRawMesh(Chunk chunk) { BaseBlock[,,] blocks = chunk.Blocks; int vertCount = 0; int trianglesCount = 0; for (int z = 0; z < chunk.ChunkSize; z++) { for (int y = 0; y < chunk.ChunkSize; y++) { for (int x = 0; x < chunk.ChunkSize; x++) { BaseBlock block = blocks[x, y, z]; if (block.CanBeRendered) { vertCount += block.GetDrawData().Vertices.Length; trianglesCount += block.GetDrawData().Triangles.Length; } } } } return(new RawMesh { Vertices = new Vector3[vertCount], Uv = new Vector2[vertCount], Triangles = new int[trianglesCount] }); }
private void AppendFace(RawMesh mesh, BaseBlock block, Face face, int xPos, int yPos, int zPos) { if (!block.CanBeRendered) { return; } int faceOrder = face.GetHashCode(); RawMesh tMesh = block.GetDrawData(); int sideCount = block.Sides; int faceVertexCount = block.VertexCount / sideCount; int faceIndicesCount = block.Indices / sideCount; int faceUvCount = block.UvCount / sideCount; //vertex for (int offset = 0; offset < faceVertexCount; offset++) { mesh.Vertices[mesh.vertexCount + offset] = tMesh.Vertices[faceOrder * 4 + offset] + new Vector3(xPos, yPos, zPos); } //triangle for (int offset = 0; offset < faceIndicesCount; offset++) { mesh.Triangles[mesh.trianglesCount + offset] = tMesh.Triangles[faceOrder * 6 + offset] + mesh.vertexCount - faceOrder * 4; } //uvs //todo doesnt support multiple face textures for (int offset = 0; offset < faceUvCount; offset++) { mesh.Uv[mesh.uvCount + offset] = tMesh.Uv[faceOrder * 4 + offset]; } mesh.vertexCount += 4; mesh.trianglesCount += 6; mesh.uvCount += 4; }
//-------------------------------------------------------------------------- virtual protected void CreateBlock(int xOffset, int yOffset) { BaseBlock block = FigureGenerator.CreateBlock(GetBlockType()); block.transform.parent = blockContainer.transform; blocks.Add(block); block.transform.localPosition = new Vector3(xOffset * TetrisConst.BRICK_SIZE, -yOffset * TetrisConst.BRICK_SIZE); }
public void SetBlock(Vector3Int absPos, BaseBlock block) { Vector3Int localPos = GetBlockLocalPos(absPos); //Debug.Log("zmieniono blok na pozycji: " + localPos.ToString()); LoadedChunkObjects[GetChunkPos(absPos)].chunkObject.GetComponent <ChunkBehaviour>().Chunk.SetBlock(localPos, block); }
public MoveBlock(BaseBlock block,MainViewModel Main) { this.Main = Main; this.block = block; timer = new Timer(700); timer.Elapsed +=new ElapsedEventHandler(run); timer.Start(); }
/// <summary> /// Gets the CGG term. /// </summary> /// <param name="block">The block.</param> /// <param name="data">The <seealso cref="SimulationData"/> data.</param> /// <returns></returns> public static double GetCGG(this BaseBlock block, SimulationData data) { CGG = 1 / (Global.a * data.timeStep) * (block.Vp[1] / block.Bg[1] - (block.Vp[1] / block.Bo[1]) * block.Rso[1]); //bhp = Well.WellData.calculatePwf(block, block.P[1], block.Kro[2], block.viscosityOil[1], block.Bo[1]); //temp = (Well.WellData.calculateFlow_Rate(block.P[1], bhp, block.Krg[2], block.viscosityGas[1], block.WI, block.Bg[1]) - block.q_gas[1]) / (block.Sg[2] - block.Sg[1]); return(CGG + temp); }
public void SetBlock(BaseBlock newPosition) { currentBlock = newPosition; Vector3 blockposition = currentBlock.transform.position; blockposition.y += 0.5f; this.transform.position = blockposition; }
public override bool CanAttachBlock(BaseBlock block) { if (!(block is StatementBlock)) { return(false); } return(base.CanAttachBlock(block)); }
private void Block_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { e.Handled = true; BaseBlock target = sender as BaseBlock; LastSelectedBlock = target; StartBlockMove(target, e.GetPosition(target)); }
private bool BlockPassibleForPlayer(BaseBlock block) { if (block.Type == BlockTypes.Air) { return(true); } return(false); }
public override void Start() { base.Start(); block = BlockManager.Instance.GetBlockAtPosition(transform.position); if (!block) { Destroy(); } }
internal void TryToMove(BaseBlock baseBlock) { int distance = 0; distance = (int)Mathf.Abs(baseBlock.Position.x - currentBlock.Position.x) + (int)Mathf.Abs(baseBlock.Position.y - currentBlock.Position.y); if (distance <= stats.movement) { SetBlock(baseBlock); } }
private BaseBlock SetBlockEvent(BaseBlock block) { block.GiveFeedback += Block_GiveFeedback; block.PreviewMouseMove += Block_PreviewMouseMove; block.QueryContinueDrag += Block_QueryContinueDrag; block.PreviewMouseLeftButtonUp += Block_PreviewMouseLeftButtonUp; block.PreviewMouseLeftButtonDown += Block_PreviewMouseLeftButtonDown; return(block); }
// allocates memory for each array in the block according to the number of neighbor blocks. // arraySize = the number of neighbor blocks. private void AllocateBlockArrays(BaseBlock block, int arraySize) { // boundary length list is only used for well equivalent radius calculations. // only sideways boundaries are considered. block.boundaryLengthList = new double[arraySize - 2]; block.transmissibility_terms_oil = new double[arraySize]; block.transmissibility_terms_water = new double[arraySize]; block.transmissibility_terms_gas = new double[arraySize]; block.deltaXList = new double[arraySize]; block.areaList = new double[arraySize]; }
// 각자 맞는 블럭으로 오버로딩 private void ConnectBlock(BaseBlock block, MouseEventArgs e) { if (SelectedBlock is StatementBlock) { ConnectBlock(SelectedBlock as StatementBlock, e); } else if (SelectedBlock is ObjectBlock) { ConnectBlock(SelectedBlock as ObjectBlock, e); } }
private void DestroyGrid() { for (int i = 0; i < currentMap.Count; i++) { BaseBlock block = currentMap[i]; currentMap[i] = null; Destroy(block.gameObject); } currentMap.Clear(); currentMap = new List <BaseBlock>(); }
public void SetBlock(int x, int y, int z, BaseBlock block, bool updatechunk) { if (BlockMap[x, y, z] != block) //If the target block isn't already what you want it to be { BlockMap[x, y, z] = block; //Then set the block to be that type if (updatechunk) { CreateVertices(); } } }
/// <summary> /// Gets the CGP term. /// </summary> /// <param name="block">The block.</param> /// <param name="data">The <see cref="SimulationData"/> data.</param> /// <returns></returns> public static double GetCGP(this BaseBlock block, SimulationData data) { CGP = 1 / (Global.a * data.timeStep) * (((block.phi_dash() / block.Bo[0] + block.Vp[1] * block.FVF_dash(Global.Phase.Oil)) * block.Rso[0] + (block.Vp[1] / block.Bo[1]) * block.Rso_dash()) * (1 - block.Sg[0]) + (block.phi_dash() / block.Bg[0] + block.Vp[1] * block.FVF_dash(Global.Phase.Gas)) * block.Sg[0]); //temp = (block.Rso[2] - block.Rso[1]) / (block.P[2] - block.P[1]) * block.q_oil[1]; //bhp = Well.WellData.calculatePwf(block, block.P[2], block.Kro[1], block.viscosityOil[2], block.Bo[2]); //temp += (Well.WellData.calculateFlow_Rate(block.P[2], bhp, block.Krg[1], block.viscosityGas[2], block.WI, block.Bg[2]) - block.q_gas[1]) / (block.P[2] - block.P[1]); return(CGP + temp); }
private bool OptimizeBlock(BaseBlock bblock, ValueSet vals) { bool ret = false; foreach (var line in bblock.Code) { if (Update(line, vals)) { ret = true; } } return(ret); }
public override bool Optimize(BaseBlock bblock) { bool answer = false; // Индикатор того, что хоть один раз, но оптимизация была выполнена. foreach (var line in bblock.Code) // Проход по всему базовому блоку. { if (ThreeAddrOpType.Computable.Contains(line.OpType)) { answer |= Recognize(line); // Выполняем оптимизацию } } return(answer); }
public void EncodeBlock_BaseBlock() { var input = new BaseBlock(1) { PositionX = 44, PositionY = 77 }; var expected = "1,1,2,44,3,77"; var actual = ObjectParser.EncodeBlock(input); Assert.AreEqual(expected, actual); }
public void SetVelocityScale(BaseBlock currentBlock) { if (currentBlock is FluidBlock) { myRigidbody.drag = 3f; velocityScale = 0.5f; } else { myRigidbody.drag = 0.01f; velocityScale = 1f; } }
/// <summary> /// Finish movement /// </summary> /// <param name="S"></param> /// <param name="E"></param> public void Block_OnMouseUp(object S, MouseEventArgs E) // Stop moving { if (!(S is BaseBlock)) { return; // PatternMatchingIsAUsefulTool } //Debug.WriteLine("Mouse Up"); MovementTicker.Stop(); ToMove = null; // Drop the block SContainer_Workspace.Panel2.Refresh(); // Redraw }
#pragma warning restore IDE0058 public void AttackBlock(BaseBlock target) { if (target && (Time.time > attackCooldownFinishTime)) { if (inventory.HasItemType(target.toolTypeNeeded)) { target.Damage(attackDamage * 5); return; } target.Damage(attackDamage); } }
// ReSharper disable once SuggestBaseTypeForParameter private void AddBlock(BaseBlock ToAdd) // Add block to panel { var X = SContainer_Workspace.Panel2.Width / 2 - ToAdd.Width / 2; // Add in the middle var Y = SContainer_Workspace.Panel2.Height / 2 - ToAdd.Height / 2; ToAdd.Location = new Point(X, Y); SContainer_Workspace.Panel2.SuspendLayout(); // Stop layout SContainer_Workspace.Panel2.Controls.Add(ToAdd); // Add the block SContainer_Workspace.Panel2.ResumeLayout(true); // Continue ToAdd.Refresh(); // Redraw }
public MainViewModel() { Paused =false; MoveBrickCommand = new RelayCommand<KeyEventArgs>(Move); Bricks = new ObservableCollection<Brick>(); //Data-structure containing the building pieces bricks. UndoCommand = new RelayCommand(undoRedoController.Undo, undoRedoController.CanUndo); RedoCommand = new RelayCommand(undoRedoController.Redo, undoRedoController.CanRedo); // while (!Paused) // { BaseBlock block = new LineBlock(); currentBlock = block; foreach (Brick child in block.Block) { Bricks.Add(child); } // Bricks.Remove(brick1); BlockMover = new MoveBlock(currentBlock,this); // } }
private BaseBlock CreateTestBaseBlock(int totalQuestions, int totalsubblocks) { BaseBlock baseBlock = new BaseBlock(); baseBlock.Name = "Bloco 1" + Guid.NewGuid().ToString().Substring(0, 4); baseBlock.BaseSubBlocks = new List<BaseSubBlock>(); for (int i = 0; i < totalsubblocks; i++) { baseBlock.BaseSubBlocks.Add(CreateTestBaseSubBlock(i, totalQuestions)); } return baseBlock; }
public BlockView(IGameObject gameObject,IViewManager viewManager) { _viewManager = viewManager; _gameObject = (BaseBlock)gameObject; }