65 lines
1.4 KiB
C#
65 lines
1.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class BtClick : MonoBehaviour
|
|
{
|
|
public Sprite clickSprite;
|
|
private Sprite defaultSprite;
|
|
|
|
public CarType carType;
|
|
private Image image;
|
|
public event Action OnStartCompleted;
|
|
private void Awake()
|
|
{
|
|
image = this.GetComponent<Image>();
|
|
defaultSprite = image.sprite;
|
|
}
|
|
|
|
|
|
private void Start()
|
|
{
|
|
switch (carType)
|
|
{
|
|
case CarType.首页:
|
|
GameManager.instance.home.Add(this.GetComponent<BtClick>());
|
|
|
|
break;
|
|
case CarType.车类型:
|
|
GameManager.instance.carType.Add(this.GetComponent<BtClick>());
|
|
|
|
break;
|
|
case CarType.天气:
|
|
GameManager.instance.weather.Add(this.GetComponent<BtClick>());
|
|
|
|
break;
|
|
case CarType.危险驾驶:
|
|
GameManager.instance.dangerDriving.Add(this.GetComponent<BtClick>());
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
this.GetComponent<Button>().onClick.AddListener(delegate
|
|
{
|
|
|
|
GameManager.instance.UIClick(this.name,carType);
|
|
Click();
|
|
});
|
|
|
|
|
|
OnStartCompleted?.Invoke();
|
|
}
|
|
|
|
public void Click()
|
|
{
|
|
image.sprite = clickSprite;
|
|
}
|
|
|
|
public void Cancel()
|
|
{
|
|
image.sprite = defaultSprite;
|
|
}
|
|
} |