private void SpawnNode(LevelAsset.SubPuzzleNode subPuzzleNode, Vector2 pos)
    {
        var nodeGameObject = GameObject.Instantiate(levelEditorNode);

        nodeGameObject.transform.parent        = rootContainer.transform;
        nodeGameObject.transform.localPosition = new Vector2(pos.x, pos.y);
        nodeGameObject.GetComponent <LevelEditorNode> ().nodeId = subPuzzleNode.id;
        nodeDictionary.Add(subPuzzleNode.id, nodeGameObject.GetComponent <LevelEditorNode> ());

        int i = 0;

        foreach (var puzzlePivotAsset in subPuzzleNode.puzzlePivots)
        {
            var puzzlePivotObject = GameObject.Instantiate(levelEditorPuzzlePivot);
            var puzzlePivot       = puzzlePivotObject.GetComponent <LevelEditorPuzzlePivot> ();
            puzzlePivot.transform.parent        = rootContainer.transform;
            puzzlePivot.transform.localPosition = new Vector3(pos.x + 0.3f * i, pos.y - 0.3f * i, i);
            puzzlePivot.parent = nodeGameObject.GetComponent <LevelEditorNode> ();
            nodeGameObject.GetComponent <LevelEditorNode> ().puzzlePivots.Add(puzzlePivot);
            i++;
        }

        if (nodeAssetDictionary.ContainsKey(subPuzzleNode.id))
        {
            float x = pos.x - 0.75f;
            float y = pos.y - 1.5f;
            foreach (var node in nodeAssetDictionary[subPuzzleNode.id])
            {
                SpawnNode(node, new Vector2(x, y));
                x += 1.5f;
            }
        }
    }
示例#2
0
    public void Initialize(GameBoard gameBoard, string id, int layer, Vector2 sizeOfPicture)
    {
        this.gameBoard            = gameBoard;
        subPuzzleButton.gameBoard = gameBoard;
        subPuzzleButton.subPuzzle = this;
        subPuzzleLayer            = layer;
        this.sizeOfPicture        = sizeOfPicture;
        this.id   = id;
        nodeAsset = LevelAssetHelper.GetNodeAsset(gameBoard.nodeAssetDictionary, id);



        textureSize = new Vector2(sizeOfPicture.x, sizeOfPicture.y) * 120;
        backgroundQuad.transform.localScale = new Vector3(sizeOfPicture.x, sizeOfPicture.y, 1);
        puzzleCameraTexture           = new RenderTexture((int)textureSize.x, (int)textureSize.y, 24, renderTextureFormat);
        puzzleCamera.targetTexture    = puzzleCameraTexture;
        puzzleCamera.orthographicSize = sizeOfPicture.y / 2;
        collectableHelper             = new CollectableHelper(puzzleCameraCollectable, sizeOfPicture, textureSize, renderTextureFormat, textureFormat);
    }