89 lines
2.6 KiB
C#
89 lines
2.6 KiB
C#
|
|
using UnityEngine;
|
||
|
|
using TMPro;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
using DG.Tweening;
|
||
|
|
|
||
|
|
public class CryptoCoinScroll : MonoBehaviour
|
||
|
|
{
|
||
|
|
[SerializeField] private TMP_Text headingText;
|
||
|
|
|
||
|
|
[Space]
|
||
|
|
|
||
|
|
[SerializeField] private Button diviCoinButton;
|
||
|
|
[SerializeField] private Button bitCoinButton;
|
||
|
|
[SerializeField] private Button liteCoinButton;
|
||
|
|
|
||
|
|
[Space]
|
||
|
|
|
||
|
|
[SerializeField] private Button returnButton;
|
||
|
|
|
||
|
|
[Space]
|
||
|
|
|
||
|
|
[SerializeField] Image currencyIcon;
|
||
|
|
[SerializeField] Sprite diviCurrencySprite;
|
||
|
|
[SerializeField] Sprite bitCoinCurrencySprite;
|
||
|
|
[SerializeField] Sprite liteCoinCurrencySprite;
|
||
|
|
|
||
|
|
|
||
|
|
// 0 = litecoin, 1 = diviCoin, 2 = bitCoin
|
||
|
|
private int coinIndex;
|
||
|
|
|
||
|
|
private Vector3 unFocusedScale = Vector3.one / 2;
|
||
|
|
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
//default state.
|
||
|
|
OnClickedDiviButton();
|
||
|
|
|
||
|
|
diviCoinButton.onClick.AddListener(OnClickedDiviButton);
|
||
|
|
bitCoinButton.onClick.AddListener(OnClickedBitCoinButton);
|
||
|
|
liteCoinButton.onClick.AddListener(OnClickedLiteCoinButton);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private void OnClickedLiteCoinButton()
|
||
|
|
{
|
||
|
|
coinIndex = 0;
|
||
|
|
headingText.text = "Litecoin";
|
||
|
|
currencyIcon.sprite = liteCoinCurrencySprite;
|
||
|
|
ScaleObjects(diviCoinButton.gameObject, unFocusedScale, 0.15f, false);
|
||
|
|
ScaleObjects(bitCoinButton.gameObject, unFocusedScale, 0.15f, false);
|
||
|
|
ScaleObjects(liteCoinButton.gameObject, Vector3.one, 0.25f, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnClickedDiviButton()
|
||
|
|
{
|
||
|
|
coinIndex = 1;
|
||
|
|
headingText.text = "Divi";
|
||
|
|
currencyIcon.sprite = diviCurrencySprite;
|
||
|
|
ScaleObjects(diviCoinButton.gameObject, Vector3.one, 0.25f, true);
|
||
|
|
ScaleObjects(bitCoinButton.gameObject, unFocusedScale, 0.15f, false);
|
||
|
|
ScaleObjects(liteCoinButton.gameObject, unFocusedScale, 0.25f, false);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnClickedBitCoinButton()
|
||
|
|
{
|
||
|
|
coinIndex = 2;
|
||
|
|
headingText.text = "Bitcoin";
|
||
|
|
currencyIcon.sprite = bitCoinCurrencySprite;
|
||
|
|
ScaleObjects(diviCoinButton.gameObject, unFocusedScale, 0.25f, false);
|
||
|
|
ScaleObjects(bitCoinButton.gameObject, Vector3.one, 0.15f, true);
|
||
|
|
ScaleObjects(liteCoinButton.gameObject, unFocusedScale, 0.25f, false);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private void ScaleObjects(GameObject objectToAffect, Vector3 scale, float completeTime, bool easeIn = false)
|
||
|
|
{
|
||
|
|
float weight = easeIn == true ? 1.0f : 0.5f;
|
||
|
|
objectToAffect.transform.DOScale(scale, completeTime).SetEase(Ease.InSine);
|
||
|
|
Image image = objectToAffect.GetComponent<Image>();
|
||
|
|
image.DOFade(weight, completeTime / 2).SetEase(Ease.InSine);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void RequestCryptoWalletDataPacket()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|