background objects
This commit is contained in:
parent
28d6351f63
commit
dd615f8412
File diff suppressed because it is too large
Load diff
|
|
@ -155,7 +155,7 @@ TextureImporter:
|
|||
width: 800
|
||||
height: 835
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
|
@ -167,6 +167,153 @@ TextureImporter:
|
|||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: backgroundtotem_0
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 73
|
||||
y: 1907
|
||||
width: 76
|
||||
height: 89
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: 4c45eff50c51dd8498fe139c3a350e54
|
||||
internalID: 592998762
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: trees
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 56
|
||||
y: 1348
|
||||
width: 786
|
||||
height: 462
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: 9ffb650b04b53144999bf86d6b4aeea7
|
||||
internalID: 1370341742
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: kingfisher
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 994
|
||||
y: 1495
|
||||
width: 511
|
||||
height: 311
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: a29ef75a1ecf93741aed0cf44237a322
|
||||
internalID: -126723542
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: penguin
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 1677
|
||||
y: 1532
|
||||
width: 400
|
||||
height: 245
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: 7437f138b4d32c14c9a0196636177b8a
|
||||
internalID: -1297142145
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: whiteback
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 35
|
||||
y: 630
|
||||
width: 475
|
||||
height: 656
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: 0b64cb60b2cbd3f48abb6344b65268ae
|
||||
internalID: -67062240
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: bluback
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 572
|
||||
y: 630
|
||||
width: 475
|
||||
height: 654
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: c6549a304eda1724bb4ed685c0cdba3a
|
||||
internalID: -413372245
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: backgroundtotem_6
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 1112
|
||||
y: 639
|
||||
width: 95
|
||||
height: 88
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: 38f1a12849b58a041b2027e520b28c38
|
||||
internalID: -1889446420
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
|
|
@ -178,9 +325,16 @@ TextureImporter:
|
|||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable:
|
||||
backgroundtotem_0: 592998762
|
||||
backgroundtotem_6: -1889446420
|
||||
bluback: -413372245
|
||||
ground: 1150890885
|
||||
kingfisher: -126723542
|
||||
penguin: -1297142145
|
||||
pillar: 589082449
|
||||
pillartop: 1905395231
|
||||
trees: 1370341742
|
||||
whiteback: -67062240
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
|
|
|
|||
|
|
@ -10,11 +10,15 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
{
|
||||
private const int PILLAR_AMOUNT_X = 12;
|
||||
private const int PILLAR_AMOUNT_Y = 3;
|
||||
private const int BACKGROUND_OBJECT_AMOUNT = 10;
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField] private Transform _pillarFirst;
|
||||
[SerializeField] private Transform _pillarSecond;
|
||||
[SerializeField] private Transform _pillarUp;
|
||||
[SerializeField] private Transform _backgroundObjectsParent;
|
||||
[SerializeField] private List<BackgroundScrollPair> _backgroundObjects;
|
||||
|
||||
|
||||
private List<List<Transform>> _pillars = new();
|
||||
private Transform _scrollTransform;
|
||||
|
|
@ -31,6 +35,8 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
private float _endDistance = float.MaxValue;
|
||||
private bool _hasReachedEnd = false;
|
||||
|
||||
private bool _endDistanceSet = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_scrollTransform = transform.parent;
|
||||
|
|
@ -58,7 +64,7 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
_pillarUp.GetChild(0).gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < PILLAR_AMOUNT_Y; i++)
|
||||
for (int i = 0; i < PILLAR_AMOUNT_Y; i++)
|
||||
{
|
||||
if (_hasReachedEnd) break;
|
||||
for (int j = 0; j < PILLAR_AMOUNT_X; j++)
|
||||
|
|
@ -75,13 +81,34 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_endDistanceSet)
|
||||
{
|
||||
_backgroundObjectsParent.gameObject.SetActive(true);
|
||||
_backgroundObjectsParent.localPosition = new Vector3(0, _endDistance);
|
||||
|
||||
foreach (var b in _backgroundObjects)
|
||||
{
|
||||
b.InitClones(_backgroundObjectsParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
PillarUpdate();
|
||||
if (!_endDistanceSet) return;
|
||||
foreach (var b in _backgroundObjects)
|
||||
{
|
||||
b.ScrollClones(_scrollTransform.localPosition.x);
|
||||
}
|
||||
}
|
||||
|
||||
private void PillarUpdate()
|
||||
{
|
||||
float currentScrollX = _scrollTransform.localPosition.x;
|
||||
float currentDistanceX = _pillarStartX + (_pillarDistanceX * _pillarIndexX);
|
||||
|
||||
|
||||
if (currentScrollX >= currentDistanceX + (_pillarDistanceX * PILLAR_AMOUNT_X / 2))
|
||||
{
|
||||
foreach (var pillarRow in _pillars)
|
||||
|
|
@ -92,11 +119,11 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
p.localPosition = new Vector3(p.localPosition.x + (_pillarDistanceX * PILLAR_AMOUNT_X), p.localPosition.y);
|
||||
}
|
||||
_pillarIndexX++;
|
||||
Update();
|
||||
PillarUpdate();
|
||||
}
|
||||
|
||||
if (_hasReachedEnd) return;
|
||||
|
||||
|
||||
float currentScrollY = _scrollTransform.localPosition.y;
|
||||
float currentDistanceY = _pillarStartY + (_pillarDistanceY * _pillarIndexY) + (_pillarDistanceY * PILLAR_AMOUNT_Y / 2);
|
||||
|
||||
|
|
@ -115,7 +142,7 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
}
|
||||
|
||||
_pillarIndexY++;
|
||||
Update();
|
||||
PillarUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,9 +166,57 @@ namespace HeavenStudio.Games.Scripts_TotemClimb
|
|||
|
||||
var allPillarEnds = EventCaller.GetAllInGameManagerList("totemClimb", new string[] { "above" }).FindAll(x => x.beat >= startBeat && x.beat < nextGameSwitchBeat);
|
||||
if (allPillarEnds.Count == 0) return double.MaxValue;
|
||||
|
||||
_endDistanceSet = true;
|
||||
return allPillarEnds[0].beat - startBeat;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
private class BackgroundScrollPair
|
||||
{
|
||||
public Transform first;
|
||||
public Transform second;
|
||||
|
||||
private List<Transform> _objects = new();
|
||||
|
||||
private int _index = 0;
|
||||
|
||||
private float _startX;
|
||||
private float _xDistance;
|
||||
|
||||
private float GetDistance()
|
||||
{
|
||||
return second.localPosition.x - first.localPosition.x;
|
||||
}
|
||||
|
||||
public void InitClones(Transform parent)
|
||||
{
|
||||
_xDistance = GetDistance();
|
||||
_startX = first.localPosition.x;
|
||||
_objects.Add(first);
|
||||
_objects.Add(second);
|
||||
|
||||
for (int i = 0; i < BACKGROUND_OBJECT_AMOUNT; i++)
|
||||
{
|
||||
Transform spawnedObject = Instantiate(first, parent);
|
||||
spawnedObject.localPosition = new Vector3(second.localPosition.x + (_xDistance * (i + 1)), first.localPosition.y, first.localPosition.z);
|
||||
_objects.Add(spawnedObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void ScrollClones(float currentScrollX)
|
||||
{
|
||||
float currentDistanceX = _startX + (_xDistance * _index) + (_xDistance * (BACKGROUND_OBJECT_AMOUNT + 2) / 2);
|
||||
|
||||
if (currentScrollX >= currentDistanceX)
|
||||
{
|
||||
var b = _objects[_index % BACKGROUND_OBJECT_AMOUNT];
|
||||
b.localPosition += new Vector3(_xDistance * BACKGROUND_OBJECT_AMOUNT, 0);
|
||||
|
||||
_index++;
|
||||
ScrollClones(currentScrollX);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue