コード例 #1
0
    public void ShowCardItem(UserCardItem card)
    {
        if (card == null)
        {
            return;
        }

        GameObject newItem = CardListItemPool.Instance.GetListItem("CardSellItem");//(GameObject)Instantiate(cardPrefab);

        if (newItem == null)
        {
            return;
        }

        newItem.transform.parent        = listParent.transform;
        newItem.transform.localPosition = new Vector3(0, 0, -1);
        newItem.transform.localScale    = new Vector3(1, 1, 1);
        newItem.name = card.cardID.ToString();
        items.Add(newItem);
        //			UIEventListener.Get(newItem).onClick +=

        Tab_Card tabCard = TableManager.GetCardByID(card.templateID);

        Transform labNameTrans = newItem.transform.FindChild("Labels/Label-Name");

        if (labNameTrans != null &&
            tabCard != null)
        {
            Tab_Appearance tabAppearance = TableManager.GetAppearanceByID(tabCard.Appearance);
            if (tabAppearance != null)
            {
                UILabel nameLabel = labNameTrans.GetComponent <UILabel>();
                if (nameLabel != null)
                {
                    int nameLangId = tabAppearance.Name;
                    nameLabel.text = LanguageManger.GetWords(nameLangId);
                }
            }
        }


        //------------------------卡牌背景及外框--------------------------------
        //2013-10-12 Jack Wen
        Transform tranSpBg = newItem.transform.FindChild("CardIcon/CardIconBtn/Sprite-BG");

        if (tranSpBg != null &&
            tabCard != null)
        {
            UISprite icon_bg = tranSpBg.GetComponent <UISprite>();
            if (icon_bg != null)
            {
                icon_bg.spriteName = UserCardItem.littleCardFrameName[tabCard.Star];
            }
        }

        Transform tranSp_Outside = newItem.transform.FindChild("CardIcon/CardIconBtn/sp-Outside");

        if (tranSp_Outside != null &&
            tabCard != null)
        {
            UISprite icon_border = tranSp_Outside.GetComponent <UISprite>();
            icon_border.spriteName = UserCardItem.littleCardBorderName[tabCard.Star];
        }
        //--------------------------------------------------------------------

        Transform transLabel_lev_value = newItem.transform.FindChild("Labels/Label-Level-Value");

        if (transLabel_lev_value != null)
        {
            UILabel cardLevelLabel = transLabel_lev_value.GetComponent <UILabel>();
            if (cardLevelLabel != null)
            {
                cardLevelLabel.text = card.level.ToString();
            }
        }
        //UILabel cardLevelLabel = newItem.transform.FindChild("Labels/Label-Level-Value").GetComponent<UILabel>();


        Transform tranLab_Hp_Val = newItem.transform.FindChild("Labels/Label-Hp-Value");

        if (tranLab_Hp_Val != null)
        {
            UILabel cardHPLabel = tranLab_Hp_Val.GetComponent <UILabel>();
            if (cardHPLabel != null)
            {
                cardHPLabel.text = card.GetHp().ToString();
            }
        }

        Transform tranLab_Att_Val = newItem.transform.FindChild("Labels/Label-Attack-Value");

        if (tranLab_Att_Val != null)
        {
            UILabel cardAttackValueLabel = tranLab_Att_Val.GetComponent <UILabel>();
            if (cardAttackValueLabel != null)
            {
                cardAttackValueLabel.text = card.GetAttack().ToString();
            }
        }

        Transform tranLab_Mony_Val = newItem.transform.FindChild("Labels/Label-Money-Value");

        if (tranLab_Mony_Val != null)
        {
            UILabel cardMoneyValueLabel = tranLab_Mony_Val.GetComponent <UILabel>();
            if (cardMoneyValueLabel != null)
            {
                cardMoneyValueLabel.text = card.GetMoneyValue().ToString();
            }
        }


        Transform tranSp_Icon = newItem.transform.FindChild("CardIcon/CardIconBtn/Sprite-Icon");

        if (tranSp_Icon != null)
        {
            UISprite       icon          = tranSp_Icon.GetComponent <UISprite>();
            Tab_Appearance tabAppearance = TableManager.GetAppearanceByID(tabCard.Appearance);
            if (icon != null &&
                tabAppearance != null)
            {
                icon.spriteName = tabAppearance.HeadIcon;
            }
        }


        //星级显示
        Transform transformStars = newItem.transform.FindChild("Stars");

        if (transformStars != null)
        {
            for (int j = 1; j <= 7; j++)
            {
                if (j <= card.quality)
                {
                    Transform tranStar = transformStars.FindChild("star_" + j);
                    if (tranStar != null)
                    {
                        tranStar.gameObject.SetActive(true);
                    }
                }
                else
                {
                    Transform tranStar = transformStars.FindChild("star_" + j);
                    if (tranStar != null)
                    {
                        tranStar.gameObject.SetActive(false);
                    }
                }
            }
        }


        Transform tranSp_Selected = newItem.transform.FindChild("Sprites/Sprite-Selected");

        if (tranSp_Selected != null)
        {
            UISprite selectSprite = tranSp_Selected.GetComponent <UISprite>();
            //设置显示状态
            if (CheckIfChooseItem(card))
            {
                if (selectSprite != null)
                {
                    selectSprite.gameObject.SetActive(true);
                }
            }
            else
            {
                if (selectSprite != null)
                {
                    selectSprite.gameObject.SetActive(false);
                }
            }
        }



        //五行图标显示
        Transform tranSpAttribut = newItem.transform.FindChild("Sprite-Attribute");

        if (tranSpAttribut != null)
        {
            UISprite sttributeIcon = tranSpAttribut.GetComponent <UISprite>();
            if (sttributeIcon != null)
            {
                sttributeIcon.spriteName = card.GetAttributeIconName();
            }
        }



//         UISprite selectSprite = newItem.transform.FindChild("Sprites/Sprite-Selected").GetComponent<UISprite>();
//         selectSprite.gameObject.SetActive(false);

        UIEventListener.Get(newItem).onClick += OnSelectItem;
        Transform tranCardIconBtn = newItem.transform.FindChild("CardIcon/CardIconBtn");

        if (tranCardIconBtn != null)
        {
            GameObject CardIconBtn = tranCardIconBtn.gameObject;
            UIEventListener.Get(CardIconBtn).onClick += ShowCardInfo;
        }
    }
