void SetBlock(Vector3 p, Block b) { RaycastHit hit; int i = 0; Chunck chunck = Chunck.GetChunck(Mathf.FloorToInt(p.x), Mathf.FloorToInt(p.y), Mathf.FloorToInt(p.z)); Vector3 localPos = chunck.transform.position - p; if (b == null) { map = chunck.GetBlock(p); if (map == null) { map = Block.getBlock(BlockList.Blocks[tmp].BlockName); } item = GetItem(map); if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 7f, lm)) { if (hit.transform.gameObject.tag != "Obje") { if (hit.transform.gameObject.tag != "Tree") { if (hit.transform.gameObject.tag != "Player") { GameObject obje = Instantiate(Resources.Load <GameObject>(map.BlockName), BlockHighlight.transform.position + new Vector3(0, 0.5f, 0), Quaternion.identity) as GameObject; obje.GetComponent <Obje>().item = item; Debug.Log("Obje = " + obje.transform.position + "Chunck Pos = " + chunck.transform.position + "P=" + p + "Local Pos=" + localPos); } } } } } map = null; if ((Mathf.FloorToInt(localPos.x) * -1) == (Chunck.Width)) { Chunck c = Chunck.GetChunck(Mathf.FloorToInt(p.x + 5), Mathf.FloorToInt(p.y), Mathf.FloorToInt(p.z)); if (c == null) { return; } c.SetBlock(p + new Vector3(+1, 0, 0), b); } else { Chunck c = Chunck.GetChunck(Mathf.FloorToInt(p.x - 5), Mathf.FloorToInt(p.y), Mathf.FloorToInt(p.z)); if (c == null) { return; } c.SetBlock(p + new Vector3(+1, 0, 0), b); } chunck.SetBlock(p + new Vector3(+1, 0, 0), b); }
static public void UpdateChunckBlocks(Chunck chunck) { chunck.SetBlock(); }