4 files modified
4 files added
885 ■■■■■ changed files
Assets/BackgroundManager.cs 180 ●●●●● patch | view | raw | blame | history
Assets/BackgroundManager.cs.meta 11 ●●●●● patch | view | raw | blame | history
Assets/Prefabs/BackgroundAll.prefab 174 ●●●●● patch | view | raw | blame | history
Assets/Prefabs/BackgroundAll.prefab.meta 7 ●●●●● patch | view | raw | blame | history
Assets/Prefabs/Managers/UIManager.prefab 7 ●●●●● patch | view | raw | blame | history
Assets/Scenes/GameplayScene.unity 471 ●●●●● patch | view | raw | blame | history
Assets/Scripts/Managers/GameManager.cs 22 ●●●●● patch | view | raw | blame | history
Assets/Scripts/UI/Tiling.cs 13 ●●●●● patch | view | raw | blame | history
Assets/BackgroundManager.cs
New file
@@ -0,0 +1,180 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BackgroundManager : MonoBehaviour
{
    [System.Serializable]
    public class BackgroundLayer
    {
        public float yThreshold;
        public Sprite backgroundSprite;
        public float transitionDistance = 3f; // Distance over which the transition occurs
        [Range(0f, 1f)] public float parallaxEffect = 0.5f;
    }
    [SerializeField] private SpriteRenderer spriteRenderer;
    [SerializeField] private SpriteRenderer transitionRenderer; // Add this field
    [SerializeField] private BackgroundLayer[] backgroundLayers;
    [SerializeField] private Transform playerTransform; // Add this field
    private bool isTransitioning = false; // Add this field
    private Transform cameraTransform;
    private Vector3 lastCameraPosition;
    private int currentLayerIndex = 0;
    private float startPositionX;
    private float lastUpdatePlayerY = 0f; // Track the last Y position of the player
    private bool isMovingUp = false; // Track if the player is moving up
    private void Start()
    {
        cameraTransform = Camera.main.transform;
        lastCameraPosition = cameraTransform.position;
        if (spriteRenderer == null)
            spriteRenderer = GetComponent<SpriteRenderer>();
        // Set initial background based on player position
        if (backgroundLayers != null && backgroundLayers.Length > 0)
        {
            float playerY = playerTransform.position.y;
            int initialLayerIndex = 0;
            // Find the correct background layer for the player's position
            for (int i = 0; i < backgroundLayers.Length; i++)
            {
                if (playerY > backgroundLayers[i].yThreshold)
                {
                    initialLayerIndex = i;
                    break;
                }
            }
            spriteRenderer.sprite = backgroundLayers[initialLayerIndex].backgroundSprite;
            currentLayerIndex = initialLayerIndex;
        }
        if (transitionRenderer == null)
        {
            var transitionObj = new GameObject("TransitionLayer");
            transitionObj.transform.parent = transform;
            transitionObj.transform.localPosition = new Vector3(0, 0, -2); // Set Z to -2
            transitionObj.transform.localScale = Vector3.one; // Match scale
            transitionRenderer = transitionObj.AddComponent<SpriteRenderer>();
            transitionRenderer.sortingOrder = spriteRenderer.sortingOrder + 1;
            transitionRenderer.sortingLayerName = spriteRenderer.sortingLayerName; // Match background layer
        }
        transitionRenderer.color = new Color(1, 1, 1, 0); // Start fully transparent
    }
    private void Update()
    {
        // Calculate parallax movement
        Vector3 cameraDelta = cameraTransform.position - lastCameraPosition;
        Vector3 newPosition = transform.position;
        // Update X position with parallax
        float parallaxX = (cameraTransform.position.x - startPositionX) * GetCurrentParallaxEffect();
        newPosition.x = startPositionX + parallaxX;
        // Update Y position to follow camera
        newPosition.y = cameraTransform.position.y;
        transform.position = newPosition;
        // Check for background change
        float currentY = cameraTransform.position.y;
        int newLayerIndex = currentLayerIndex;
        for (int i = 0; i < backgroundLayers.Length; i++)
        {
            if (currentY > backgroundLayers[i].yThreshold)
            {
                newLayerIndex = i;
                break;
            }
        }
        if (newLayerIndex != currentLayerIndex && !isTransitioning) // Add transition check
        {
            StartCoroutine(TransitionBackground(backgroundLayers[newLayerIndex]));
            currentLayerIndex = newLayerIndex;
        }
        lastCameraPosition = cameraTransform.position;
        float lastUpdatePlayerYRounded = Mathf.Round(lastUpdatePlayerY * 10) / 10;
        float playerYRounded = Mathf.Round(playerTransform.position.y * 10) / 10;
        if (lastUpdatePlayerYRounded != playerYRounded) // Check if player has moved
        {
            if (lastUpdatePlayerYRounded > playerYRounded) // Check if player is moving down
            {
                isMovingUp = false;
            }
            else if (lastUpdatePlayerYRounded < playerYRounded) // Check if player is moving up
            {
                isMovingUp = true;
            }
            lastUpdatePlayerY = playerYRounded; // Update the last Y position
        }
    }
    private float GetCurrentParallaxEffect()
    {
        if (backgroundLayers == null || backgroundLayers.Length == 0)
            return 0.5f;
        return backgroundLayers[currentLayerIndex].parallaxEffect;
    }
    private IEnumerator TransitionBackground(BackgroundLayer newLayer)
    {
        // Check if the transition is already in progress or if the new sprite is the same as the current one
        if (isTransitioning || newLayer.backgroundSprite.name == spriteRenderer.sprite.name) yield break;
        isTransitioning = true;
        // Setup transition renderer
        transitionRenderer.sprite = newLayer.backgroundSprite;
        transitionRenderer.transform.localPosition = Vector3.zero;
        bool initialMovingUp = isMovingUp; // Store the initial moving direction
        float initialY = playerTransform.position.y;
        //bool movingUp = playerTransform.position.y > initialY;
        // Fade in new sprite over old one
        while (true)
        {
            float currentY = playerTransform.position.y;
            // Check if the direction has changed
            if (initialMovingUp != isMovingUp &&
                ((initialMovingUp ? initialY > currentY : initialY < currentY)
                ))
            {
                transitionRenderer.color = new Color(1, 1, 1, 0);
                isTransitioning = false;
                yield break;
            }
            // Calculate the alpha based on the distance moved
            float alpha = Mathf.Abs(currentY - initialY) / newLayer.transitionDistance;
            transitionRenderer.color = new Color(1, 1, 1, Mathf.Clamp01(alpha));
            // Check if transition is complete
            if (alpha >= 1f)
                break;
            yield return null;
        }
        // Ensure the final alpha value is set correctly
        transitionRenderer.color = new Color(1, 1, 1, 1);
        // Switch the sprites
        spriteRenderer.sprite = newLayer.backgroundSprite;
        transitionRenderer.color = new Color(1, 1, 1, 0);
        isTransitioning = false;
    }
}
Assets/BackgroundManager.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 718d5e9be0a4bd647adb3ea9fc7cf477
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/Prefabs/BackgroundAll.prefab
New file
@@ -0,0 +1,174 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3961525155789603524
GameObject:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  serializedVersion: 6
  m_Component:
  - component: {fileID: 6632530311481836413}
  - component: {fileID: 2210798272007827299}
  - component: {fileID: 3370728266000366833}
  - component: {fileID: 3294723280575835773}
  - component: {fileID: 316786603489862069}
  m_Layer: 11
  m_Name: BackgroundAll
  m_TagString: Untagged
  m_Icon: {fileID: 0}
  m_NavMeshLayer: 0
  m_StaticEditorFlags: 0
  m_IsActive: 1