コード例 #2
0
    public void ShowCardItem(UserCardItem card)
    {
        if (card == null)
        {
            return;
        }

        //GameObject newItem = ResourceManager.Instance.loadWidget(listItem);//(GameObject)Instantiate(listItem);
        GameObject newItem = CardListItemPool.Instance.GetListItem(listItem);

        newItem.transform.parent        = listParent.transform;
        newItem.transform.localPosition = new Vector3(0, 0, -2);
        newItem.transform.localScale    = new Vector3(1, 1, 1);
        newItem.name = card.cardID.ToString();
        items.Add(newItem);
        currentPageCount++;
        UIEventListener.Get(newItem).onClick += ShowCardInfo;
        //------------------------卡牌背景及外框--------------------------------
        //2013-10-12 Jack Wen
        UISprite icon_bg     = newItem.transform.FindChild("CardIcon/Button-CardIcon/SpriteBG").GetComponent <UISprite>();
        UISprite icon_border = newItem.transform.FindChild("CardIcon/Button-CardIcon/Sprite").GetComponent <UISprite>();
        int      icon_star   = TableManager.GetCardByID(card.templateID).Star;

        icon_bg.spriteName     = UserCardItem.littleCardFrameName[icon_star];
        icon_border.spriteName = UserCardItem.littleCardBorderName[icon_star];
        //--------------------------------------------------------------------
        UILabel nameLabel  = newItem.transform.FindChild("Labels/Label-Name").GetComponent <UILabel>();
        int     nameLangId = TableManager.GetAppearanceByID(TableManager.GetCardByID(card.templateID).Appearance).Name;

        nameLabel.text = LanguageManger.GetWords(nameLangId);

        UILabel lifeLabel = newItem.transform.FindChild("Labels/Label-Hp-Value").GetComponent <UILabel>();

        lifeLabel.text = (card.GetHp()).ToString();

        UILabel attackLabel = newItem.transform.FindChild("Labels/Label-Attack-Value").GetComponent <UILabel>();

        attackLabel.text = (card.GetAttack()).ToString();

        UILabel levelLabel = newItem.transform.FindChild("Labels/Label-Level-Value").GetComponent <UILabel>();

        levelLabel.text = card.level.ToString();

        //UIPanel panel = newItem.GetComponent<UIPanel>();

        //让图标无响应
        //newItem.transform.FindChild("CardIcon/Button-CardIcon").GetComponent<BoxCollider>().enabled = false;
        // GameObject CardIconBtn = newItem.transform.FindChild("CardIcon/Button-CardIcon").gameObject;
        UIEventListener.Get(newItem).onClick += ShowCardInfo;

        //星级显示
        Transform transformStars = newItem.transform.FindChild("Stars");

        for (int j = 1; j <= 7; j++)
        {
            if (j <= card.quality)
            {
                GameObject starIcon = transformStars.FindChild("star_" + j).gameObject;
                starIcon.SetActive(true);
            }
            else
            {
                GameObject starIcon = transformStars.FindChild("star_" + j).gameObject;
                starIcon.SetActive(false);
            }
        }

        //五行图标显示
        UISprite sttributeIcon = newItem.transform.FindChild("Sprite-Attribute").GetComponent <UISprite>();

        sttributeIcon.spriteName = card.GetAttributeIconName();

        UISprite icon = newItem.transform.FindChild("CardIcon/Button-CardIcon/Sprite-Icon").GetComponent <UISprite>();

        icon.spriteName = TableManager.GetAppearanceByID(TableManager.GetCardByID(card.templateID).Appearance).HeadIcon;

        UILabel protectedLabel = newItem.transform.FindChild("Labels/Label-Is-Protected").GetComponent <UILabel>();
        bool    isMember       = false;

        for (int i = 0; i < Obj_MyselfPlayer.GetMe().teamMemberArray.Length; i++)
        {
            if (Obj_MyselfPlayer.GetMe().teamMemberArray[i] == card.cardID)
            {
                isMember = true;
            }
        }

        //判断卡牌是否被保护
        if (card.isProtected)
        {
            newItem.transform.FindChild("Sprites/sp-suo").gameObject.SetActive(true);
        }
        else
        {
            newItem.transform.FindChild("Sprites/sp-suo").gameObject.SetActive(false);
        }

        //显示是否上场
        if (isMember)
        {
            protectedLabel.text = "上场";
        }
        else
        {
            protectedLabel.text = "";
        }
    }
