Exemple #1
0
    public void SpawnPiece(MazeNode node, GameObject cells, int sectionID)
    {
        Vector3 location = new Vector3(node.Col * 6 + 8, node.Floor * 30, node.Row * 6 + 8);

        GameObject obj = Instantiate(Resources.Load(node.GetPrefabName()), location, node.GetRotation()) as GameObject;

        obj.transform.parent = cells.transform;
        node.floorPrefab     = obj.transform.GetChild(0).gameObject;
        GameObject cellObj = Instantiate(Resources.Load("Prefabs/Level/CellLog"), location, node.GetRotation()) as GameObject;

        cellObj.transform.parent = obj.transform;
        CellLog cellLog = cellObj.GetComponent <CellLog>();

        cellLog.Row    = node.Row;
        cellLog.Col    = node.Col;
        cellLog.CellID = AnalyticsManager.AddCell(sectionID, node.Col, node.Row);
        obj.name       = "Cell " + cellLog.CellID;

        if (DebugLabelsOn)
        {
            GameObject textObj = Instantiate(Resources.Load("Prefabs/Level/CellTextPrefab"), location + new Vector3(0, 0.5f, -1), new Quaternion()) as GameObject;
            textObj.transform.parent = obj.transform;

            TextMesh t = textObj.GetComponentInChildren <TextMesh>();
            if (t != null)
            {
                t.text = "R: " + node.Row + " C: " + node.Col;
            }

            textObj = Instantiate(Resources.Load("Prefabs/Level/CellTextPrefab"), location + new Vector3(0, 0.5f, 0), new Quaternion()) as GameObject;
            textObj.transform.parent = obj.transform;

            t = textObj.GetComponentInChildren <TextMesh>();
            if (t != null)
            {
                t.text = "P" + piecesSpawned++;
            }
        }
    }