IEnumerator SendCheck(WWW data) { yield return(data); // Wait until the download is done if (data.error == null) { BlockManager m_blockManager = GameObject.Find("GameManager").GetComponent <BlockManager>(); ScoreUI scoreUI = GameObject.Find("ScoreUI").GetComponent <ScoreUI>(); List <Vector2> listPos = SaveNLoad.GetInstance.GetListPos(); JsonData mapData = JsonMapper.ToObject(data.text); GameObject goBlockManager = new GameObject("BlockManager"); m_iPreScore = int.Parse(mapData["bestScore"]["score"].ToString()); scoreUI.SetScore(m_iPreScore); Debug.Log(mapData.Count); for (int i = 0; i < mapData.Count; ++i) { m_blockManager.CreateBlock(goBlockManager , listPos[int.Parse(mapData["mapData"][i]["iIndex"].ToString())] , int.Parse(mapData["mapData"][i]["blockID"].ToString()) , int.Parse(mapData["mapData"][i]["itemID"].ToString())); //아이템 ID 넘길것 } } else { Debug.Log("Net Load Failed"); } }
private void Start() { for (int i = 0; i < puzzleNumber; i++) { Block block = blockManager.CreateBlock(transform.position + Vector3.up * 3.5f * houseFloor + Vector3.left * 3f + (Vector3.right * 3.0f) * i, blockManager.blockData[Random.Range(0, blockManager.blockData.Length)]); block.GetComponent <MeshRenderer>().material = blockMat; block.GetComponent <MeshRenderer>().material.SetColor("_EmissionColor", block.blockData.color * 3f); puzzleBlocks.Add(block); puzzleBlocks[i].stoppd = true; } playerPuzzles.AddRange(playerPanel.GetComponentsInChildren <InputPuzzle>(true)); StartCoroutine(UpdateTime()); }
void MouseControl() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit = new RaycastHit(); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray.origin, ray.direction, out hit)) { Vector3 pos = new Vector3(Mathf.Round(hit.point.x), Mathf.Ceil(hit.point.y), Mathf.Round(hit.point.z)); blockManager.CreateBlock(null, pos); } } else if (Input.GetMouseButtonDown(1)) { } }
public static void ReadFromXml(XmlElement xmlElement, BlockManager blockManager, Block parent) { int id = int.Parse(xmlElement.Attributes["child_id"].Value); if (parent.subBlocks[id] != null) { return; } int level = int.Parse(xmlElement.Attributes["level"].Value); if (level != parent.Level - 1) { return; } bool issolid = xmlElement.HasAttribute("material_id"); int material = 0; if (issolid) { material = int.Parse(xmlElement.Attributes["material_id"].Value); } Block block = blockManager.CreateBlock(level, issolid); block.transform.position = parent.ChildPositions[id]; if (issolid) { block.SetPaletteMaterial(blockManager.palette, material); } parent.subBlocks[id] = block; foreach (XmlElement e in xmlElement.ChildNodes) { ReadFromXml(e, blockManager, block); } }
// Use this for initialization void Start() { for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { grid[x, y] = new GridElement(); grid[x, y].State = GridElement.ElementState.Empty; grid[x, y].Type = GridElement.ElementType.Empty; grid[x, y].Element = null; } } int shortColumn = Random.Range(0, Width); for (int x = Width - 1; x >= 0; x--) { int height = (shortColumn == x ? 2 : 7) + Random.Range(0, 2); if (height - 1 > topOccupiedRow) { topOccupiedRow = height - 1; } for (int y = height - 1; y >= 1; y--) { int type; do { type = Random.Range(0, Block.TypeCount); if (!(StateAt(x, y + 1) == GridElement.ElementState.Empty) && BlockAt(x, y + 1).Type == type) { continue; } if (x == Grid.Width - 1) { break; } if (!(StateAt(x + 1, y) == GridElement.ElementState.Empty) && BlockAt(x + 1, y).Type == type) { continue; } break; } while (true); // setup creep creation state if (y == 2) { BlockManager.SecondToLastNewRowTypes[x] = type; } if (y == 1) { BlockManager.LastNewRowTypes[x] = type; } // create the block BlockManager.CreateBlock(x, y, type); } } topEffectiveRow = topOccupiedRow; }