scroll stuff
This commit is contained in:
parent
f98dc55596
commit
7e21797acf
File diff suppressed because it is too large
Load diff
91
Assets/Resources/Sprites/Games/TotemClimb/TotemRecolor.mat
Normal file
91
Assets/Resources/Sprites/Games/TotemClimb/TotemRecolor.mat
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: TotemRecolor
|
||||
m_Shader: {fileID: 4800000, guid: ff54fed5718ccc543808dec1f266d1c8, type: 3}
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _AddColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ColorAlpha: {r: 0.41568628, g: 0.12941177, b: 0.14117648, a: 1}
|
||||
- _ColorBravo: {r: 0.8235294, g: 0.6431373, b: 0.5294118, a: 1}
|
||||
- _ColorDelta: {r: 0.5803922, g: 0.32941177, b: 0.24313726, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8050440f1fb615e499a19c17ed17252d
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Assets/Scripts/Games/TotemClimb/TCGroundManager.cs
Normal file
56
Assets/Scripts/Games/TotemClimb/TCGroundManager.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/Games/TotemClimb/TCGroundManager.cs.meta
Normal file
11
Assets/Scripts/Games/TotemClimb/TCGroundManager.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5f01311f73b954b4bae83be6f232a500
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Assets/Scripts/Games/TotemClimb/TCPillarManager.cs
Normal file
87
Assets/Scripts/Games/TotemClimb/TCPillarManager.cs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_TotemClimb
|
||||
{
|
||||
public class TCPillarManager : MonoBehaviour
|
||||
{
|
||||
private const int PILLAR_AMOUNT_X = 12;
|
||||
private const int PILLAR_AMOUNT_Y = 4;
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField] private Transform _pillarFirst;
|
||||
[SerializeField] private Transform _pillarSecond;
|
||||
[SerializeField] private Transform _pillarUp;
|
||||
|
||||
private List<List<Transform>> _pillars = new();
|
||||
private Transform _scrollTransform;
|
||||
|
||||
private float _pillarDistanceX;
|
||||
private float _pillarStartX;
|
||||
|
||||
private float _pillarDistanceY;
|
||||
private float _pillarStartY;
|
||||
|
||||
private int _pillarIndexX = 0;
|
||||
private int _pillarIndexY = 0;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_scrollTransform = transform.parent;
|
||||
|
||||
_pillarStartX = _pillarFirst.localPosition.x;
|
||||
_pillarDistanceX = _pillarSecond.localPosition.x - _pillarFirst.localPosition.x;
|
||||
_pillarStartY = _pillarFirst.localPosition.y;
|
||||
_pillarDistanceY = _pillarUp.localPosition.y - _pillarFirst.localPosition.y;
|
||||
|
||||
for (int i = 0; i < PILLAR_AMOUNT_Y; i++) _pillars.Add(new());
|
||||
|
||||
_pillars[0].Add(_pillarFirst);
|
||||
_pillars[0].Add(_pillarSecond);
|
||||
_pillars[1].Add(_pillarUp);
|
||||
|
||||
for (int i = 0; i < PILLAR_AMOUNT_Y; i++)
|
||||
{
|
||||
for (int j = 0; j < PILLAR_AMOUNT_X; j++)
|
||||
{
|
||||
if (_pillars.ElementAtOrDefault(i).ElementAtOrDefault(j) != null) continue;
|
||||
Transform spawnedPillar = Instantiate(_pillarFirst, transform);
|
||||
spawnedPillar.localPosition = new Vector3(_pillarStartX + (_pillarDistanceX * j), spawnedPillar.localPosition.y + (_pillarDistanceY * i));
|
||||
_pillars[i].Add(spawnedPillar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float currentScrollX = _scrollTransform.localPosition.x;
|
||||
float currentDistanceX = _pillarStartX + (_pillarDistanceX * _pillarIndexX);
|
||||
|
||||
if (currentScrollX >= currentDistanceX + (_pillarDistanceX * PILLAR_AMOUNT_X / 2))
|
||||
{
|
||||
foreach (var pillarRow in _pillars)
|
||||
{
|
||||
var p = pillarRow[_pillarIndexX % PILLAR_AMOUNT_X];
|
||||
|
||||
p.localPosition = new Vector3(p.localPosition.x + (_pillarDistanceX * PILLAR_AMOUNT_X), p.localPosition.y);
|
||||
}
|
||||
_pillarIndexX++;
|
||||
}
|
||||
|
||||
float currentScrollY = _scrollTransform.localPosition.y;
|
||||
float currentDistanceY = _pillarStartY + (_pillarDistanceY * _pillarIndexY);
|
||||
|
||||
if (currentScrollY >= currentDistanceY + (_pillarDistanceY * PILLAR_AMOUNT_Y / 2))
|
||||
{
|
||||
foreach (var p in _pillars[_pillarIndexY % PILLAR_AMOUNT_Y])
|
||||
{
|
||||
p.localPosition = new Vector3(p.localPosition.x, p.localPosition.y + (_pillarDistanceY * PILLAR_AMOUNT_Y));
|
||||
}
|
||||
_pillarIndexY++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/Games/TotemClimb/TCPillarManager.cs.meta
Normal file
11
Assets/Scripts/Games/TotemClimb/TCPillarManager.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 99aece23798354a489e4efc915601eab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/Scripts/Games/TotemClimb/TCTotemManager.cs
Normal file
53
Assets/Scripts/Games/TotemClimb/TCTotemManager.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_TotemClimb
|
||||
{
|
||||
public class TCTotemManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform _totemTransform;
|
||||
[SerializeField] private float _xDistance;
|
||||
[SerializeField] private float _yDistance;
|
||||
[SerializeField] private int _totemAmount = 12;
|
||||
|
||||
private Transform _scrollTransform;
|
||||
private float _totemStartX;
|
||||
private float _totemStartY;
|
||||
private List<Transform> _totems = new();
|
||||
|
||||
private int _totemIndex = 0;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_scrollTransform = transform.parent;
|
||||
_totemStartX = _totemTransform.localPosition.x;
|
||||
_totemStartY = _totemTransform.localPosition.y;
|
||||
|
||||
_totems.Add(_totemTransform);
|
||||
|
||||
for (int i = 1; i < _totemAmount; i++)
|
||||
{
|
||||
Transform spawnedTotem = Instantiate(_totemTransform, transform);
|
||||
spawnedTotem.transform.localPosition = new Vector3(_totemStartX + (_xDistance * i), _totemStartY + (_yDistance * i));
|
||||
_totems.Add(spawnedTotem);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float currentScrollX = _scrollTransform.localPosition.x;
|
||||
float currentDistanceX = _totemStartX + (_xDistance * _totemIndex);
|
||||
|
||||
if (currentScrollX >= currentDistanceX + (_xDistance * _totemAmount / 2))
|
||||
{
|
||||
var t = _totems[_totemIndex % _totemAmount];
|
||||
|
||||
t.localPosition = new Vector3(t.localPosition.x + (_xDistance * _totemAmount), t.localPosition.y + (_yDistance * _totemAmount));
|
||||
|
||||
_totemIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/Games/TotemClimb/TCTotemManager.cs.meta
Normal file
11
Assets/Scripts/Games/TotemClimb/TCTotemManager.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 09d47a9ccd9cfbe419ae4739d230b1df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -2,6 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.Games.Scripts_TotemClimb;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
|
|
@ -13,7 +14,14 @@ namespace HeavenStudio.Games.Loaders
|
|||
{
|
||||
return new Minigame("totemClimb", "Totem Climb", "FFFFFF", false, false, new()
|
||||
{
|
||||
new("start", "Start Jumping")
|
||||
{
|
||||
|
||||
},
|
||||
new("stop", "Stop Jumping")
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -23,12 +31,74 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
public class TotemClimb : Minigame
|
||||
{
|
||||
[Header("Components")]
|
||||
[SerializeField] private Transform _cameraTransform;
|
||||
[SerializeField] private Transform _scrollTransform;
|
||||
|
||||
[Header("Properties")]
|
||||
[SerializeField] private float _scrollSpeedX = 3.838f;
|
||||
[SerializeField] private float _scrollSpeedY = 1.45f;
|
||||
|
||||
private double _startBeat = double.MaxValue;
|
||||
private double _endBeat = double.MaxValue;
|
||||
|
||||
public static TotemClimb instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public override void OnGameSwitch(double beat)
|
||||
{
|
||||
CalculateStartAndEndBeat(beat);
|
||||
}
|
||||
|
||||
public override void OnPlay(double beat)
|
||||
{
|
||||
var allGameSwitches = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame" }).FindAll(x => x.beat <= beat && x.datamodel is "gameManager/switchGame/totemClimb");
|
||||
double lastGameSwitchBeat = 0;
|
||||
if (allGameSwitches.Count > 0) lastGameSwitchBeat = allGameSwitches[^1].beat;
|
||||
|
||||
CalculateStartAndEndBeat(lastGameSwitchBeat);
|
||||
}
|
||||
|
||||
private void CalculateStartAndEndBeat(double beat)
|
||||
{
|
||||
var nextGameSwitches = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame" }).FindAll(x => x.beat > beat && x.datamodel != "gameManager/switchGame/totemClimb");
|
||||
double nextGameSwitchBeat = double.MaxValue;
|
||||
if (nextGameSwitches.Count > 0)
|
||||
{
|
||||
nextGameSwitchBeat = nextGameSwitches[0].beat;
|
||||
}
|
||||
|
||||
var allStarts = EventCaller.GetAllInGameManagerList("totemClimb", new string[] { "start" }).FindAll(x => x.beat >= beat && x.beat < nextGameSwitchBeat);
|
||||
if (allStarts.Count == 0) return;
|
||||
|
||||
_startBeat = allStarts[0].beat;
|
||||
|
||||
var allStops = EventCaller.GetAllInGameManagerList("totemClimb", new string[] { "stop" }).FindAll(x => x.beat > _startBeat && x.beat < nextGameSwitchBeat);
|
||||
if (allStops.Count == 0) return;
|
||||
|
||||
_endBeat = allStops[0].beat;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
|
||||
ScrollUpdate(cond);
|
||||
}
|
||||
|
||||
private void ScrollUpdate(Conductor cond)
|
||||
{
|
||||
if (_startBeat == double.MaxValue) return;
|
||||
double beatDistance = _endBeat - _startBeat;
|
||||
float normalizedBeat = Mathf.Clamp(cond.GetPositionFromBeat(_startBeat, 1), 0f, (float)beatDistance);
|
||||
|
||||
_scrollTransform.localPosition = new Vector3(normalizedBeat * _scrollSpeedX, normalizedBeat * _scrollSpeedY);
|
||||
_cameraTransform.localPosition = new Vector3(_scrollTransform.localPosition.x * -2, _scrollTransform.localPosition.y * -2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ namespace HeavenStudio.Editor
|
|||
// This two are from unity answer (I mixed up)
|
||||
public void CreateWaveForm()
|
||||
{
|
||||
if (audio == null || audio.clip == null) return;
|
||||
resolution = audio.clip.frequency / resolution;
|
||||
|
||||
samples = new float[audio.clip.samples * audio.clip.channels];
|
||||
|
|
|
|||
Loading…
Reference in a new issue