--- !u!4 &6632530311481836413
Transform:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 3961525155789603524}
  serializedVersion: 2
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
  m_LocalPosition: {x: 0, y: 6, z: -2}
  m_LocalScale: {x: 1, y: 1, z: 1}
  m_ConstrainProportionsScale: 0
  m_Children: []
  m_Father: {fileID: 0}
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &2210798272007827299
SpriteRenderer:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 3961525155789603524}
  m_Enabled: 1
  m_CastShadows: 0
  m_ReceiveShadows: 0
  m_DynamicOccludee: 1
  m_StaticShadowCaster: 0
  m_MotionVectors: 1
  m_LightProbeUsage: 1
  m_ReflectionProbeUsage: 1
  m_RayTracingMode: 0
  m_RayTraceProcedural: 0
  m_RenderingLayerMask: 1
  m_RendererPriority: 0
  m_Materials:
  - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
  m_StaticBatchInfo:
    firstSubMesh: 0
    subMeshCount: 0
  m_StaticBatchRoot: {fileID: 0}
  m_ProbeAnchor: {fileID: 0}
  m_LightProbeVolumeOverride: {fileID: 0}
  m_ScaleInLightmap: 1
  m_ReceiveGI: 1
  m_PreserveUVs: 0
  m_IgnoreNormalsForChartDetection: 0
  m_ImportantGI: 0
  m_StitchLightmapSeams: 1
  m_SelectedEditorRenderState: 0
  m_MinimumChartSize: 4
  m_AutoUVMaxDistance: 0.5
  m_AutoUVMaxAngle: 89
  m_LightmapParameters: {fileID: 0}
  m_SortingLayerID: 1963190711
  m_SortingLayer: -2
  m_SortingOrder: 0
  m_Sprite: {fileID: 21300000, guid: 7d5be99b0261348468ab492c35422f1b, type: 3}
  m_Color: {r: 1, g: 1, b: 1, a: 1}
  m_FlipX: 0
  m_FlipY: 0
  m_DrawMode: 0
  m_Size: {x: 84.12234, y: 61.8624}
  m_AdaptiveModeThreshold: 0.349
  m_SpriteTileMode: 0
  m_WasSpriteAssigned: 1
  m_MaskInteraction: 0
  m_SpriteSortPoint: 0
