Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alecs000 committed Apr 4, 2023
2 parents 857752a + 844b6e9 commit 4fc61bc
Show file tree
Hide file tree
Showing 13 changed files with 1,393 additions and 15 deletions.

Large diffs are not rendered by default.

266 changes: 261 additions & 5 deletions Assets/Scenes/GameScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@ RectTransform:
m_Children:
- {fileID: 1879916603}
m_Father: {fileID: 1238698634}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.1924375, y: 0.87700003}
m_AnchorMax: {x: 0.8117501, y: 0.96922094}
m_AnchoredPosition: {x: -3, y: 1}
m_AnchoredPosition: {x: -2.999878, y: 1}
m_SizeDelta: {x: -7.089966, y: -2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &641517907
Expand Down Expand Up @@ -1679,8 +1679,8 @@ RectTransform:
m_Children:
- {fileID: 862295120}
- {fileID: 6541020236614636302}
- {fileID: 1528680348}
- {fileID: 504675922}
- {fileID: 1528680348}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -1921,6 +1921,124 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1267449266}
m_CullTransparentMesh: 1
--- !u!1 &1271782618
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1271782621}
- component: {fileID: 1271782620}
- component: {fileID: 1271782624}
- component: {fileID: 1271782623}
- component: {fileID: 1271782622}
m_Layer: 5
m_Name: Backgroung
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1271782620
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1271782618}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8508295fc2451b846b50032ce571f617, type: 3}
m_Name:
m_EditorClassIdentifier:
_bagroundImage: {fileID: 1271782622}
_configs:
- <Sprite>k__BackingField: {fileID: 21300000, guid: 94d52055702559b4bb01132e8b4c7f88,
type: 3}
<StartLevel>k__BackingField: 0
<EndLevel>k__BackingField: 5
- <Sprite>k__BackingField: {fileID: 21300000, guid: 9c845b5c25744d742b71a7aefe9e84e6,
type: 3}
<StartLevel>k__BackingField: 6
<EndLevel>k__BackingField: 10
- <Sprite>k__BackingField: {fileID: 21300000, guid: d11dab8ed612b134a92945beb821b918,
type: 3}
<StartLevel>k__BackingField: 11
<EndLevel>k__BackingField: 20
--- !u!224 &1271782621
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1271782618}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 2039226119}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1271782622
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1271782618}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 6975ee4c1f40caf4da8dd733ee2cfeaf, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1271782623
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1271782618}
m_CullTransparentMesh: 1
--- !u!114 &1271782624
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1271782618}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 86710e43de46f6f4bac7c8e50813a599, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AspectMode: 4
m_AspectRatio: 1.77777
--- !u!1 &1288659373
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2653,10 +2771,15 @@ PrefabInstance:
propertyPath: m_SizeDelta.x
value: 190.14
objectReference: {fileID: 0}
- target: {fileID: 744114260322352916, guid: 4a7c1b49b2924a64e9c757d086060867,
type: 3}
propertyPath: m_SizeDelta.x
value: 471.64
objectReference: {fileID: 0}
- target: {fileID: 744114260322352916, guid: 4a7c1b49b2924a64e9c757d086060867,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 365.83997
value: 235.82
objectReference: {fileID: 0}
- target: {fileID: 744114261140172705, guid: 4a7c1b49b2924a64e9c757d086060867,
type: 3}
Expand All @@ -2681,7 +2804,7 @@ PrefabInstance:
- target: {fileID: 744114261140172706, guid: 4a7c1b49b2924a64e9c757d086060867,
type: 3}
propertyPath: m_RootOrder
value: 2
value: 3
objectReference: {fileID: 0}
- target: {fileID: 744114261140172706, guid: 4a7c1b49b2924a64e9c757d086060867,
type: 3}
Expand Down Expand Up @@ -3768,6 +3891,139 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1879916602}
m_CullTransparentMesh: 1
--- !u!1 &2013254783
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2013254784}
m_Layer: 0
m_Name: Background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2013254784
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2013254783}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5.8503084, y: 3.6523473, z: 8301.818}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2039226119}
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2039226118
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2039226119}
- component: {fileID: 2039226122}
- component: {fileID: 2039226121}
- component: {fileID: 2039226120}
m_Layer: 0
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2039226119
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2039226118}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1271782621}
m_Father: {fileID: 2013254784}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &2039226120
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2039226118}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &2039226121
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2039226118}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &2039226122
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2039226118}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 1
m_Camera: {fileID: 1246104239}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: -32768
m_TargetDisplay: 0
--- !u!1 &2098830376
GameObject:
m_ObjectHideFlags: 0
Expand Down
10 changes: 10 additions & 0 deletions Assets/Scripts/BackgroundConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using UnityEngine;

[System.Serializable]
public class BackgroundConfig
{
[field: SerializeField] public Sprite Sprite { get; private set; }
[field: SerializeField] public int StartLevel { get; private set; }
[field: SerializeField] public int EndLevel { get; private set; }

}
11 changes: 11 additions & 0 deletions Assets/Scripts/BackgroundConfig.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions Assets/Scripts/BackgroundSetter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

public class BackgroundSetter : MonoBehaviour
{
[SerializeField] private Image _bagroundImage;
[SerializeField] private BackgroundConfig[] _configs;

private void Start()
{
SetBaground();
}

private void SetBaground()
{
_bagroundImage.sprite = GetBackground();
}

private Sprite GetBackground()
{
foreach (var config in _configs)
{
if (IsSutableConfig(config))
{
return config.Sprite;
}
}

return GetHighestLevelBackground();
}

private bool IsSutableConfig(BackgroundConfig config)
{
return config.StartLevel <= LevelSelector.SelectedLevel &&
config.EndLevel >= LevelSelector.SelectedLevel;
}

private Sprite GetHighestLevelBackground()
{
return _configs.OrderByDescending(c => c.EndLevel).Select(c => c.Sprite).First(); ;
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/BackgroundSetter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4fc61bc

Please sign in to comment.