Example #1
0
        void ResetMap(LevelEditor levelEditor)
        {
            var parentTransform = levelEditor.nodeRepository.transform;

            while (parentTransform.childCount != 0)
            {
                DestroyImmediate(parentTransform.GetChild(0).gameObject);
            }
        }
Example #2
0
        void UpdateAllNodesInMap(LevelEditor levelEditor)
        {
            var nodeEditorsParent = levelEditor.gameObject.transform.GetChild(0);

            foreach (Transform node in nodeEditorsParent)
            {
                var nodeDataModel = node.gameObject.GetComponent <NodeDataModel>();
                UpdateNode(nodeDataModel);
            }
        }
Example #3
0
        void UpdateReferences(LevelEditor levelEditor)
        {
            foreach (var nodeObject in levelEditor.nodeMatrixFlattened)
            {
                var nodeData    = nodeObject.GetComponent <NodeDataModel>();
                var generalData = levelEditor.editorNode.GetComponent <NodeDataModel>();

                nodeData.rockPrefab    = generalData.rockPrefab;
                nodeData.bramblePrefab = generalData.bramblePrefab;
            }
        }
Example #4
0
        void GenerateBaseMap(LevelEditor levelEditor)
        {
            levelEditor.InitMatrix();

            ResetMap(levelEditor);

            for (var i = 0; i < levelEditor.rows; i++)
            {
                for (var j = 0; j < levelEditor.columns; j++)
                {
                    var newNode = Instantiate(levelEditor.editorNode, new Vector3(j, 0, i) * levelEditor.tileOffset, Quaternion.identity, levelEditor.gameObject.transform);
                    newNode.name             = $"Node{i}_{j}";
                    newNode.transform.parent = levelEditor.nodeRepository.transform;
                    newNode.gameObject.GetComponent <NodeDataModel>().SetPosition(i, j);

                    levelEditor.nodeMatrixFlattened[FlattenMatrix(i, j, levelEditor.columns)] = newNode;
                }
            }
        }