--- !u!114 &3370728266000366833
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 3961525155789603524}
  m_Enabled: 0
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 051afb118ce1a7f459dc727505508d77, type: 3}
  m_Name:
  m_EditorClassIdentifier:
  cam: {fileID: 0}
  followTarget: {fileID: 0}
--- !u!114 &3294723280575835773
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 3961525155789603524}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: bff9938391d7202429e3508a7efde6eb, type: 3}
  m_Name:
  m_EditorClassIdentifier:
  offsetX: 0
  offsetY: 0
  heightSprites:
  - minHeight: -7.99
    maxHeight: 200
    sprite: {fileID: 21300000, guid: 7d5be99b0261348468ab492c35422f1b, type: 3}
  - minHeight: -200
    maxHeight: -8
    sprite: {fileID: 21300000, guid: 58a6eeb45a0e2674ab35114433129f28, type: 3}
  hasRightBuddy: 0
  hasLeftBuddy: 0
  hasTopBuddy: 0
  hasBottomBuddy: 0
  reverseScale: 1
--- !u!61 &316786603489862069
BoxCollider2D:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 3961525155789603524}
  m_Enabled: 1
  m_Density: 1
  m_Material: {fileID: 0}
  m_IncludeLayers:
    serializedVersion: 2
    m_Bits: 2048
  m_ExcludeLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_LayerOverridePriority: 0
  m_ForceSendLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_ForceReceiveLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_ContactCaptureLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_CallbackLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_IsTrigger: 1
  m_UsedByEffector: 0
  m_UsedByComposite: 0
  m_Offset: {x: 0, y: 0}
  m_SpriteTilingProperty:
    border: {x: 0, y: 0, z: 0, w: 0}
    pivot: {x: 0.5, y: 0.5}
    oldSize: {x: 25, y: 14.0625}
    newSize: {x: 84.12234, y: 61.8624}
    adaptiveTilingThreshold: 0.349
    drawMode: 0
    adaptiveTiling: 0
  m_AutoTiling: 0
  serializedVersion: 2
  m_Size: {x: 25, y: 14.0625}
  m_EdgeRadius: 0
