-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
95 additions
and
13 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
Assets/Script/Game/Controllers/BreakSlideShineController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using MajdataPlay.Extensions; | ||
using MajdataPlay.Interfaces; | ||
using MajdataPlay.Types; | ||
using MajdataPlay.Utils; | ||
using System; | ||
using System.Buffers; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UnityEngine; | ||
#nullable enable | ||
namespace MajdataPlay.Game.Controllers | ||
{ | ||
public class BreakSlideShineController : MonoBehaviour | ||
{ | ||
public IFlasher? Parent { get; set; } = null; | ||
public SpriteRenderer[] Renderers { get; set; } = ArrayPool<SpriteRenderer>.Shared.Rent(0); | ||
|
||
NoteStatus _state = NoteStatus.Start; | ||
GamePlayManager _gpManager; | ||
|
||
public void Initialize() | ||
{ | ||
if (_state >= NoteStatus.Initialized) | ||
return; | ||
else if (Parent is null) | ||
throw new NullReferenceException(); | ||
_gpManager = MajInstanceHelper<GamePlayManager>.Instance!; | ||
if (Renderers.IsEmpty()) | ||
{ | ||
var parentObject = Parent.GameObject; | ||
var barCount = parentObject.transform.childCount - 1; | ||
Renderers = ArrayPool<SpriteRenderer>.Shared.Rent(barCount); | ||
for (int i = 0; i < barCount; i++) | ||
Renderers[i] = parentObject.transform.GetChild(i).GetComponent<SpriteRenderer>(); | ||
} | ||
} | ||
void Start() | ||
{ | ||
Initialize(); | ||
} | ||
void Update() | ||
{ | ||
if (Renderers.IsEmpty()) | ||
return; | ||
if (Parent is not null && Parent.CanShine) | ||
{ | ||
var param = _gpManager.BreakParam; | ||
foreach (var renderer in Renderers) | ||
{ | ||
if (renderer is null) | ||
continue; | ||
renderer.material.SetFloat("_Brightness", param.Brightness); | ||
renderer.material.SetFloat("_Contrast", param.Contrast); | ||
} | ||
} | ||
} | ||
void OnDestroy() | ||
{ | ||
ArrayPool<SpriteRenderer>.Shared.Return(Renderers); | ||
} | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Script/Game/Controllers/BreakSlideShineController.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters