예제 #1
0
    // 根据等级排序英雄
    void SortHeroWithLevel(ref List <ObjectCard> heroList)
    {
        for (int i = 0; i < heroList.Count - 1; ++i)
        {
            ObjectCard item = heroList [i];
            for (int j = i; j < heroList.Count; ++j)
            {
                int level1 = heroList [i].GetHeroData().Level;
                int level2 = heroList [j].GetHeroData().Level;

                if (level2 < level1)
                {
                    item         = heroList [j];
                    heroList [j] = heroList [i];
                    heroList [i] = item;
                }
                else if (level2 == level1)
                {
                    HeroTemplate hero1    = ( HeroTemplate )DataTemplate.GetInstance().m_HeroTable.getTableData(heroList [i].GetHeroData().TableID);
                    int          quality1 = hero1.getQuality();

                    HeroTemplate hero2    = ( HeroTemplate )DataTemplate.GetInstance().m_HeroTable.getTableData(heroList [j].GetHeroData().TableID);
                    int          quality2 = hero2.getQuality();

                    if (quality2 < quality1)
                    {
                        item         = heroList [j];
                        heroList [j] = heroList [i];
                        heroList [i] = item;
                    }
                    else if (quality2 == quality1)
                    {
                        HeroTemplate hero3  = ( HeroTemplate )DataTemplate.GetInstance().m_HeroTable.getTableData(heroList [i].GetHeroData().TableID);
                        int          count1 = hero3.getReturnBack();
                        count1 += ( int )(( float )hero1.getExpNum() * DataTemplate.GetInstance().m_GameConfig.getRongling_conversion_rate() / ( float )DataTemplate.GetInstance().m_GameConfig.getJingyanjiejing_to_jingyan());

                        HeroTemplate hero4  = ( HeroTemplate )DataTemplate.GetInstance().m_HeroTable.getTableData(heroList [j].GetHeroData().TableID);
                        int          count2 = hero4.getReturnBack();
                        count2 += ( int )(( float )hero1.getExpNum() * DataTemplate.GetInstance().m_GameConfig.getRongling_conversion_rate() / ( float )DataTemplate.GetInstance().m_GameConfig.getJingyanjiejing_to_jingyan());

                        if (count2 < count1)
                        {
                            item         = heroList [j];
                            heroList [j] = heroList [i];
                            heroList [i] = item;
                        }
                    }
                }
            }
        }
    }
예제 #2
0
    /// <summary>
    /// 可升级检测逻辑
    /// </summary>
    /// <param name="hero"></param>
    /// <returns></returns>
    private bool CheckUpgradable(ObjectCard hero)
    {
        if (hero == null)
        {
            return(false);
        }

        HeroTemplate    _heroItem = hero.GetHeroRow();
        IExcelBean      _data     = null;
        HeroexpTemplate _heroExp  = null;
        var             _dataMap  = m_HeroExpTable.getData();

        if (_dataMap.TryGetValue(hero.GetHeroData().Level, out _data))
        {
            _heroExp = _data as HeroexpTemplate;
        }

        if (_heroExp != null)
        {
            return(m_ObjectSelf.ExpFruit * m_ExpCrystalFactor >= _heroExp.getExp()[_heroItem.getExpNum() - 1] &&
                   hero.GetHeroData().Level < _heroItem.getMaxLevel());
        }
        else
        {
            return(false);
        }
    }
예제 #3
0
    public void NeedExp()
    {
        HeroTemplate _HeroItem = objc.GetHeroRow();
        int          expid     = _HeroItem.getExpNum() - 1;
        int          level     = objc.GetHeroData().Level;

        if (level != null)
        {
            if (level < _HeroItem.getMaxLevel())
            {
                HeroexpTemplate _HeroExp = (HeroexpTemplate)DataTemplate.GetInstance().m_HeroExpTable.getTableData(level);
                int             needxp   = _HeroExp.getExp()[expid] - objc.GetHeroData().Exp;
                mNeedExp.text = needxp.ToString();
            }
        }
    }
예제 #4
0
    int GetLithCount(ObjectCard card)
    {
        HeroTemplate temp      = (HeroTemplate)DataTemplate.GetInstance().m_HeroTable.getTableData(card.GetHeroData().TableID);
        int          lithCount = temp.getReturnBack();
        int          expNum    = temp.getExpNum();
        int          level     = card.GetHeroData().Level;
        int          allExp    = 0;

        for (int i = 1; i < level; i++)
        {
            HeroexpTemplate heroExpTemp = (HeroexpTemplate)DataTemplate.GetInstance().m_HeroExpTable.getTableData(i);
            allExp += heroExpTemp.getExp()[expNum - 1];
        }

        lithCount += (int)((allExp + card.GetHeroData().Exp) * DataTemplate.GetInstance().m_GameConfig.getRongling_conversion_rate() / (float)DataTemplate.GetInstance().m_GameConfig.getJingyanjiejing_to_jingyan());

        return(lithCount);
    }
