// helper to make hole public void MakeHole() { // does nothing if already has hole if (m_hasHole) { return; } // initialize hole state and display m_hasHole = true; m_holeDisplay = WallDisplay.GetFromPool(GameManager.s_gameSettings.wallDisplayPrefab); m_holeDisplay.Initialize(m_root.transform, new Vector2(m_position.x, m_position.y - 1), GameManager.s_gameSettings.holeSprite); }
// helper to pool displays public void Pool() { // pool wall display m_wallDisplay.Pool(); m_wallDisplay = null; // pool hole display if (m_hasHole) { m_holeDisplay.Pool(); m_holeDisplay = null; } }
// constructor public Cell(WallState wallState, Vector2 position, GameObject root) { // initialize position m_position = position; m_root = root; // initialize wall state and display m_wallState = wallState; m_wallDisplay = WallDisplay.GetFromPool(GameManager.s_gameSettings.wallDisplayPrefab); m_wallDisplay.Initialize(m_root.transform, m_position, GameManager.s_gameSettings.GetWallSprite(m_wallState)); // start out with no hole m_hasHole = false; m_holeDisplay = null; }