You've already forked Darklings-FightingGame
mirror of
https://github.com/izzy2lost/Darklings-FightingGame.git
synced 2026-03-10 11:35:19 -07:00
37 lines
736 B
C#
37 lines
736 B
C#
using Demonics.Utility;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class PlayerGhost : MonoBehaviour
|
|
{
|
|
[SerializeField] private float _ghostTime = default;
|
|
private SpriteRenderer _spriteRenderer = default;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
_spriteRenderer = GetComponent<SpriteRenderer>();
|
|
}
|
|
|
|
async void OnEnable()
|
|
{
|
|
StartCoroutine(GhostCoroutine());
|
|
}
|
|
|
|
IEnumerator GhostCoroutine()
|
|
{
|
|
yield return new WaitForSecondsRealtime(_ghostTime);
|
|
if (gameObject != null)
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void SetSprite(Sprite sprite, float flipSpriteValue, Color color)
|
|
{
|
|
_spriteRenderer.color = color;
|
|
_spriteRenderer.sprite = sprite;
|
|
transform.localScale = new Vector2(flipSpriteValue, 1.0f);
|
|
}
|
|
}
|