Skip to content

Commit

Permalink
last bpm 0 fix+track phase change+0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yojohanshinwataikei committed Oct 3, 2020
1 parent 1624e55 commit 6afe013
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 20 deletions.
3 changes: 2 additions & 1 deletion Assets/Materials/Player/Track.mat
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Phase: 0.24114475
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _Speed: 0
- _Speed: 0.12320762
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
Expand Down
2 changes: 1 addition & 1 deletion Assets/Misc/BuildTimestamp.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
637372395510882808
637373598038901891
5 changes: 5 additions & 0 deletions Assets/Misc/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.3.2
- 改写了轨道底板的移动方式, 现在它会在 BPM 小于 0 时倒退并且在 BPM 变化时不会发生突变了
- 修复最后一条 Timing 的 BPM 为 0 时其后的物件不显示的问题

---
0.3.1
- 修复 arc 和 arctap 的分数与 combo 计算中的问题

Expand Down
45 changes: 31 additions & 14 deletions Assets/Scripts/Gameplay/Managers/ArcTimingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private void Awake()
}
private void Start()
{
speedShaderId = Shader.PropertyToID("_Speed");
phaseShaderId = Shader.PropertyToID("_Phase");
}

private int velocity = 30;
Expand All @@ -36,7 +36,8 @@ private void Start()
private List<SpriteRenderer> beatLineInstances = new List<SpriteRenderer>();
private float earliestRenderTime = 0;
private float latestRenderTime = 0;
private int speedShaderId = 0;
private int phaseShaderId = 0;
private float phase = 0;
public float CurrentSpeed { get; set; }
public List<ArcTiming> Timings { get => timings; }
public int Velocity
Expand Down Expand Up @@ -69,7 +70,7 @@ public void Clean()
Timings.Clear();
timingGroups.Clear();
AdeTimingEditor.Instance.SetCurrentTimingGroup(null);
TrackRenderer.sharedMaterial.SetFloat(speedShaderId, 0);
TrackRenderer.sharedMaterial.SetFloat(phaseShaderId, 0);
HideExceededBeatlineInstance(0);
}
public void Load(List<ArcTiming> arcTimings, List<ArcTimingGroup> arcTimingGroups)
Expand Down Expand Up @@ -263,7 +264,7 @@ private void UpdateChartSpeedStatus()
private void UpdateRenderRange(ArcTimingGroup timingGroup)
{
var Timings = GetTiming(timingGroup);
int nearPosition = 0;
int nearPosition = -20000;
int farPosition = 100000;
float earliestRenderTime, latestRenderTime;
if (Timings.Count == 0)
Expand Down Expand Up @@ -316,11 +317,23 @@ private void UpdateRenderRange(ArcTimingGroup timingGroup)
{
continue;
}
float nearTime = Mathf.Lerp(startTime, finishTime, Mathf.InverseLerp(startPosition, finishPosition, nearPosition));
float farTime = Mathf.Lerp(startTime, finishTime, Mathf.InverseLerp(startPosition, finishPosition, farPosition));
float nearTime;
float farTime;
if (Mathf.Approximately(startPosition, finishPosition))
{
nearTime = startTime;
farTime = finishTime;
}
else
{
nearTime = Mathf.Lerp(startTime, finishTime, Mathf.InverseLerp(startPosition, finishPosition, nearPosition));
farTime = Mathf.Lerp(startTime, finishTime, Mathf.InverseLerp(startPosition, finishPosition, farPosition));
}
earliestRenderTime = Mathf.Min(earliestRenderTime, nearTime, farTime);
latestRenderTime = Mathf.Max(latestRenderTime, nearTime, farTime);
}
earliestRenderTime = Mathf.Min(earliestRenderTime, currentTiming);
latestRenderTime = Mathf.Max(latestRenderTime, currentTiming);
earliestRenderTime += ArcAudioManager.Instance.AudioOffset;
latestRenderTime += ArcAudioManager.Instance.AudioOffset;
}
Expand Down Expand Up @@ -361,7 +374,9 @@ private void UpdateBeatline()
}
private void UpdateTrackSpeed()
{
TrackRenderer.sharedMaterial.SetFloat(speedShaderId, ArcGameplayManager.Instance.IsPlaying ? CurrentSpeed : 0);
phase += 3f * (ArcGameplayManager.Instance.IsPlaying ? CurrentSpeed : 0) * Time.deltaTime;
phase -= Mathf.Floor(phase);
TrackRenderer.sharedMaterial.SetFloat(phaseShaderId, phase);
}

public void ReOrderTimingGroup(ArcTimingGroup timingGroup)
Expand Down Expand Up @@ -406,19 +421,21 @@ public void AddTimingGroup(ArcTimingGroup timingGroup)
{
timingGroup.Id = 1;
}
int pos=timingGroup.Id-1;
timingGroups.Insert(pos,timingGroup);
for(int i=pos+1;i<timingGroups.Count;i++){
timingGroups[i].Id=i+1;
int pos = timingGroup.Id - 1;
timingGroups.Insert(pos, timingGroup);
for (int i = pos + 1; i < timingGroups.Count; i++)
{
timingGroups[i].Id = i + 1;
}
OnTimingGroupChange();
}
public void RemoveTimingGroup(ArcTimingGroup timingGroup)
{
int pos=timingGroup.Id-1;
int pos = timingGroup.Id - 1;
timingGroups.Remove(timingGroup);
for(int i=pos;i<timingGroups.Count;i++){
timingGroups[i].Id=i+1;
for (int i = pos; i < timingGroups.Count; i++)
{
timingGroups[i].Id = i + 1;
}
OnTimingGroupChange();
}
Expand Down
6 changes: 3 additions & 3 deletions Assets/Shader/Track.shader
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Shader "Arcade/Track"
Properties
{
[PerRendererData] _MainTex ("Texture", 2D) = "white" {}
_Speed ("Speed", Float) = 1
_Phase ("Phase", Float) = 0
_Color ("Color", Color) = (1,1,1,1)
}
SubShader
Expand Down Expand Up @@ -33,7 +33,7 @@ Shader "Arcade/Track"
float2 uv : TEXCOORD0;
};

float _Speed;
float _Phase;
sampler2D _MainTex;
float4 _Color;

Expand All @@ -48,7 +48,7 @@ Shader "Arcade/Track"
half4 frag (v2f i) : SV_Target
{
float2 p = i.uv;
p.y = (p.y + _Time.y * abs(_Speed) * 3) % 1;
p.y = (p.y + _Phase) % 1;
float4 c= tex2D(_MainTex,p);
c.a = _Color.a;
return c;
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ PlayerSettings:
16:10: 0
16:9: 1
Others: 0
bundleVersion: 0.3.1
bundleVersion: 0.3.2
preloadedAssets:
- {fileID: 4800000, guid: bb26ede1beb997943a7d6295fbf075d4, type: 3}
- {fileID: 4800000, guid: 1e340182228616b4ca7dad1e80f4d319, type: 3}
Expand Down

0 comments on commit 6afe013

Please sign in to comment.