Exemplo n.º 1
0
    public int GetHeroLevel(int pHeroId, uint exp)
    {//获取英雄等级
        GameData.Instance.initData(E_StaticDB_DBType.HeroInfo);

        T_HeroInfo pHeroInfo = GetHeroInfoById(pHeroId);

        if (pHeroInfo == null)
        {
            return(0);
        }

        int lvl = 1;//英雄等级从1级开始

        for (int i = 0; i < _pHeroExpInfoList.Count; i++)
        {
            if (_pHeroExpInfoList[i].pExp == 0)
            {
                continue;                                //不可能存在 0
            }
            uint _exp = _pHeroExpInfoList[i].pExp;
            if (exp >= _exp)
            {
                lvl++;

                lvl = Mathf.Min(m_heroMaxLv, lvl);
            }
        }
        return(lvl);
    }
Exemplo n.º 2
0
    public T_HeroStartInfo GetHeroStarInfoByIdAndLvl(int pId, int pStar)
    {
        GameData.Instance.initData(E_StaticDB_DBType.HeroInfo);

        T_HeroInfo pHeroInfo = GetHeroInfoById(pId);

        if (pHeroInfo == null)
        {
            return(null);
        }

        foreach (T_HeroStartInfo pHeroStartInfo in pHeroInfo.pHeroStartInfo)
        {
            if (pStar == pHeroStartInfo.Star)
            {
                return(pHeroStartInfo);
            }
        }

        return(null);
    }
Exemplo n.º 3
0
    public uint GetHeroUpgradeExp(int pHeroId, int pLvl)
    {//获取英雄升级需要的经验
        if (_pHeroExpInfoList.Count == 0)
        {
            return(0);
        }
        if (pLvl == 0)
        {
            return(0);          //英雄是从零级开始
        }
        T_HeroInfo pHeroInfo = GetHeroInfoById(pHeroId);

        if (pHeroInfo.Id == 0)
        {
            return(0);
        }
        if (_pHeroExpInfoList.Count > pLvl)
        {
            return(_pHeroExpInfoList[pLvl - 1].pExp);
        }
        return(0);
    }
Exemplo n.º 4
0
    public void LoadFromXML(string pXmlString)
    {//英雄配置
        XmlDocument xDoc = new XmlDocument();

        xDoc.LoadXml(pXmlString);
        XmlElement  parent   = xDoc.DocumentElement;
        XmlNodeList nodeList = parent.ChildNodes;

        foreach (XmlElement pHero in nodeList)
        {
            T_HeroInfo pHeroInfo = new T_HeroInfo();
            _heroInfoList.Add(pHeroInfo);

            pHeroInfo.Id   = XmlHelper.ReadIntegerAttribute(pHero, "Id");
            pHeroInfo.Name = XmlHelper.ReadStringAttribute(pHero, "Name");
            //  pHeroInfo.NameId = XmlHelper.ReadIntegerAttribute(pHero, "NameId");

            //XmlNodeList pStarList = pHero.SelectSingleNode("Star").ChildNodes;
            XmlNodeList pStarList = pHero.ChildNodes;
            foreach (XmlElement pStart in pStarList)
            {
                T_HeroStartInfo pHeroStartInfo = new T_HeroStartInfo();
                pHeroInfo.pHeroStartInfo.Add(pHeroStartInfo);

                pHeroStartInfo.Star    = XmlHelper.ReadIntegerAttribute(pStart, "Star");
                pHeroStartInfo.NeedLvl = XmlHelper.ReadIntegerAttribute(pStart, "NeedLvl");

                pHeroStartInfo.Attack          = XmlHelper.ReadIntegerAttribute(pStart, "Attack");
                pHeroStartInfo.HP              = XmlHelper.ReadIntegerAttribute(pStart, "HP");
                pHeroStartInfo.MP              = XmlHelper.ReadIntegerAttribute(pStart, "MP");
                pHeroStartInfo.Attack_Speed    = XmlHelper.ReadIntegerAttribute(pStart, "Attack_Speed");
                pHeroStartInfo.Move_Speed      = XmlHelper.ReadIntegerAttribute(pStart, "Move_Speed");
                pHeroStartInfo.Attack_Favorite = XmlHelper.ReadIntegerAttribute(pStart, "Attack_Favorite");
                pHeroStartInfo.Tenacity        = XmlHelper.ReadIntegerAttribute(pStart, "Tenacity");
            }
        }
    }