-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hide keyboard buttons after clicked
- Loading branch information
Showing
4 changed files
with
200 additions
and
1 deletion.
There are no files selected for viewing
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
52 changes: 52 additions & 0 deletions
52
...-fighters/Assets/Maple Fighters/Scripts/Gameplay/Map/Objects/ClickableKeyboardGuidance.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,52 @@ | ||
using UnityEngine; | ||
|
||
namespace Scripts.Gameplay.Map.Objects | ||
{ | ||
public class ClickableKeyboardGuidance : MonoBehaviour | ||
{ | ||
[SerializeField] | ||
private KeyCode primaryKeyCode; | ||
|
||
[SerializeField] | ||
private KeyCode secondaryKeyCode; | ||
|
||
[SerializeField] | ||
private float colorSpeed; | ||
|
||
private bool clicked; | ||
|
||
private new Animation animation; | ||
private SpriteRenderer spriteRenderer; | ||
|
||
private void Awake() | ||
{ | ||
animation = GetComponent<Animation>(); | ||
spriteRenderer = GetComponent<SpriteRenderer>(); | ||
} | ||
|
||
private void Update() | ||
{ | ||
if (clicked) | ||
{ | ||
DeacraseColor(); | ||
} | ||
else | ||
{ | ||
clicked = Input.GetKeyDown(primaryKeyCode) || Input.GetKeyDown(secondaryKeyCode); | ||
} | ||
} | ||
|
||
private void DeacraseColor() | ||
{ | ||
animation.Stop(); | ||
|
||
if (spriteRenderer.color.a <= 0) | ||
{ | ||
Destroy(gameObject); | ||
} | ||
|
||
var color = new Color(0, 0, 0, 1); | ||
spriteRenderer.color -= color * colorSpeed * Time.deltaTime; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ters/Assets/Maple Fighters/Scripts/Gameplay/Map/Objects/ClickableKeyboardGuidance.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.