예제 #5
0
    public void ExpCrustal()
    {
        int allExpNum = ObjectSelf.GetInstance().ExpFruit;

        allExpCrystal.text = allExpNum.ToString();
        int          proportion = DataTemplate.GetInstance().m_GameConfig.getJingyanjiejing_to_jingyan();
        HeroTemplate _HeroItem  = objc.GetHeroRow();

        mLevel.text = objc.GetHeroData().Level.ToString();
        int expid = _HeroItem.getExpNum() - 1;
        int level = int.Parse(mLevel.text);

        if (level < _HeroItem.getMaxLevel())
        {
            HeroexpTemplate _HeroExp = (HeroexpTemplate)DataTemplate.GetInstance().m_HeroExpTable.getTableData(level);
            int             needxp   = _HeroExp.getExp()[expid] - objc.GetHeroData().Exp;
            oneExpCrustal.text = needxp.ToString();
            int tenneedxp = 0;
            levelSurplus      = 0;
            expSurplus        = 0;
            expCrustalSurplus = 0;
            //距离当阶最大等级是否为10级
            if (level >= (_HeroItem.getMaxLevel() - 10))
            {
                for (int i = level; i < _HeroItem.getMaxLevel(); i++)
                {
                    HeroexpTemplate ten_HeroExp = (HeroexpTemplate)DataTemplate.GetInstance().m_HeroExpTable.getTableData(i);
                    tenneedxp += ten_HeroExp.getExp()[expid];
                }
            }
            else
            {
                for (int i = level; i < level + 10; i++)
                {
                    HeroexpTemplate ten_HeroExp = (HeroexpTemplate)DataTemplate.GetInstance().m_HeroExpTable.getTableData(i);
                    if (allExpNum < _HeroExp.getExp()[expid])
                    {
                        expSurplus        = _HeroExp.getExp()[expid];
                        expCrustalSurplus = allExpNum;
                        levelSurplus      = i;
                    }
                    allExpNum -= _HeroExp.getExp()[expid];
                    tenneedxp += ten_HeroExp.getExp()[expid];
                }
            }
            tenExpCrustal.text = (tenneedxp - objc.GetHeroData().Exp).ToString();
        }
        mExpProgress.value = (int)(objc.GetHeroData().GetExpPercentage() * 100);

        //等级到达当阶最大等级时
        if (int.Parse(mLevel.text) >= _HeroItem.getMaxLevel())
        {
            mExpProgress.value = 100f;
            mLevelup1.gameObject.GetComponent <Image>().overrideSprite  = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_07");
            mLevelup10.gameObject.GetComponent <Image>().overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_07");
            oneExpCrustal.text = "------";
            tenExpCrustal.text = "------";
            //mExpProOver.overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_08");
            mExpProgress.value = 99.9f;
            mNeedDes.text      = GameUtils.getString("hero_levelup_content1"); //"已达到当阶最高级"
            expEffectsMax.SetActive(true);
            mNeedExp.gameObject.SetActive(false);
            //sPlay = false;
        }
        //升一级经验结晶不足
        else if (int.Parse(allExpCrystal.text) == 0 || int.Parse(oneExpCrustal.text) > int.Parse(allExpCrystal.text))
        {
            mLevelup1.gameObject.GetComponent <Image>().overrideSprite  = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_07");
            mLevelup10.gameObject.GetComponent <Image>().overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_07");
        }
        //升10级经验结晶不足
        else if (int.Parse(allExpCrystal.text) == 0 || int.Parse(tenExpCrustal.text) > int.Parse(allExpCrystal.text))
        {
            mLevelup10.gameObject.GetComponent <Image>().overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_07");
        }
        else
        {
            isPlay = true;
            //mExpProOver.overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "UI_HeroInfo_01");
            mNeedDes.text = GameUtils.getString("hero_levelup_content2"); //"升级所需经验"
            mNeedExp.gameObject.SetActive(true);
            oneExpCrustal.gameObject.SetActive(true);
            tenExpCrustal.gameObject.SetActive(true);
            expEffectsMax.SetActive(false);
            //结晶数为0时
            if (int.Parse(allExpCrystal.text) == 0)
            {
                mLevelup1.gameObject.GetComponent <Image>().overrideSprite  = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_07");
                mLevelup10.gameObject.GetComponent <Image>().overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_07");
            }
            else
            {
                mLevelup1.gameObject.GetComponent <Image>().overrideSprite  = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_04");
                mLevelup10.gameObject.GetComponent <Image>().overrideSprite = UIResourceMgr.LoadSprite(common.defaultPath + "UI_Up_04");
            }
        }
    }