예제 #1
0
    public void Start()
    {
        buttonBuy.onClick.AddListener(() => {
            if (null == GameManager.Instance.selectedUnit)
            {
                return;
            }

            HeroUnit unit = GameManager.Instance.selectedUnit;
            if (GameManager.Instance.gold < unit.info.purchasePrice)
            {
                GameManager.Instance.uiMessageBox.message = "골드가 부족 합니다";
                return;
            }
            GameManager.Instance.gold -= unit.info.purchasePrice;
            unit.purchased             = true;
            GameManager.Instance.selectedSlot.EquipUnit(unit);

            GameManager.Instance.selectedSlot = null;
            GameManager.Instance.selectedUnit = null;
            GameManager.Instance.uiHeroInfoPanel.gameObject.SetActive(false);
            GameManager.Instance.uiHeroShopPanel.gameObject.SetActive(false);
            GameManager.Instance.Save();
        });

        buttonEquip.onClick.AddListener(() => {
            if (null == GameManager.Instance.selectedUnit)
            {
                return;
            }

            HeroUnit unit = GameManager.Instance.selectedUnit;
            GameManager.Instance.selectedSlot.EquipUnit(unit);

            GameManager.Instance.selectedUnit = null;
            GameManager.Instance.selectedSlot = null;
            GameManager.Instance.uiHeroInfoPanel.gameObject.SetActive(false);
            GameManager.Instance.uiHeroShopPanel.gameObject.SetActive(false);
            GameManager.Instance.Save();
        });

        buttonLevelup.onClick.AddListener(() => {
            if (null == GameManager.Instance.selectedUnit)
            {
                return;
            }
            HeroUnit unit = GameManager.Instance.selectedUnit;
            unit.Upgrade();
            Init();
            contentHeroShop.SetUnit(unit);
            GameManager.Instance.Save();
        });
    }