Assets/Prefabs/BackgroundAll.prefab.meta
New file
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bcc4a9d71ad64b340b222e078e04fe7c
PrefabImporter:
  externalObjects: {}
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/Prefabs/Managers/UIManager.prefab
@@ -11,7 +11,7 @@
  - component: {fileID: 5654596948088327753}
  - component: {fileID: 6908574976455911116}
  - component: {fileID: 7748736149887392517}
  - component: {fileID: 851313892602111808}
  - component: {fileID: 6581875976717324756}
  m_Layer: 0
  m_Name: UIManager
  m_TagString: Untagged
@@ -56,7 +56,8 @@
  tilemap: {fileID: 0}
  pickups: {fileID: 0}
  fogTilemap: {fileID: 0}
  fogOfWar: {fileID: 851313892602111808}
  fogOfWar: {fileID: 6581875976717324756}
  backGroundPrefab: {fileID: 3961525155789603524, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
--- !u!114 &7748736149887392517
MonoBehaviour:
  m_ObjectHideFlags: 0
@@ -171,7 +172,7 @@
  m_DefaultActionMap: UI
  m_SplitScreenIndex: -1
  m_Camera: {fileID: 0}
--- !u!114 &851313892602111808
--- !u!114 &6581875976717324756
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
Assets/Scenes/GameplayScene.unity
@@ -599,7 +599,7 @@
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
  m_AnchorMin: {x: 1, y: 1}
  m_AnchorMax: {x: 1, y: 1}
  m_AnchoredPosition: {x: 0.000061035156, y: 0}
  m_AnchoredPosition: {x: 0, y: 0}
  m_SizeDelta: {x: 200, y: 50}
  m_Pivot: {x: 1, y: 1}
--- !u!222 &456454179
@@ -1878,6 +1878,7 @@
  - {fileID: 1049982787}
  - {fileID: 2045670860}
  - {fileID: 734382261}
  - {fileID: 2136420133}
  m_Father: {fileID: 0}
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &808172310
@@ -2906,178 +2907,11 @@
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1205505956}
  m_CullTransparentMesh: 1
--- !u!1 &1223747237
GameObject:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  serializedVersion: 6
  m_Component:
  - component: {fileID: 1223747238}
  - component: {fileID: 1223747240}
  - component: {fileID: 1223747239}
  - component: {fileID: 1223747241}
  - component: {fileID: 1223747242}
  m_Layer: 11
  m_Name: BackgroundAll
  m_TagString: Untagged
  m_Icon: {fileID: 0}
  m_NavMeshLayer: 0
  m_StaticEditorFlags: 0
  m_IsActive: 1
--- !u!4 &1223747238
--- !u!4 &1223747238 stripped
Transform:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_CorrespondingSourceObject: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
  m_PrefabInstance: {fileID: 8353648914744807342}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1223747237}
  serializedVersion: 2
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
  m_LocalPosition: {x: 0, y: 6, z: -2}
  m_LocalScale: {x: 1, y: 1, z: 1}
  m_ConstrainProportionsScale: 0
  m_Children: []
  m_Father: {fileID: 796676099}
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1223747239
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1223747237}
  m_Enabled: 0
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 051afb118ce1a7f459dc727505508d77, type: 3}
  m_Name:
  m_EditorClassIdentifier:
  cam: {fileID: 519420031}
  followTarget: {fileID: 254538002}
--- !u!212 &1223747240
SpriteRenderer:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1223747237}
  m_Enabled: 1
  m_CastShadows: 0
  m_ReceiveShadows: 0
  m_DynamicOccludee: 1
  m_StaticShadowCaster: 0
  m_MotionVectors: 1
  m_LightProbeUsage: 1
  m_ReflectionProbeUsage: 1
  m_RayTracingMode: 0
  m_RayTraceProcedural: 0
  m_RenderingLayerMask: 1
  m_RendererPriority: 0
  m_Materials:
  - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
  m_StaticBatchInfo:
    firstSubMesh: 0
    subMeshCount: 0
  m_StaticBatchRoot: {fileID: 0}
  m_ProbeAnchor: {fileID: 0}
  m_LightProbeVolumeOverride: {fileID: 0}
  m_ScaleInLightmap: 1
  m_ReceiveGI: 1
  m_PreserveUVs: 0
  m_IgnoreNormalsForChartDetection: 0
  m_ImportantGI: 0
  m_StitchLightmapSeams: 1
  m_SelectedEditorRenderState: 0
  m_MinimumChartSize: 4
  m_AutoUVMaxDistance: 0.5
  m_AutoUVMaxAngle: 89
  m_LightmapParameters: {fileID: 0}
  m_SortingLayerID: 1963190711
  m_SortingLayer: -2
  m_SortingOrder: 0
  m_Sprite: {fileID: 21300000, guid: 7d5be99b0261348468ab492c35422f1b, type: 3}
  m_Color: {r: 1, g: 1, b: 1, a: 1}
  m_FlipX: 0
  m_FlipY: 0
  m_DrawMode: 0
  m_Size: {x: 84.12234, y: 61.8624}
  m_AdaptiveModeThreshold: 0.349
  m_SpriteTileMode: 0
  m_WasSpriteAssigned: 1
  m_MaskInteraction: 0
  m_SpriteSortPoint: 0
