Exemple #1
0
        //初始化怪物卡牌
        public void InitMonsterCard(MonsterTemplate _monster)
        {
            Parent = selfTransform.FindChild("Parent");
            Image Boss_Image = Parent.FindChild("Boss_Image").GetComponent <Image>();

            CardNameText      = Parent.FindChild("Name_txt").GetComponent <Text>();
            _CardLevelText    = Parent.FindChild("Level_txt");
            CardImage         = Parent.FindChild("Icon_Img").GetComponent <Image>();
            CardStar          = _monster.getMonsterstar();
            maxStar           = _monster.getMonstermaxstar();
            CardLevel         = _monster.getMonsterlevel();
            CardName          = GameUtils.getString(_monster.getMonstername());
            CardNameText.text = CardName;//名称
            InterfaceControler.GetInst().AddLevelNum(CardLevel.ToString(), _CardLevelText, url);
            _Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(_monster.getArtresources());
            Sprite _img = UIResourceMgr.LoadSprite(common.defaultPath + _Artresourcedata.getHeadiconresource());

            CardImage.sprite = _img;//图片

            for (int i = 0; i < 5; i++)
            {
                Image temp = Parent.FindChild("Star_Image").GetChild(i).GetComponent <Image>();
                temp.enabled = i < maxStar;

                temp         = Parent.FindChild("Star_Image").GetChild(i + 5).GetComponent <Image>();
                temp.enabled = i < CardStar;
            }

            Boss_Image.enabled = _monster.getMonstertype() == 2 ? true : false;
        }
    private string GetBossName(StageTemplate stageData)
    {
        MonstergroupTemplate _monsterGroup = null;
        MonsterTemplate      _bossTemp     = null;

        for (int i = stageData.m_monstergroup.Length - 1; i >= 0; i--)
        {
            _monsterGroup = null;
            _bossTemp     = null;
            if (stageData.m_monstergroup[i] <= 0)
            {
                continue;
            }
            _monsterGroup = DataTemplate.GetInstance().m_MonsterGroupTable.getTableData(stageData.m_monstergroup[i]) as MonstergroupTemplate;
            if (_monsterGroup == null || _monsterGroup.getGrouptype() != 2 || GameUtils.GetObjectClassById(_monsterGroup.getMonsterid()[0]) != EM_OBJECT_CLASS.EM_OBJECT_CLASS_MONSTER)
            {
                continue;
            }

            _bossTemp = DataTemplate.GetInstance().m_MonsterTable.getTableData(_monsterGroup.getMonsterid()[0]) as MonsterTemplate;
            if (_bossTemp != null)
            {
                break;
            }
        }
        if (_bossTemp == null)
        {
            return(null);
        }
        else
        {
            return(GameUtils.getString(_bossTemp.getMonstername()));
        }
    }
    public void SetData(int tableID)
    {
        int    quality = -1;
        string iconStr = string.Empty;
        string name    = string.Empty;
        string hintTxt = string.Empty;
        string detail  = string.Empty;

        EM_OBJECT_CLASS eoc = GameUtils.GetObjectClassById(tableID);

        switch (eoc)
        {
        case EM_OBJECT_CLASS.EM_OBJECT_CLASS_RUNE:
            ItemTemplate runeItemT = DataTemplate.GetInstance().GetItemTemplateById(tableID);
            if (runeItemT == null)
            {
                LogManager.LogError("item表格中缺少物品id=" + tableID);
                return;
            }
            iconStr = runeItemT.getIcon_s();
            name    = GameUtils.getString(runeItemT.getName());
            int count = 0;
            if (ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, tableID, ref count))
            {
            }
            else
            {
                count = 0;
            }
            hintTxt = string.Format(GameUtils.getString("tongyong_daoju1"), count);
            detail  = GameUtils.getString(runeItemT.getDes());
            quality = runeItemT.getRune_quality();
            break;

        case EM_OBJECT_CLASS.EM_OBJECT_CLASS_COMMON:
            ItemTemplate itemT = DataTemplate.GetInstance().GetItemTemplateById(tableID);
            if (itemT == null)
            {
                LogManager.LogError("item表格中缺少物品id=" + tableID);
                return;
            }

            iconStr = itemT.getIcon_s();
            name    = GameUtils.getString(itemT.getName());

            int num = 0;
            if (ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, tableID, ref num))
            {
            }
            else
            {
                num = 0;
            }
            hintTxt = string.Format(GameUtils.getString("tongyong_daoju1"), num);
            detail  = GameUtils.getString(itemT.getDes());
            quality = itemT.getQuality();
            break;

        case EM_OBJECT_CLASS.EM_OBJECT_CLASS_MONSTER:
            MonsterTemplate monsterT = DataTemplate.GetInstance().m_MonsterTable.getTableData(tableID) as MonsterTemplate;
            if (monsterT == null)
            {
                LogManager.LogError("item表格中缺少物品id=" + tableID);
                return;
            }

            ArtresourceTemplate artMonster = DataTemplate.GetInstance().GetArtResourceTemplate(monsterT.getArtresources());
            if (artMonster == null)
            {
                LogManager.LogError("ArtResource时装表格中缺少物品id=" + monsterT.getArtresources());
                return;
            }

            iconStr = artMonster.getHeadiconresource();
            name    = GameUtils.getString(monsterT.getMonstername());
            hintTxt = string.Format("Lv{0}", monsterT.getMonsterlevel());
            detail  = GameUtils.getString(monsterT.getDescriptionID());
            quality = monsterT.getMonsterstar();
            break;

        case EM_OBJECT_CLASS.EM_OBJECT_CLASS_HERO:
            HeroTemplate heroT = DataTemplate.GetInstance().GetHeroTemplateById(tableID);
            if (heroT == null)
            {
                LogManager.LogError("hero表格中缺少物品id=" + tableID);
                return;
            }
            ArtresourceTemplate artHero = DataTemplate.GetInstance().GetArtResourceTemplate(heroT.getArtresources());
            if (artHero == null)
            {
                LogManager.LogError("ArtResource时装表格中缺少物品id=" + heroT.getArtresources());
                return;
            }

            iconStr = artHero.getHeadiconresource();
            //英雄的初始品质为HeroTemplate中的Quality;
            name = string.Format(GameUtils.GetHeroNameFontColor(heroT.getQuality()), GameUtils.getString(heroT.getNameID()));
            ObjectCard oc = ObjectSelf.GetInstance().HeroContainerBag.FindHero(tableID);
            hintTxt = string.Format("Lv{0}", oc == null ? 1 : oc.GetHeroData().Level);
            detail  = GameUtils.getString(heroT.getDescriptionID());
            break;

        case EM_OBJECT_CLASS.EM_OBJECT_CLASS_SKIN:
            ArtresourceTemplate artT = DataTemplate.GetInstance().GetArtResourceTemplate(tableID);
            if (artT == null)
            {
                LogManager.LogError("ArtResource时装表格中缺少物品id=" + tableID);
                return;
            }

            iconStr = string.Empty;
            name    = string.Empty;
            hintTxt = string.Empty;
            detail  = string.Empty;
            break;

        case EM_OBJECT_CLASS.EM_OBJECT_CLASS_RES:
            //资源类型点击无响应;
            iconStr = string.Empty;
            name    = string.Empty;
            hintTxt = string.Empty;
            detail  = string.Empty;
            break;

        default:
            LogManager.LogError("未处理的商城物品预览类型");
            break;
        }
        name = string.Format(GameUtils.GetHeroNameFontColor(quality), name);
        SetData(iconStr, name, hintTxt, detail);
    }