Skip to content

Commit

Permalink
Merge pull request #141 from LeZi9916/master
Browse files Browse the repository at this point in the history
Special effects sprite optimization
  • Loading branch information
LingFeng-bbben authored Mar 14, 2024
2 parents f382be0 + 972fd9c commit 430a5df
Show file tree
Hide file tree
Showing 19 changed files with 1,421 additions and 315 deletions.
605 changes: 460 additions & 145 deletions Assets/Animation/breakEffect.anim

Large diffs are not rendered by default.

605 changes: 460 additions & 145 deletions Assets/Animation/tapEffect.anim

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions Assets/Scripts/Notes/HoldDrop.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using static UnityEditor.PlayerSettings;

public class HoldDrop : NoteLongDrop
{
Expand Down Expand Up @@ -130,30 +131,32 @@ private void Update()
Destroy(tapLine);
Destroy(holdEffect);
Destroy(gameObject);
return;
}


transform.rotation = Quaternion.Euler(0, 0, -22.5f + -45f * (startPosition - 1));
tapLine.transform.rotation = transform.rotation;
holdEffect.transform.position = getPositionFromDistance(4.8f);

if (destScale > 0.3f) tapLine.SetActive(true);

if (distance < 1.225f)
{
transform.localScale = new Vector3(destScale, destScale);
spriteRenderer.size = new Vector2(1.22f, 1.42f);
distance = 1.225f;
var pos = getPositionFromDistance(distance);
transform.position = pos;

if (destScale > 0.3f) tapLine.SetActive(true);
transform.position = pos;
}
else
{
if (holdDistance < 1.225f && distance >= 4.8f) // 头到达 尾未出现
{
holdDistance = 1.225f;
distance = 4.8f;
holdEffect.SetActive(true);
//holdEffect.SetActive(true);
PlayHoldEffect();
startHoldShine();
}
else if (holdDistance < 1.225f && distance < 4.8f) // 头未到达 尾未出现
Expand All @@ -163,7 +166,8 @@ private void Update()
else if (holdDistance >= 1.225f && distance >= 4.8f) // 头到达 尾出现
{
distance = 4.8f;
holdEffect.SetActive(true);
//holdEffect.SetActive(true);
PlayHoldEffect();
startHoldShine();

holdEndRender.enabled = true;
Expand All @@ -190,13 +194,19 @@ private void Update()

private void startHoldShine()
{
if (!holdAnimStart)
{
GameObject.Find("NoteEffects").GetComponent<NoteEffectManager>().ResetEffect(startPosition);
if (!holdAnimStart && timeProvider.AudioTime - time > 0.1)
{
holdAnimStart = true;
animator.runtimeAnimatorController = HoldShine;
animator.enabled = true;
}
}
void PlayHoldEffect()
{
if (timeProvider.AudioTime - time > 0.1) holdEffect.SetActive(true);
else holdEffect.SetActive(false);
}

private Vector3 getPositionFromDistance(float distance)
{
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/Notes/NoteEffectManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using static UnityEditor.PlayerSettings;

public class NoteEffectManager : MonoBehaviour
{
Expand Down Expand Up @@ -53,6 +54,7 @@ public void PlayEffect(int position, bool isBreak)
{
var pos = position - 1;
tapEffects[pos].SetActive(true);
tapAnimators[pos].speed = 0.9f;
if (isBreak)
{
tapAnimators[pos].SetTrigger("break");
Expand All @@ -64,4 +66,5 @@ public void PlayEffect(int position, bool isBreak)
judgeAnimators[pos].SetTrigger("perfect");
}
}
public void ResetEffect(int position) => tapEffects[position - 1].SetActive(false);
}
29 changes: 25 additions & 4 deletions Assets/Scripts/Notes/SlideDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class SlideDrop : NoteLongDrop

public int sortIndex;

public float fadeInTime;

public float fullFadeInTime;

public List<int> areaStep = new List<int>();
public bool smoothSlideAnime = false;

Expand All @@ -52,19 +56,36 @@ public class SlideDrop : NoteLongDrop
private void Start()
{
timeProvider = GameObject.Find("AudioTimeProvider").GetComponent<AudioTimeProvider>();

// 计算Slide淡入时机
// 在8.0速时应当提前300ms显示Slide
fadeInTime = -3.926913f / speed ;
// Slide完全淡入时机
// 正常情况下应为负值;速度过高将忽略淡入
fullFadeInTime = Math.Min(fadeInTime + 0.2f,0);
}

// Update is called once per frame
private void Update()
{
// Slide淡入期间,不透明度从0到0.55耗时200ms
var startiming = timeProvider.AudioTime - timeStar;
if (startiming <= 0f)
{
var alpha = startiming * (speed / 3.9269f) + 1f;
if(fullFadeInTime == 0 || startiming >= fullFadeInTime)
setSlideBarAlpha(0.65f);
if (startiming < fadeInTime)
setSlideBarAlpha(0);
else
{
var alpha = Math.Min((1 - ((startiming - fullFadeInTime) / -0.2f)),1) * 0.55f;
setSlideBarAlpha(alpha);
}
//var alpha = startiming * (speed / 3.9269f) + 1f;
//alpha *= 0.85f;
alpha = alpha > 0.6f ? 0.6f : alpha;
alpha = alpha < 0f ? 0f : alpha;
setSlideBarAlpha(alpha);
//alpha = alpha > 0.6f ? 0.6f : alpha;
//alpha = alpha < 0f ? 0f : alpha;
//setSlideBarAlpha(alpha);
return;
}

Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/Notes/StarDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,15 @@ private void Update()

tapLine.transform.rotation = Quaternion.Euler(0, 0, -22.5f + -45f * (startPosition - 1));

if (destScale > 0.3f && !isNoHead) tapLine.SetActive(true);

if (distance < 1.225f)
{
transform.localScale = new Vector3(destScale, destScale);

distance = 1.225f;
var pos = getPositionFromDistance(distance);
transform.position = pos;
if (destScale > 0.3f && !isNoHead) tapLine.SetActive(true);
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/Notes/TapDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,16 @@ private void Update()
transform.rotation = Quaternion.Euler(0, 0, -22.5f + -45f * (startPosition - 1));
tapLine.transform.rotation = Quaternion.Euler(0, 0, -22.5f + -45f * (startPosition - 1));


if (destScale > 0.3f) tapLine.SetActive(true);

if (distance < 1.225f)
{
transform.localScale = new Vector3(destScale, destScale);

distance = 1.225f;
var pos = getPositionFromDistance(distance);
transform.position = pos;
if (destScale > 0.3f) tapLine.SetActive(true);
transform.position = pos;
}
else
{
Expand Down
30 changes: 26 additions & 4 deletions Assets/Scripts/Notes/WifiDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class WifiDrop : NoteLongDrop

public int sortIndex;

public float fadeInTime;

public float fullFadeInTime;

public List<int> areaStep = new List<int>();
public bool smoothSlideAnime = false;

Expand All @@ -53,6 +57,13 @@ public class WifiDrop : NoteLongDrop

private void Start()
{
// 计算Slide淡入时机
// 在8.0速时应当提前300ms显示Slide
fadeInTime = -3.926913f / speed;
// Slide完全淡入时机
// 正常情况下应为负值;速度过高将忽略淡入
fullFadeInTime = Math.Min(fadeInTime + 0.2f, 0);

timeProvider = GameObject.Find("AudioTimeProvider").GetComponent<AudioTimeProvider>();
var notes = GameObject.Find("Notes").transform;
for (var i = 0; i < star_slide.Length; i++)
Expand Down Expand Up @@ -116,13 +127,24 @@ private void Start()
// Update is called once per frame
private void Update()
{
// Wifi Slide淡入期间,不透明度从0到1耗时200ms
var startiming = timeProvider.AudioTime - timeStart;
if (startiming <= 0f)
{
var alpha = startiming * (speed / 3.9269f) + 1f;
alpha = alpha > 1f ? 1f : alpha;
alpha = alpha < 0f ? 0f : alpha;
setSlideBarAlpha(alpha);
if (fullFadeInTime == 0 || startiming >= fullFadeInTime)
setSlideBarAlpha(1);
if (startiming < fadeInTime)
setSlideBarAlpha(0);
else
{
var alpha = Math.Min((1 - ((startiming - fullFadeInTime) / -0.2f)), 1);
setSlideBarAlpha(alpha);
}
//var alpha = startiming * (speed / 3.9269f) + 1f;
//alpha *= 0.85f;
//alpha = alpha > 0.6f ? 0.6f : alpha;
//alpha = alpha < 0f ? 0f : alpha;
//setSlideBarAlpha(alpha);
return;
}

Expand Down
Binary file modified Assets/Sprite/Hex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 41 additions & 6 deletions Assets/Sprite/Hex.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Sprite/HexBackup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 430a5df

Please sign in to comment.