private StairModel CreateStair() { // TODO: Refactor this var availableTiles = m_tilesModel.Where(_s => _s.TeleporterModel == null && _s.PositionInBoard<(m_tilesModel.Count()-m_boardConfiguration.HorizontalTiles*2f)); TileModel startTile = availableTiles.ElementAt(UnityEngine.Random.Range(0, availableTiles.Count())); var posibleTiles = m_tilesModel.Where(_s => _s.TeleporterModel == null && _s.PositionInBoard > (startTile.PositionInBoard + m_boardConfiguration.HorizontalTiles)); int randomElementIndex = UnityEngine.Random.Range(0, posibleTiles.Count()); TileModel endTile = posibleTiles.ElementAt(randomElementIndex); StairModel stairModel = new StairModel(startTile, endTile); startTile.TeleporterModel = stairModel; endTile.TeleporterModel = stairModel; return stairModel; }
public void SetModel(StairModel _tileModel) { m_stairModel = _tileModel; }
private void SetupStairView(StairModel _stairModel) { if (m_prefabStairView == null) { m_prefabStairView = Resources.Load<GameObject>(STAIR_PREFAB_NAME); } GameObject stairGameObject = Instantiate(m_prefabStairView); stairGameObject.GetComponent<Transform>().SetParent(transform); stairGameObject.name = typeof(StairView).Name; StairController stairController = stairGameObject.GetComponent<StairController>(); stairController.SetModel(_stairModel); stairController.Initialize(); StairView stairView = stairGameObject.GetComponent<StairView>(); stairView.Initialize(stairController); m_StairsView.Add(stairView); }