/// <summary> /// Instantiate a preview version of the prefab block /// </summary> private void InstantiatePreview(Vector3 position) { //Instantiate the prefab Preview = Instantiate(GrabbedBlock, position, Quaternion.Euler(Rotation)).gameObject.AddComponent <PreviewBlock>(); //Change the layer, so it doesn't get tagged by raycasts Preview.gameObject.layer = 0; //Make the material 50% transparent StandardShaderUtils.ChangeRenderMode(Preview.Material, StandardShaderUtils.BlendMode.Transparent); Color c = GrabbedBlock.Colour; c.a = 0.75f; Preview.Material.color = c; //Destroy any components that are exclusive to Blocks Block b = Preview.GetComponent <Block>(); b.Toggle(); Destroy(b); foreach (Transform t in Preview.transform) { Destroy(t.gameObject); } if (GrabbedBlock.name == Preview.name) { print("ash"); } }
public void CreateNextBlock() { if (boardSize == 5) { previewBlockL = ((GameObject)Instantiate(previewBlockRes, previewPosBlock5L, Quaternion.identity)).GetComponent <PreviewBlock> (); previewBlockR = ((GameObject)Instantiate(previewBlockRes, previewPosBlock5R, Quaternion.identity)).GetComponent <PreviewBlock> (); } else if (boardSize == 7) { previewBlockL = ((GameObject)Instantiate(previewBlockRes, previewPosBlock7L, Quaternion.identity)).GetComponent <PreviewBlock> (); previewBlockR = ((GameObject)Instantiate(previewBlockRes, previewPosBlock7R, Quaternion.identity)).GetComponent <PreviewBlock> (); } else if (boardSize == 9) { previewBlockL = ((GameObject)Instantiate(previewBlockRes, previewPosBlock9L, Quaternion.identity)).GetComponent <PreviewBlock> (); previewBlockR = ((GameObject)Instantiate(previewBlockRes, previewPosBlock9R, Quaternion.identity)).GetComponent <PreviewBlock> (); } int newColor = Random.Range(2, 8 + difficulty); int wildCardRoll = Random.Range(0, 100); if (wildCardRoll < 4) { newColor = 1; } int newShape = Random.Range(1, 7 + difficulty); previewBlockL.SetBlockProperties(newColor, newShape); previewBlockR.SetBlockProperties(newColor, newShape); nextBlock = previewBlockL; nextBlock.SetExpire(spawnSpeed); }
private PreviewBlock GeneratePreviewBlockFromBlock(Block blck) { bool hasEvent; using (var ctx = new ApplicationDbContext()) { hasEvent = ctx.GameEvents.Any(e => e.BlockID == blck.ID); } PreviewBlock output = new PreviewBlock ( blck.ID, blck.Name[0], blck.Description, hasEvent, blck.PosX, blck.PosY ); if (blck.TypeOfBlock == BlockType.Wall) { output.Icon = '\u2588'; } return(output); }
public BlockEditPageViewModel(PageData page, IContent content) { previewBlock = new PreviewBlock(page, content); CurrentPage = page as SitePageData; }
public BlockEditPageViewModel(PageData page, IContent content) { PreviewBlock = new PreviewBlock(page, content); CurrentPage = (SitePageData)page; }
public void CreateNextBlock () { if (boardSize == 5) { previewBlockL = ((GameObject)Instantiate (previewBlockRes, previewPosBlock5L, Quaternion.identity)).GetComponent<PreviewBlock> (); previewBlockR = ((GameObject)Instantiate (previewBlockRes, previewPosBlock5R, Quaternion.identity)).GetComponent<PreviewBlock> (); } else if (boardSize == 7) { previewBlockL = ((GameObject)Instantiate (previewBlockRes, previewPosBlock7L, Quaternion.identity)).GetComponent<PreviewBlock> (); previewBlockR = ((GameObject)Instantiate (previewBlockRes, previewPosBlock7R, Quaternion.identity)).GetComponent<PreviewBlock> (); } else if (boardSize == 9) { previewBlockL = ((GameObject)Instantiate (previewBlockRes, previewPosBlock9L, Quaternion.identity)).GetComponent<PreviewBlock> (); previewBlockR = ((GameObject)Instantiate (previewBlockRes, previewPosBlock9R, Quaternion.identity)).GetComponent<PreviewBlock> (); } int newColor = Random.Range (2, 8 + difficulty); int wildCardRoll = Random.Range (0, 100); if (wildCardRoll < 4) { newColor = 1; } int newShape = Random.Range (1, 7 + difficulty); previewBlockL.SetBlockProperties (newColor, newShape); previewBlockR.SetBlockProperties (newColor, newShape); nextBlock = previewBlockL; nextBlock.SetExpire (spawnSpeed); }