private void SetupLayer() { if (_currMap.transform.childCount == 0) { _currLayer = _currMap.CreateLayer("Ground", true); Undo.RegisterCreatedObjectUndo(_currLayer.gameObject, _currLayer.name); _sortedLayer = new List <SrpgLayer>(); _sortedLayer.Add(_currLayer); } else { _sortedLayer = _currMap.GetSortedLayers(); if (_currLayer == null) { _currLayer = _currMap.GetLastestEditedLayer(); } } }
void Start() { //----- init configuration and check ----- if (!InitConfig()) { return; } if (_unitFitMode == UnitFitMode.Unknown) { Debug.LogError("unitFitMode is unknown"); return; } if (_moveMethod == MoveMethod.Unknown) { Debug.LogError("moveMethod is unknown"); return; } //----- init map & layers and check ----- if (!InitMap()) { return; } if (_map == null) { Debug.LogError("map is null"); return; } List <SrpgLayer> layers = _map.GetSortedLayers(); if (layers.Count == 0) { Debug.LogError("no layers"); return; } if (_groundLayer == null) { _groundLayer = layers[layers.Count - 1]; } // unit layer & cell layer z index 수정 필요 if (_unitLayer == null) { _unitLayer = _map.CreateLayer("Units"); } // magic number 5!? int cellLayerZ = _unitLayer.zIndexStart - 5; _cellLayer = _map.CreateLayer("Cells", false, cellLayerZ); foreach (SrpgLayer layer in layers) { if (layer.touchable) { SrpgTile[] tiles = layer.GetComponentsInChildren <SrpgTile>(); foreach (SrpgTile tile in tiles) { tile.clicked += OnTileClicked; } } } //----- init units and check ----- if (!InitUnits()) { return; } Debug.Assert(_playerUnits.Count > 0 && _enemyUnits.Count > 0); StartGame(); }