InteractionObject.cs 868 Bytes
Newer Older
Sebastian Frey's avatar
Sebastian Frey committed
1
using UnityEngine;
2
using _Game.Scripts.Scriptable_Object;
Sebastian Frey's avatar
Sebastian Frey committed
3
4
5
6
7

namespace _Game.Scripts.Elements
{
	public class InteractionObject : MonoBehaviour
	{
8
9
10
11
12
13
14
15
16
17
18
19
20
		[SerializeField] private float _cooldown;
		private bool _isReady = true;
		private SpriteRenderer _spriteRenderer;
		private Color _defaultColor;
		private Color _idleColor;

		private void Start()
		{
			_spriteRenderer = GetComponent<SpriteRenderer>();
			_defaultColor = _spriteRenderer.color;
			_idleColor = new Color(_defaultColor.r, _defaultColor.g, _defaultColor.b, 0);
		}

21
		public void InfuseElement()
Sebastian Frey's avatar
Sebastian Frey committed
22
		{
Sebastian's avatar
Sebastian committed
23
			print("Infused " + this.gameObject.tag);
24
25
26
27
28
29
30
31
32
			_isReady = false;
			_spriteRenderer.color = _idleColor;
			Invoke("SetReady", _cooldown);
		}

		private void SetReady()
		{
			_isReady = true;
			_spriteRenderer.color = _defaultColor;
Sebastian Frey's avatar
Sebastian Frey committed
33
		}
34

35
		public bool GetIsReady()
36
		{
37
			return _isReady;
38
		}
Sebastian Frey's avatar
Sebastian Frey committed
39
40
	}
}