--- !u!114 &1223747241
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1223747237}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: bff9938391d7202429e3508a7efde6eb, type: 3}
  m_Name:
  m_EditorClassIdentifier:
  offsetX: 0
  offsetY: 0
  heightSprites:
  - minHeight: 6
    maxHeight: 200
    sprite: {fileID: 21300000, guid: 7d5be99b0261348468ab492c35422f1b, type: 3}
  - minHeight: -200
    maxHeight: -8
    sprite: {fileID: 21300000, guid: 58a6eeb45a0e2674ab35114433129f28, type: 3}
  hasRightBuddy: 0
  hasLeftBuddy: 0
  hasTopBuddy: 0
  hasBottomBuddy: 0
  reverseScale: 1
--- !u!61 &1223747242
BoxCollider2D:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1223747237}
  m_Enabled: 1
  m_Density: 1
  m_Material: {fileID: 0}
  m_IncludeLayers:
    serializedVersion: 2
    m_Bits: 2048
  m_ExcludeLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_LayerOverridePriority: 0
  m_ForceSendLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_ForceReceiveLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_ContactCaptureLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_CallbackLayers:
    serializedVersion: 2
    m_Bits: 4294967295
  m_IsTrigger: 1
  m_UsedByEffector: 0
  m_UsedByComposite: 0
  m_Offset: {x: 0, y: 0}
  m_SpriteTilingProperty:
    border: {x: 0, y: 0, z: 0, w: 0}
    pivot: {x: 0.5, y: 0.5}
    oldSize: {x: 25, y: 14.0625}
    newSize: {x: 84.12234, y: 61.8624}
    adaptiveTilingThreshold: 0.349
    drawMode: 0
    adaptiveTiling: 0
  m_AutoTiling: 0
  serializedVersion: 2
  m_Size: {x: 25, y: 14.0625}
  m_EdgeRadius: 0
--- !u!1 &1235149190
GameObject:
  m_ObjectHideFlags: 0
@@ -4224,7 +4058,7 @@
  m_Name: 
  m_EditorClassIdentifier: 
  m_TrackedObjectOffset: {x: 0, y: 0, z: 0}
  m_LookaheadTime: 0.1
  m_LookaheadTime: 0
  m_LookaheadSmoothing: 5
  m_LookaheadIgnoreY: 0
  m_XDamping: 0
@@ -4521,11 +4355,6 @@
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1725312356}
  m_CullTransparentMesh: 1
