Skip to content

Commit

Permalink
Designant arc render and logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yojohanshinwataikei committed Jan 1, 2025
1 parent 5242335 commit 7388447
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Assets/Materials/Player/TrackBorderLeft.mat
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Phase: 0
- _Phase: 0.6642631
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
Expand Down
2 changes: 1 addition & 1 deletion Assets/Materials/Player/TrackBorderRight.mat
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Phase: 0
- _Phase: 0.6642631
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
Expand Down
2 changes: 1 addition & 1 deletion Assets/Materials/Player/TrackMain.mat
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Phase: 0
- _Phase: 0.6642631
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
Expand Down
42 changes: 41 additions & 1 deletion Assets/Scripts/Gameplay/Chart/ArcChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ public override GameObject Instance
ModelRenderer.sortingLayerName = "Arc";
ModelRenderer.sortingOrder = 4;
alphaShaderId = Shader.PropertyToID("_Alpha");
colorShaderId = Shader.PropertyToID("_Color");
ArcTapCollider = instance.GetComponentInChildren<MeshCollider>();
Enable = false;
}
Expand All @@ -909,6 +910,8 @@ public override void Destroy()
{
RemoveArcTapConnection();
base.Destroy();
currentAlpha = 1;
currentTintColor = Color.white;
ArcTapCollider = null;
ModelRenderer = null;
ShadowRenderer = null;
Expand All @@ -935,6 +938,7 @@ public void Instantiate(ArcArc arc)

UpdatePosition();
UpdateScale();
UpdateColor();
SetupArcTapConnection();
}

Expand Down Expand Up @@ -970,6 +974,18 @@ public void UpdateScale()
}
}

public void UpdateColor()
{
if (Arc.Designant && !Arc.IsSfx)
{
TintColor = ArcArcManager.Instance.ArcTapDesignant;
}
else
{
TintColor = Color.white;
}
}

/// <summary>
/// Please use the overload method.
/// </summary>
Expand All @@ -980,7 +996,7 @@ public override void Instantiate()

public void SetupArcTapConnection()
{
if (Arc == null || Arc.NoInput() || (Arc.EndTiming - Arc.Timing) == 0) return;
if (Arc == null || Arc.NoInput() || Arc.Designant || (Arc.EndTiming - Arc.Timing) == 0) return;
List<ArcTap> taps = ArcTapNoteManager.Instance.Taps;
ArcTap[] sameTimeTapNotes = taps.Where((s) => Mathf.Abs(s.Timing - Timing) <= 1).ToArray();
foreach (ArcTap t in sameTimeTapNotes)
Expand Down Expand Up @@ -1032,6 +1048,23 @@ public bool IsMyself(GameObject gameObject)
{
return Model.gameObject.Equals(gameObject);
}
public Color TintColor
{
get
{
return currentTintColor;
}
set
{
if (currentTintColor != value)
{
currentTintColor = value;
ModelRenderer.GetPropertyBlock(propertyBlock);
propertyBlock.SetColor(colorShaderId, value);
ModelRenderer.SetPropertyBlock(propertyBlock);
}
}
}

public float Alpha
{
Expand Down Expand Up @@ -1095,8 +1128,10 @@ public override bool Selected
}

private bool selected;
private Color currentTintColor = Color.white;
private float currentAlpha = 1f;
private int alphaShaderId = 0;
private int colorShaderId = 0;

public ArcArcTap()
{
Expand Down Expand Up @@ -1126,6 +1161,11 @@ public bool IsVoid
}

}

public bool Designant
{
get => LineType == ArcLineType.Designant;
}
public List<ArcArcTap> ArcTaps = new List<ArcArcTap>();

public ArcArcTap ConvertedVariousSizedArctap = null;
Expand Down
44 changes: 40 additions & 4 deletions Assets/Scripts/Gameplay/Components/ArcArcRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ private Color ArcVoid
{
get { return ArcArcManager.Instance.ArcVoid; }
}
private Color ArcDesignant
{
get { return ArcArcManager.Instance.ArcDesignant; }
}



