private void btnAdd_Click(object sender, EventArgs e) { int count=0; int discardCount=0; bool Good; Block newBlock; do { do { newBlock = new Block(trackBar1.Value); Good = true; foreach (Block value in blockList) { if (newBlock.Equals(value)&&discardCount<1000) { Good = false; discardCount++; ProgressBar1.Value = discardCount; ProgressBar1.Refresh(); } } } while(!Good); if (discardCount < 1000) { blockList.Add(newBlock); newBlock.AddBlock(); count++; Block.blockSwitch = false; } } while (count < 25 && discardCount <1000); }
void DrawButtons() { if (EditorTools.DrawHeader("ADD ")) { Block block = target as Block; if (GUILayout.Button("Add Empty")) { block.AddBlock(BlockType.EMPTY); EditorUtility.SetDirty(block); } if (GUILayout.Button("Add H")) { block.AddBlock(BlockType.H); EditorUtility.SetDirty(block); } if (GUILayout.Button("Add HHH")) { block.AddBlock(BlockType.HHH); EditorUtility.SetDirty(block); } if (GUILayout.Button("Add V")) { block.AddBlock(BlockType.V); EditorUtility.SetDirty(block); } if (GUILayout.Button("Add VVV")) { block.AddBlock(BlockType.VVV); EditorUtility.SetDirty(block); } if (GUILayout.Button("Add X")) { block.AddBlock(BlockType.X); EditorUtility.SetDirty(block); } if (GUILayout.Button("Add NX")) { block.AddBlock(BlockType.NX); EditorUtility.SetDirty(block); } if (GUILayout.Button("Update Brick Resource")) { block.UpdateBrickResource(); EditorUtility.SetDirty(block); } GUILayout.Space(10f); // GUILayout.Button ("Add Brick"); GUILayout.Space(10f); if (GUILayout.Button("DelateAll")) { block.DeleteAllChild(); EditorUtility.SetDirty(block); } } }
void AddInMap(Block block, Vector3 locPot) { block_Root.AddBlock(block); block.transform.parent = block_Root.transform; block.M_Loc_CurPot = locPot; block.M_Loc_StartPot = locPot; block.IReset(); block.InitParam(); block.gameObject.SetActive(true); curBlock = block; addBlockCount++; Debug.Log("add in map : locPot=" + locPot); }
public void AddBlock(Block block) { ActiveBlock.AddBlock(block); }
/// <summary> /// Clone object (blocks) /// </summary> /// <param name="newSuperBlock">New block</param> /// <param name="oldSuperBlock">Old block</param> void CloneObjectRecursive(Block newSuperBlock, Block oldSuperBlock) { foreach (var b in oldSuperBlock.SubBlocks) { if (b is Constructor) { newSuperBlock.AddBlock(new Constructor(newSuperBlock, (b as Constructor).Parameters)); CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b); } else if (b is Method) { newSuperBlock.AddBlock(new Method(newSuperBlock, (b as Method).Name, (b as Method).ReturnType, (b as Method).Parameters)); CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b); } else if (b is VariableDeclarationStatement) { newSuperBlock.AddBlock(new VariableDeclarationStatement(newSuperBlock, (b as VariableDeclarationStatement).Name, (b as VariableDeclarationStatement).Type)); } else if (b is AssignStatement) { List<IExpression> newExpressions = CloneExpressions((b as AssignStatement).Expressions, newSuperBlock); newSuperBlock.AddBlock(new AssignStatement(newSuperBlock, (b as AssignStatement).Name, (b as AssignStatement).Type, newExpressions)); } else if (b is PrintStatement) { List<IExpression> newExpressions = CloneExpressions((b as PrintStatement).Expressions, newSuperBlock); newSuperBlock.AddBlock(new PrintStatement(newSuperBlock, newExpressions)); } else if (b is ConditionStatement) { List<IExpression> newLeft = CloneExpressions((b as ConditionStatement).Left, newSuperBlock); List<IExpression> newRight = CloneExpressions((b as ConditionStatement).Right, newSuperBlock); newSuperBlock.AddBlock(new ConditionStatement(newSuperBlock, newLeft, newRight, (b as ConditionStatement).OperatorType)); CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b); } else if (b is ElseIfStatement) { List<IExpression> newLeft = CloneExpressions((b as ElseIfStatement).Left, newSuperBlock); List<IExpression> newRight = CloneExpressions((b as ElseIfStatement).Right, newSuperBlock); newSuperBlock.AddBlock(new ElseIfStatement(newSuperBlock, newLeft, newRight, (b as ElseIfStatement).OperatorType)); CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b); } else if (b is ElseStatement) { newSuperBlock.AddBlock(new ElseStatement(newSuperBlock)); CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b); } } }