mycj_demo/mycj/Assets/Script/paotaInfo.cs
2024-12-02 09:37:47 +08:00

50 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class paotaInfo : MonoBehaviour
{
[Header("范围显示")]
public RectTransform fanwei;
[Header("2d圆形碰撞体")]
public CircleCollider2D _CircleCollider2D;
[Header("范围值,指半径")]
public float fanweiNumber;
public Button UpBTN;
// Start is called before the first frame update
void Start()
{
Init();
UpBTN.onClick.AddListener(()=> {
UpLevel();
});
UpBTN.gameObject.SetActive(false);
PlayerInfo.instance.OnGoldReachedThreshold += ShowUpBTN;
}
private void OnDestroy()
{
PlayerInfo.instance.OnGoldReachedThreshold -= ShowUpBTN;
}
void ShowUpBTN() {
UpBTN.gameObject.SetActive(true);
}
public void Init()
{
fanwei.sizeDelta = new Vector2(fanweiNumber*2, fanweiNumber * 2);
_CircleCollider2D.radius = fanweiNumber;
}
void UpLevel()
{
float a = fanweiNumber * 1.5f;
fanwei.sizeDelta = new Vector2(a * 2f, a * 2f);
_CircleCollider2D.radius = a;
}
}