46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class Chip : MonoBehaviour
|
|
{
|
|
public float value;
|
|
public Vector3 defScale{get; private set;}
|
|
|
|
|
|
void Awake(){
|
|
defScale = transform.localScale;
|
|
if(RouletteManager.RegisterChip(this)){
|
|
RouletteManager.OnMoneyAvailablChanged.AddListener(OnMoneyChanged);
|
|
GetComponent<Button>().onClick.AddListener(OnClicked);
|
|
}else{
|
|
GetComponent<Image>().raycastTarget = false;
|
|
}
|
|
}
|
|
|
|
|
|
void OnMoneyChanged(float newMoney){
|
|
GetComponent<Button>().interactable = newMoney >= value;
|
|
}
|
|
|
|
void OnClicked(){
|
|
RouletteManager.SelectedChip = value;
|
|
}
|
|
|
|
public void OnSelectedChanged(float newVal){
|
|
// outline.effectColor = new Color(1,1,1, (newVal == value) ? 0.5f : 0);
|
|
transform.localScale = defScale *( (newVal == value) ? 1.3f : 1);
|
|
}
|
|
|
|
|
|
void OnValidate(){
|
|
if(value == 0){
|
|
try{
|
|
value = float.Parse(gameObject.name.Replace("chip_",""));
|
|
}catch{}
|
|
}
|
|
}
|
|
}
|