--- !u!1 &1776306376 stripped
GameObject:
  m_CorrespondingSourceObject: {fileID: 8598998496262044661, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
  m_PrefabInstance: {fileID: 75655679957548990}
  m_PrefabAsset: {fileID: 0}
--- !u!1 &1794216239
GameObject:
  m_ObjectHideFlags: 0
@@ -5387,6 +5216,115 @@
  hasTopBuddy: 0
  hasBottomBuddy: 0
  reverseScale: 1
--- !u!1 &2136420132
GameObject:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  serializedVersion: 6
  m_Component:
  - component: {fileID: 2136420133}
  - component: {fileID: 2136420135}
  - component: {fileID: 2136420134}
  m_Layer: 11
  m_Name: Background
  m_TagString: Untagged
  m_Icon: {fileID: 0}
  m_NavMeshLayer: 0
  m_StaticEditorFlags: 0
  m_IsActive: 1
--- !u!4 &2136420133
Transform:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 2136420132}
  serializedVersion: 2
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
  m_LocalPosition: {x: 0, y: 0, z: -2}
  m_LocalScale: {x: 5, y: 5, z: 1}
  m_ConstrainProportionsScale: 0
  m_Children: []
  m_Father: {fileID: 796676099}
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &2136420134
SpriteRenderer:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 2136420132}
  m_Enabled: 1
  m_CastShadows: 0
  m_ReceiveShadows: 0
  m_DynamicOccludee: 1
  m_StaticShadowCaster: 0
  m_MotionVectors: 1
  m_LightProbeUsage: 1
  m_ReflectionProbeUsage: 1
  m_RayTracingMode: 0
  m_RayTraceProcedural: 0
  m_RenderingLayerMask: 1
  m_RendererPriority: 0
  m_Materials:
  - {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
  m_StaticBatchInfo:
    firstSubMesh: 0
    subMeshCount: 0
  m_StaticBatchRoot: {fileID: 0}
  m_ProbeAnchor: {fileID: 0}
  m_LightProbeVolumeOverride: {fileID: 0}
  m_ScaleInLightmap: 1
  m_ReceiveGI: 1
  m_PreserveUVs: 0
  m_IgnoreNormalsForChartDetection: 0
  m_ImportantGI: 0
  m_StitchLightmapSeams: 1
  m_SelectedEditorRenderState: 0
  m_MinimumChartSize: 4
  m_AutoUVMaxDistance: 0.5
  m_AutoUVMaxAngle: 89
  m_LightmapParameters: {fileID: 0}
  m_SortingLayerID: 1963190711
  m_SortingLayer: -2
  m_SortingOrder: 0
  m_Sprite: {fileID: 0}
  m_Color: {r: 1, g: 1, b: 1, a: 1}
  m_FlipX: 0
  m_FlipY: 0
  m_DrawMode: 0
  m_Size: {x: 1, y: 1}
  m_AdaptiveModeThreshold: 0.5
  m_SpriteTileMode: 0
  m_WasSpriteAssigned: 0
  m_MaskInteraction: 0
  m_SpriteSortPoint: 0
--- !u!114 &2136420135
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 2136420132}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 718d5e9be0a4bd647adb3ea9fc7cf477, type: 3}
  m_Name:
  m_EditorClassIdentifier:
  spriteRenderer: {fileID: 2136420134}
  transitionRenderer: {fileID: 0}
  backgroundLayers:
  - yThreshold: -5
    backgroundSprite: {fileID: 21300000, guid: 7d5be99b0261348468ab492c35422f1b, type: 3}
    transitionDistance: 4
    parallaxEffect: 0.439
  - yThreshold: -300
    backgroundSprite: {fileID: 21300000, guid: 58a6eeb45a0e2674ab35114433129f28, type: 3}
    transitionDistance: 5
    parallaxEffect: 0.482
  playerTransform: {fileID: 254538002}
--- !u!114 &18669457987763773
MonoBehaviour:
  m_ObjectHideFlags: 0
