Added crane stuff
This commit is contained in:
@@ -10,12 +10,28 @@ public class CraneControl : MonoBehaviour, IPointerEnterHandler, IPointerExitHan
|
||||
[SerializeField]
|
||||
private OutlineFx.OutlineFx _outline;
|
||||
|
||||
[SerializeField]
|
||||
private SpriteRenderer _renderer;
|
||||
|
||||
[SerializeField]
|
||||
private Sprite _closedSprite;
|
||||
|
||||
[SerializeField]
|
||||
private float _speed = 3;
|
||||
|
||||
[SerializeField]
|
||||
private UnityEvent _onHooked;
|
||||
|
||||
[Header("Audio")]
|
||||
[SerializeField]
|
||||
private AudioSource _startMoveAudio;
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource _moveLoopAudio;
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource _endMoveAudio;
|
||||
|
||||
private bool mouseIsDown = false;
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
@@ -29,10 +45,16 @@ public class CraneControl : MonoBehaviour, IPointerEnterHandler, IPointerExitHan
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
mouseIsDown = true;
|
||||
_startMoveAudio.Play();
|
||||
_moveLoopAudio.Play();
|
||||
_endMoveAudio.Stop();
|
||||
}
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
mouseIsDown = false;
|
||||
_startMoveAudio.Stop();
|
||||
_moveLoopAudio.Stop();
|
||||
_endMoveAudio.Play();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -72,6 +94,8 @@ public class CraneControl : MonoBehaviour, IPointerEnterHandler, IPointerExitHan
|
||||
other.transform.parent.SetParent(transform);
|
||||
other.transform.parent.localPosition = Vector3.zero;
|
||||
|
||||
_renderer.sprite = _closedSprite;
|
||||
|
||||
_onHooked.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user