using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class WeaponUpgradePandle : MonoBehaviour { public static WeaponUpgradePandle instance; public Image weaponsImage; public Text weaponNameText; public Text upgradePrinceText; public Text playerMoneyText; public Text nowLevelText; public Text nextLevelText; public Button upgradeButton; public SingleWeapon singleWeapon; public Transform weaponsScrollView; //调用其他的类 public Character character; //public TownInfo townInfo; // Start is called before the first frame update private void Awake() { instance = this; } // Start is called before the first frame update void Start() { OpenWeaponTradePanel(); } void Update() { playerMoneyText.text = character.money + ""; } public void OpenWeaponTradePanel() { //transform.DOScale(1, 0.3f); /*for (int i = 0; i < weaponsScrollView.childCount; i++) { Destroy(sellsScrollView.GetChild(i).gameObject); } for (int i = 0; i < townInfo.goodsInTown.Count; i++) { GameObject gameObject = Instantiate(townInfo.goodsInTown[i], sellsScrollView, false); //gameObject.transform.DOScale(1, 0.3f); //gameObject.transform.rotation = Quaternion.identity; }*/ Debug.Log("剩余金钱为"+character.money); playerMoneyText.text = character.money + ""; weaponsImage.enabled = false; upgradePrinceText.text = ""; nowLevelText.text = ""; nextLevelText.text = ""; upgradeButton.interactable = false; //sellButton.interactable = false; } public void CloseWeaponTradePanel() { if (singleWeapon != null) { singleWeapon.WeaponNameText.color = Color.white; singleWeapon = null; } weaponsImage.enabled = false; upgradePrinceText.text = ""; nowLevelText.text = ""; nextLevelText.text = ""; upgradeButton.interactable = false; gameObject.SetActive(false); } public void UpdateUI() { if (singleWeapon != null) { nowLevelText.text = singleWeapon.weapon.level+""; nextLevelText.text = (singleWeapon.weapon.level + 1) + ""; weaponsImage.enabled = true; weaponsImage.sprite = singleWeapon.weaponSprite; upgradePrinceText.text = (singleWeapon.weapon.level+1)*10 + ""; upgradeButton.interactable = true; playerMoneyText.text = character.money + ""; } } public void UpgradeWeapons() { if (character.money >= singleWeapon.UpgradePrice) { character.money -= singleWeapon.UpgradePrice; singleWeapon.weapon.level += 1; UpdateUI(); } } }