@@ -5480,22 +5418,26 @@
      propertyPath: m_LocalEulerAnglesHint.z
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 6581875976717324756, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: player
      value:
      objectReference: {fileID: 254538002}
    - target: {fileID: 6581875976717324756, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: fogTilemap
      value:
      objectReference: {fileID: 1794216242}
    - target: {fileID: 6581875976717324756, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: mainCamera
      value:
      objectReference: {fileID: 519420031}
    - target: {fileID: 6908574976455911116, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: pickups
      value: 
      objectReference: {fileID: 1409843025}
    - target: {fileID: 6908574976455911116, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: tileMap
      value:
      objectReference: {fileID: 1919262559}
    - target: {fileID: 6908574976455911116, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: tilemap
      value: 
      objectReference: {fileID: 1919262559}
    - target: {fileID: 6908574976455911116, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: fogOfWar
      value:
      objectReference: {fileID: 75655679957548994}
    - target: {fileID: 6908574976455911116, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: playerUI
      value: 
@@ -5504,10 +5446,6 @@
      propertyPath: fogTilemap
      value: 
      objectReference: {fileID: 1794216242}
    - target: {fileID: 6908574976455911116, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: gameCanvas
      value:
      objectReference: {fileID: 90387968388784992}
    - target: {fileID: 6908574976455911116, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: pauseMenuUI
      value: 
@@ -5520,30 +5458,6 @@
      propertyPath: worldSpaceUI
      value: 
      objectReference: {fileID: 97771189}
    - target: {fileID: 6908574976455911116, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: lootTextPrefab
      value:
      objectReference: {fileID: 456827189715955869, guid: 9014e3792e948bf4e81fdfdc7f38c5d9, type: 3}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.size
      value: 15
      objectReference: {fileID: 0}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[14].m_ActionId
      value: b425611e-206f-4a50-938e-ad263b5330a1
      objectReference: {fileID: 0}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[14].m_ActionName
      value: UI/Inventory[/Keyboard/b,/Keyboard/i]
      objectReference: {fileID: 0}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.size
      value: 1
      objectReference: {fileID: 0}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_Target
      value: 
@@ -5552,82 +5466,26 @@
      propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Target
      value: 
      objectReference: {fileID: 7398061984209721034}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
      value: 2
      objectReference: {fileID: 0}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[13].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
      value: OnEscapedPressed
      objectReference: {fileID: 0}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
      value: OnInventoryButtonPressed
      objectReference: {fileID: 0}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
      value: InventoryDisplay, Assembly-CSharp
      objectReference: {fileID: 0}
    - target: {fileID: 7748736149887392517, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_ActionEvents.Array.data[14].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
      value: UnityEngine.Object, UnityEngine
      objectReference: {fileID: 0}
    - target: {fileID: 8598998496262044661, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_Name
      value: GameManager
      objectReference: {fileID: 0}
    - target: {fileID: 8598998496262044661, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      propertyPath: m_IsActive
      value: 1
      objectReference: {fileID: 0}
    m_RemovedComponents:
    - {fileID: 851313892602111808, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
    m_RemovedComponents: []
    m_RemovedGameObjects: []
    m_AddedGameObjects: []
    m_AddedComponents:
    - targetCorrespondingSourceObject: {fileID: 8598998496262044661, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
      insertIndex: -1
      addedObject: {fileID: 75655679957548994}
    m_AddedComponents: []
  m_SourcePrefab: {fileID: 100100000, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
--- !u!114 &75655679957548991 stripped
MonoBehaviour:
  m_CorrespondingSourceObject: {fileID: 6908574976455911116, guid: 7296d9a2424531f4ba42c0c75e9c48a0, type: 3}
  m_PrefabInstance: {fileID: 75655679957548990}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1776306376}
  m_GameObject: {fileID: 0}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: ee189283a861cae42b728253b8229316, type: 3}
  m_Name: 
  m_EditorClassIdentifier: 
--- !u!114 &75655679957548994
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1776306376}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: e98672417f6c56e4d8020c2453ced645, type: 3}
  m_Name:
  m_EditorClassIdentifier:
  fogTilemap: {fileID: 1794216242}
  fogTile: {fileID: 11400000, guid: 54e9042346ddcc347aa31573844df14b, type: 2}
  player: {fileID: 254538002}
  viewRadius: 5
  mainCamera: {fileID: 519420031}
  fogLevels:
  - tile: {fileID: 11400000, guid: ee11684c9f570a741917f425e4ff9bf1, type: 2}
    opacity: 20
  - tile: {fileID: 11400000, guid: cfdca8d69259ece46ac1c967fcfcc447, type: 2}
    opacity: 40
  - tile: {fileID: 11400000, guid: e70bfd59f79cdce449d7a6a67b4a1722, type: 2}
    opacity: 60
  - tile: {fileID: 11400000, guid: 546f1dbae64d6ce49b8474fc131c86b9, type: 2}
    opacity: 80
  - tile: {fileID: 11400000, guid: 54e9042346ddcc347aa31573844df14b, type: 2}
    opacity: 100
--- !u!223 &90387968388784992
Canvas:
  m_ObjectHideFlags: 0
@@ -13389,6 +13247,75 @@
  m_hasFontAssetChanged: 0
  m_baseMaterial: {fileID: 0}
  m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1001 &8353648914744807342
PrefabInstance:
  m_ObjectHideFlags: 0
  serializedVersion: 2
  m_Modification:
    serializedVersion: 3
    m_TransformParent: {fileID: 796676099}
    m_Modifications:
    - target: {fileID: 3370728266000366833, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: cam
      value:
      objectReference: {fileID: 519420031}
    - target: {fileID: 3370728266000366833, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: followTarget
      value:
      objectReference: {fileID: 254538002}
    - target: {fileID: 3961525155789603524, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_Name
      value: BackgroundAll
      objectReference: {fileID: 0}
    - target: {fileID: 3961525155789603524, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_IsActive
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalPosition.x
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalPosition.y
      value: 6
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalPosition.z
      value: -2
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalRotation.w
      value: 1
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalRotation.x
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalRotation.y
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalRotation.z
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalEulerAnglesHint.x
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalEulerAnglesHint.y
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 6632530311481836413, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
      propertyPath: m_LocalEulerAnglesHint.z
      value: 0
      objectReference: {fileID: 0}
    m_RemovedComponents: []
    m_RemovedGameObjects: []
    m_AddedGameObjects: []
    m_AddedComponents: []
  m_SourcePrefab: {fileID: 100100000, guid: bcc4a9d71ad64b340b222e078e04fe7c, type: 3}
--- !u!114 &8374585935729613849
MonoBehaviour:
  m_ObjectHideFlags: 0
Assets/Scripts/Managers/GameManager.cs
@@ -27,6 +27,7 @@
    public GameObject pickups;
    public Tilemap fogTilemap;
    public FogOfWar fogOfWar;
    public GameObject backGroundPrefab;
    private void Awake()
    {
@@ -47,6 +48,25 @@
        }
        Debug.Log("waiting for async map loading");
        StartCoroutine(generateTileMap.GenerateTiles(LoadTileMapsFinished, destroyedTiles));
    }
    private void InitializeBackgroundTiles()
    {
        GameObject tilesParent = new GameObject("BackgroundTiles");
        GameObject player = GameObject.FindGameObjectWithTag("Player");
        Vector3 backgroundPos = player.transform.position;
        // Adjust the new position based on whether y is positive or negative
        float colliderHeight = backGroundPrefab.GetComponent<BoxCollider2D>().size.y;
        if (backgroundPos.y >= 0)
        {
            backgroundPos.y -= Mathf.Abs(backgroundPos.y) % colliderHeight;
        }
        else
        {
            backgroundPos.y += Mathf.Abs(backgroundPos.y) % colliderHeight;
        }
        Instantiate(backGroundPrefab, (backgroundPos), Quaternion.identity, tilesParent.transform);
    }
    private void LoadMapState()
@@ -71,6 +91,8 @@
    {
        Debug.Log("done async map loading");
        levelChanger.GetComponent<Animator>().SetBool("SceneLoading", false);
        //Initialize background tiles after the tilemap is loaded
        //InitializeBackgroundTiles();
        GameLoaded();
    }
    public void GameLoaded()
Assets/Scripts/UI/Tiling.cs
@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static AnimationStrings;
[RequireComponent(typeof(SpriteRenderer))]
public class Tiling : MonoBehaviour
@@ -127,6 +128,18 @@
            myTransform.position.z
        );
        // Adjust the new position so it fits with the BoxCollider2D size
        // Adjust the new position based on whether y is positive or negative
        float colliderHeight = GetComponent<BoxCollider2D>().size.y;
        if (newPosition.y >= 0)
        {
            newPosition.y -= Mathf.Abs(newPosition.y) % colliderHeight;
        }
        else
        {
            newPosition.y += Mathf.Abs(newPosition.y) % colliderHeight;
        }
        Transform newBuddy = Instantiate(myTransform, newPosition, myTransform.rotation);
        Tiling buddyTiling = newBuddy.GetComponent<Tiling>();