BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / GAME / Scripts / Components / Pushbutton.cs

Pushbutton.cs

09143ea9 History
Pushbutton.cs 904 B Download Raw
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class Pushbutton : Connectable
6{
7 public PushButtonOnClick OnClick;
8 [SerializeField] private float buttonRestPosition, buttonClickedPosition;
9 [SerializeField] private Transform buttonTransform;
10 private Tween pushTween = new Tween(Easing.Linear);
11
12 void Start()
13 {
14 pushTween.onChange = t =>
15 {
16 buttonTransform.localPosition = Curving.Lerp(new Vector3[]
17 {
18 new Vector3(0, buttonRestPosition, 0),
19 new Vector3(0, buttonClickedPosition, 0),
20 new Vector3(0, buttonRestPosition, 0)
21 }, t);
22 };
23 }
24
25 public override void Activate()
26 {
27 base.Activate();
28 pushTween.Start(0, 1, 0.6f);
29
30 OnClick?.Invoke();
31 }
32
33 public delegate void PushButtonOnClick();
34}