public ArcArc Arc
Expand Down Expand Up @@ -253,8 +258,8 @@ public void ReloadColor()
float alpha = Alpha;
if (arc != null)
{
HighColor = (arc.IsVoid ? ArcVoid : (arc.Color == 0 ? ArcBlueHigh : arc.Color == 1 ? ArcRedHigh : arc.Color == 2 ? ArcGreenHigh : ArcUnknownHigh));
LowColor = (arc.IsVoid ? ArcVoid : (arc.Color == 0 ? ArcBlueLow : arc.Color == 1 ? ArcRedLow : arc.Color == 2 ? ArcGreenLow : ArcUnknownLow));
HighColor = GetColor(true);
LowColor = GetColor(false);
}
Alpha = alpha;
}
Expand Down Expand Up @@ -339,6 +344,37 @@ private void OnDestroy()
private Color currentLowColor;
private List<ArcArcSegmentComponent> segments = new List<ArcArcSegmentComponent>();

private Color GetColor(bool high)
{
if (arc.LineType == ArcLineType.TrueIsVoid)
{
return ArcVoid;
}
else if (arc.LineType == ArcLineType.Designant)
{
return ArcDesignant;
}
else
{
if (arc.Color == 0)
{
return high ? ArcBlueHigh : ArcBlueLow;
}
else if (arc.Color == 1)
{
return high ? ArcRedHigh : ArcRedLow;
}
else if (arc.Color == 2)
{
return high ? ArcGreenHigh : ArcGreenLow;
}
else
{
return high ? ArcUnknownHigh : ArcUnknownLow;
}
}
}

private void InstantiateSegment(int quantity)
{
int count = segments.Count;
Expand Down Expand Up @@ -438,8 +474,8 @@ public void BuildSegments()
-timingManager.CalculatePositionByTimingAndStart(arc.Timing, arc.EndTiming, arc.TimingGroup) / 1000f);
segments[segmentCount - 1].BuildSegment(start, end, arc.IsVoid ? OffsetVoid : OffsetNormal, arc.Timing + segSize * (segmentCount - 1), arc.EndTiming, startHeight, endHeight);
}
HighColor = (arc.IsVoid ? ArcVoid : (arc.Color == 0 ? ArcBlueHigh : arc.Color == 1 ? ArcRedHigh : arc.Color == 2 ? ArcGreenHigh : ArcUnknownHigh));
LowColor = (arc.IsVoid ? ArcVoid : (arc.Color == 0 ? ArcBlueLow : arc.Color == 1 ? ArcRedLow : arc.Color == 2 ? ArcGreenLow : ArcUnknownLow));
HighColor = GetColor(true);
LowColor = GetColor(false);
}

public void BuildHead()
Expand Down
4 changes: 4 additions & 0 deletions Assets/Scripts/Gameplay/Managers/ArcArcManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ public void SetArcColors(
foreach (ArcArc arc in Arcs)
{
arc.arcRenderer.ReloadColor();
foreach (ArcArcTap arctap in arc.ArcTaps)
{
arctap.UpdateColor();
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Gameplay/Managers/ArcScoreManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private double CalculateSingleScore()
}
foreach (var arc in ArcArcManager.Instance.Arcs)
{
if (arc.NoInput())
if (arc.NoInput() || arc.Designant)
{
continue;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ private int CalculateCombo(int timing)
}
foreach (var arc in ArcArcManager.Instance.Arcs)
{
if (arc.NoInput())
if (arc.NoInput() || arc.Designant)
{
continue;
}
Expand Down
3 changes: 3 additions & 0 deletions Assets/Shader/ArcTap.shader
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Shader "Arcade/ArcTap"
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[PerRendererData] _Color ("Color", Color) = (1,1,1,1)
[PerRendererData] _Alpha ("Alpha", Float) = 1
}
SubShader
Expand Down Expand Up @@ -32,6 +33,7 @@ Shader "Arcade/ArcTap"
};

float _Alpha;
float4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;

Expand All @@ -46,6 +48,7 @@ Shader "Arcade/ArcTap"
half4 frag (v2f i) : SV_Target
{
half4 c = half4(tex2D(_MainTex,i.uv).rgb, _Alpha);
c *= _Color;
c.rgb *= c.a;
return c;
}
Expand Down

0 comments on commit 7388447

Please sign in to comment.