Пример #1
0
    private void ReturnToRuin(ConstructionSpace space, GameObject buildingLogic)
    {
        Tilemap ruinShape = space.Data.RuinShape;

        if (Map != null)
        {
            foreach (Vector3Int ruinShapePosition in ruinShape.cellBounds.allPositionsWithin)
            {
                Vector3Int mapPosition = space.LocalOrigin + ruinShapePosition;
                Map.SetTile(mapPosition, ruinShape.GetTile(ruinShapePosition));
                _positionToBuildingLogic.Remove(mapPosition);
            }
            audioManager.PlayBuildingDestroyed();
        }

        if (buildingLogic != null)
        {
            _activeBuildingLogic.Remove(buildingLogic);
            OnHealthBonusMayHaveChanged();
        }

        if (_constructionSpaceToWallSprite.ContainsKey(space))
        {
            Destroy(_constructionSpaceToWallSprite[space]);
            _constructionSpaceToWallSprite.Remove(space);
        }

        GameObject ruinLogic = _constructionSpaceToRuinLogic[space];

        if (ruinLogic != null)
        {
            ruinLogic.SetActive(true);
        }
    }