Пример #1
0
    /// <summary>
    /// 点击英雄面板
    /// </summary>
    public void OnHeroPanelClick(UIHeroShop_PanelHero heroPanel)
    {
        currentSelectHeroPanel = heroPanel;
        DRHeroShop drHeroShop = heroPanel.GetHeroShop();

        // 显示/隐藏购买按钮
        if (PlayerData.HasHero(drHeroShop.Id))
        {
            buttonBuy.SetActive(false);
            string boughtText = GameEntry.Localization.GetString("HeroShop.Bought");

            // 显示/隐藏出战按钮
            if (PlayerData.CurrentFightHeroID != drHeroShop.Id)
            {
                buttonFight.SetActive(true);
                textPrice.text = $"{boughtText}";
            }
            else
            {
                buttonFight.SetActive(false);

                string fightText = GameEntry.Localization.GetString("HeroShop.Fight");
                textPrice.text = $"{boughtText},{fightText}";
            }
        }
        else
        {
            buttonBuy.SetActive(true);
            buttonFight.SetActive(false);
            string goldText = GameEntry.Localization.GetString("Message.Gold");
            textPrice.text = $"{drHeroShop.Price}{goldText}";
        }
    }
Пример #2
0
    protected override void OnInit(object userData)
    {
        base.OnInit(userData);

        /* 创建英雄面板 */
        IDataTable <DRHeroShop> dtHeroShop = GameEntry.DataTable.GetDataTable <DRHeroShop> ();

        DRHeroShop[] drHeroShops = dtHeroShop.GetAllDataRows();

        string assetName = AssetUtility.GetUIFormAsset("UIHeroShop_PanelHero");

        GameEntry.Resource.LoadAsset(assetName, new LoadAssetCallbacks(
                                         (_assetName, _asset, _duration, _userData) => {
            foreach (DRHeroShop drHeroShop in drHeroShops)
            {
                GameObject panelHeroObj = (GameObject)Instantiate((Object)_asset);
                panelHeroObj.transform.SetParent(panelHeroParent, false);

                UIHeroShop_PanelHero panelHero = panelHeroObj.GetComponent <UIHeroShop_PanelHero> ();
                panelHero.Init(drHeroShop, OnHeroPanelClick);
            }
        }
                                         ));
    }