コード例 #3
0
    public bool InitWithUserCardItem(UserCardItem card)
    {
        transform.localPosition = new Vector3(0, 0, -1);
        transform.localScale    = new Vector3(1, 1, 1);
        gameObject.name         = card.cardID.ToString();

        if (card == null)
        {
            return(false);
        }

        //读表双重验证
        Tab_Card tabCard = TableManager.GetCardByID(card.templateID);

        if (tabCard == null)
        {
            return(false);
        }
        Tab_Appearance tabApp = TableManager.GetAppearanceByID(tabCard.Appearance);

        if (tabApp == null)
        {
            return(false);
        }

        iconCard.spriteName = tabApp.HeadIcon;
        //------------------------卡牌背景及外框--------------------------------
        //2013-10-12 Jack Wen
        int icon_star = tabCard.Star;

        iconBG.spriteName    = UserCardItem.littleCardFrameName[icon_star];
        iconFrame.spriteName = UserCardItem.littleCardBorderName[icon_star];
        //--------------------------------------------------------------------

        int nameLangId = tabApp.Name;

        labelName.text      = LanguageManger.GetWords(nameLangId);
        labelHP.text        = card.GetHp().ToString();
        labelAttack.text    = card.GetAttack().ToString();
        labelCardLevel.text = card.level.ToString();
        HideSelected();

        //等级状态显示
        labelMaxLevel.text = card.level.ToString() + "/" + tabCard.MaxLevel;

        //五行图标显示
        attribute.spriteName = card.GetAttributeIconName();


        //星级显示
        for (int j = 1; j <= 7; j++)
        {
            if (j <= card.quality)
            {
                starArray[j - 1].SetActive(true);
            }
            else
            {
                starArray[j - 1].SetActive(false);
            }
        }

        return(true);
    }