2022-01-10 15:15:06 +01:00
|
|
|
using System.Collections;
|
2021-09-25 21:18:24 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class PlayerGhost : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private float _ghostTime = default;
|
2022-09-14 23:06:52 +03:00
|
|
|
private SpriteRenderer _spriteRenderer;
|
2021-09-25 21:18:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
_spriteRenderer = GetComponent<SpriteRenderer>();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-05 19:47:55 +01:00
|
|
|
void OnEnable()
|
2021-09-25 21:18:24 +02:00
|
|
|
{
|
2022-01-10 15:15:06 +01:00
|
|
|
StartCoroutine(GhostCoroutine());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator GhostCoroutine()
|
|
|
|
|
{
|
|
|
|
|
yield return new WaitForSecondsRealtime(_ghostTime);
|
2021-12-01 17:52:38 +01:00
|
|
|
if (gameObject != null)
|
|
|
|
|
{
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
}
|
2021-09-25 21:18:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetSprite(Sprite sprite, float flipSpriteValue, Color color)
|
|
|
|
|
{
|
|
|
|
|
_spriteRenderer.color = color;
|
|
|
|
|
_spriteRenderer.sprite = sprite;
|
|
|
|
|
transform.localScale = new Vector2(flipSpriteValue, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|