mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-28 20:43:03 +00:00
ccfc528d99
* setup * scroll stuff * tons of stuff * totem bop * bopping and new assets * soem more * frog fit * fixed order of operation issue * triple proto * wow i love super curves * TRIPLE JUMP * frog fall * the spinny * dragon initial * functional dragon * fixed un bug * the deets * the deets have been fixed * miss stuff * smol fix * no log * fixed some issues * switch to next state * particle * remove useless logic * zoomed out * sound and line fix * new bg sheet * minor tweaks * pillar tops * background objects * background tweak * triple sound tweak * background rework * frog wings and new jump anim * fix * birds * disable pillars * landing end * fix again * minor fix * fixes and icon * background scroll logic rework * put in fixed sheet * fixed sounds
56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace HeavenStudio.Games.Scripts_TotemClimb
|
|
{
|
|
public class TCGroundManager : MonoBehaviour
|
|
{
|
|
private const int GROUND_AMOUNT = 6;
|
|
|
|
[Header("Components")]
|
|
[SerializeField] private Transform _groundFirst;
|
|
[SerializeField] private Transform _groundSecond;
|
|
|
|
private List<Transform> _grounds = new();
|
|
private Transform _scrollTransform;
|
|
private float _groundDistance;
|
|
private float _groundStart;
|
|
|
|
private int _groundIndex = 0;
|
|
|
|
private void Awake()
|
|
{
|
|
_scrollTransform = transform.parent;
|
|
|
|
_groundStart = _groundFirst.localPosition.x;
|
|
_groundDistance = _groundSecond.localPosition.x - _groundFirst.localPosition.x;
|
|
|
|
_grounds.Add(_groundFirst);
|
|
_grounds.Add(_groundSecond);
|
|
|
|
for (int i = 2; i < GROUND_AMOUNT; i++)
|
|
{
|
|
Transform spawnedGround = Instantiate(_groundFirst, transform);
|
|
spawnedGround.localPosition = new Vector3(_groundStart + (_groundDistance * i), spawnedGround.localPosition.y);
|
|
_grounds.Add(spawnedGround);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
float currentScrollX = _scrollTransform.localPosition.x;
|
|
float currentDistance = _groundStart + (_groundDistance * _groundIndex);
|
|
|
|
if (currentScrollX >= currentDistance + (_groundDistance * GROUND_AMOUNT / 2))
|
|
{
|
|
var g = _grounds[_groundIndex % GROUND_AMOUNT];
|
|
|
|
g.localPosition = new Vector3(g.localPosition.x + (_groundDistance * GROUND_AMOUNT), g.localPosition.y);
|
|
|
|
_groundIndex++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|