Ejemplo n.º 1
0
    // 设置当前经验进度
    public void SetExpProgress(int clientCurrentLevel, int clientCurrentExp)
    {
        _txtHeroLevel.text     = clientCurrentLevel.ToString();
        _txtHeroLevelNext.text = (clientCurrentLevel + 1).ToString();
        HeroLevelConfig expCfg = HeroLevelConfigLoader.GetConfig(clientCurrentLevel);

        if (expCfg != null)
        {
            if (expCfg.ExpRequire == 0)
            {
                _imageExpPrg.fillAmount = 1;
                _txtExpPrg.gameObject.SetActive(false);
            }
            else
            {
                _nextFillAmount = 1.0f * clientCurrentExp / expCfg.ExpRequire;
                _curSeq.Kill();
                Sequence seq = DOTween.Sequence();
                _curSeq = seq;
                seq.Join(_imageExpPrg.DOFillAmount(_nextFillAmount, 0.5f));
                seq.Play();
                _txtExpPrg.text = string.Format("{0}/{1}", clientCurrentExp, expCfg.ExpRequire);
                _txtExpPrg.gameObject.SetActive(true);
            }
        }
    }
Ejemplo n.º 2
0
 public HeroInfo(HeroConfig heroConfig, HeroLevelConfig heroLevel)
 {
     this.HeroID = heroConfig.HeroID;
     this.Level = heroLevel.HeroLevel;
     this.HP = heroLevel.HP * heroConfig.HP;
     this.GoldUpgrade = heroLevel.GoldUprade * heroConfig.GoldUpgrade;
 }
Ejemplo n.º 3
0
    // 在当前经验(相对于当前等级)的基础上加经验
    public void AddExpBaseOnCurExp(int curLevel, int booksAddExp)
    {
        int totalAddExp = booksAddExp + _currentExp;
        int requiredExp = 0;
        int reduceExp   = 0;

        for (int i = curLevel; i <= HeroLevelConfigLoader.Data.Count; i++)
        {
            HeroLevelConfig config = HeroLevelConfigLoader.GetConfig(i);
            requiredExp += config.ExpRequire;
            // 一直累加直到能再升级
            if (totalAddExp < requiredExp)
            {
                _currentLevel = config.Level;
                _currentExp   = totalAddExp - reduceExp;
                break;
            }

            //超过90级后 经验不增加
            if (i == HeroLevelConfigLoader.Data.Count)
            {
                _currentLevel = config.Level;
                _currentExp   = 0;
            }

            // 累加用于计算升级后对应的当前经验
            reduceExp += config.ExpRequire;
            //_panelHeroExpBook.SetExpProgress(_currentLevel, _currentExp);

            EventDispatcher.TriggerEvent <int, int>(EventID.EVENT_EXPBOOK_COST, _currentLevel, _currentExp);
        }
        // 设置经验进度条,break 出来之后
        EventDispatcher.TriggerEvent <int, int>(EventID.EVENT_EXPBOOK_COST, _currentLevel, _currentExp);
        //_panelHeroExpBook.SetExpProgress(_currentLevel, _currentExp);
    }
Ejemplo n.º 4
0
    public void SetHeroInfo(HeroInfo info)
    {
        _currentInfo = info;
        _starPanel.SetStar(info.StarLevel);
        _imageHeroIconBg.sprite = ResourceManager.Instance.GetHeroIconBgByStar(info.StarLevel);
        _imageHeroIcon.sprite   = ResourceManager.Instance.GetHeroIcon(info.ConfigID);
        _heroName.text          = info.GetName();
        _txtHeroLevel.text      = "Lv" + info.Level;

        IsSelect = UserManager.Instance.IsHeroInPVEFormation(info.ConfigID);
        _imgCheck.gameObject.SetActive(IsSelect);

        _imageHeroAttribute.sprite = ResourceManager.Instance.GetHeroTypeIcon(info.ConfigID);

        _heroName.color = ResourceManager.Instance.GetColorByQuality(info.StarLevel);

        HeroLevelConfig expCfg = HeroLevelConfigLoader.GetConfig(_currentInfo.Level);

        if (expCfg != null)
        {
            if (expCfg.ExpRequire == 0)
            {
                _imgExpPrg.fillAmount = 1;
                _txtExpPrg.gameObject.SetActive(false);
            }
            else
            {
                _imgExpPrg.fillAmount = 1.0f * _currentInfo.Exp / expCfg.ExpRequire;
                _txtExpPrg.text       = string.Format("{0}/{1}", _currentInfo.Exp, expCfg.ExpRequire);
                _txtExpPrg.gameObject.SetActive(true);
            }
        }

        _txtFightScore.text = _currentInfo.FightingScore.ToString();
    }
Ejemplo n.º 5
0
    // 处理动画
    IEnumerator ProcessAnimation()
    {
        const float     TIME          = 0.5f;
        float           curFillAmount = 0;
        int             curLevel      = _info.Level;
        int             curExp        = _info.Exp;
        HeroLevelConfig expCfg        = HeroLevelConfigLoader.GetConfig(curLevel);
        int             maxExp        = expCfg.ExpRequire;

        if (curExp + _addExp < maxExp)
        {
            // 未升级
            curFillAmount = 1.0f * (curExp + _addExp) / maxExp;
            _heroExp._image.DOFillAmount(curFillAmount, TIME);
        }
        else
        {
            while (_addExp > 0)
            {
                curFillAmount = Mathf.Max(1.0f, 1.0f * (curExp + _addExp) / maxExp);
                _heroExp._image.DOFillAmount(curFillAmount, TIME);
                yield return(new WaitForSeconds(TIME));

                _heroExp._image.fillAmount = 0;
                _addExp -= maxExp - curExp;
                curExp   = 0;
                ++curLevel;
                expCfg = HeroLevelConfigLoader.GetConfig(curLevel);
                maxExp = expCfg.ExpRequire;
            }
        }
    }
Ejemplo n.º 6
0
    public void SetInfo(long heroID, int addExp)
    {
        HeroInfo info = UserManager.Instance.GetHeroInfo(heroID);

        if (info == null)
        {
            gameObject.SetActive(false);
            return;
        }

        _info   = info;
        _addExp = addExp;

        _heroBg.sprite   = ResourceManager.Instance.GetIconBgByQuality(info.StarLevel);
        _heroIcon.sprite = ResourceManager.Instance.GetHeroIcon(info.ConfigID);
        _heroLevel.text  = "Lv " + info.Level;


        HeroLevelConfig expCfg = HeroLevelConfigLoader.GetConfig(info.Level);

        if (expCfg.ExpRequire == 0)
        {
            _heroExp.SetValue(1);
            if (_heroLevelUp != null)
            {
                _heroLevelUp.gameObject.SetActive(false);
            }
        }
        else
        {
            // 设置初始的进度
            _heroExp._image.fillAmount = 1.0f * info.Exp / expCfg.ExpRequire;
            StartCoroutine(ProcessAnimation());

            if (info.Exp + addExp >= expCfg.ExpRequire)
            {
                if (_heroLevelUp != null)
                {
                    _heroLevelUp.gameObject.SetActive(true);
                }
            }
            else
            {
                if (_heroLevelUp != null)
                {
                    _heroLevel.gameObject.SetActive(false);
                }
            }
        }

        _heroExp.SetText(Str.Get("UI_EXP") + "+" + addExp);
    }
Ejemplo n.º 7
0
    // 计算当前能花费的经验书数目
    public int GetMaxCostBooks()
    {
        HeroLevelConfig curHeroExpCfg = HeroLevelConfigLoader.GetConfig(_currentLevel);
        int             curTotalExp   = curHeroExpCfg.TotalExp + _currentExp;
        // 计算英雄能达到的最大等级(不超过玩家等级)
        int             maxLevel          = UserManager.Instance.Level;
        HeroLevelConfig maxLevelExpCfg    = HeroLevelConfigLoader.GetConfig(maxLevel);
        int             needExpToMaxLevel = maxLevelExpCfg.TotalExp - curTotalExp;
        // 计算达到最大等级需要的经验数目,需注意,该经验书数目为 0 时 _bookAddExp 为 0
        int needBookToMaxLevel = needExpToMaxLevel / (_bookAddExp > 0 ? _bookAddExp : 1);

        // 负数表示英雄已达到最大等级
        if (needBookToMaxLevel < 0)
        {
            needBookToMaxLevel = 0;
        }

        return(needBookToMaxLevel > _leftBooksNum ? _leftBooksNum : needBookToMaxLevel);
    }
Ejemplo n.º 8
0
    public void OnAddExp(int value)
    {
        Exp += value;

        HeroLevelConfig expCfg = HeroLevelConfigLoader.GetConfig(Level);

        if (expCfg != null)
        {
            if (Exp + value >= expCfg.ExpRequire)
            {
                // 升级的情况由服务端处理
            }
            else
            {
                // 未升级的情况直接加经验
                Exp += value;
            }
        }
    }
Ejemplo n.º 9
0
        public HeroLevelConfig[] GetHeroLevelConfigs()
        {
            List <HeroLevelConfig> lst = new List <HeroLevelConfig>();

            foreach (int level in GetLevelUpData().Keys)
            {
                HeroLevelConfig           config = new HeroLevelConfig();
                DynData <HeroLevelConfig> d      = new DynData <HeroLevelConfig>(config);
                d.Set <Amplitude.StaticString>("Name", "Hero_" + GetName() + "_LVL" + level);
                d.Set <float>("FoodCost", (float)Convert.ToDouble(GetLevelUpData()[level][0]));
                string[] skills = new string[GetLevelUpData()[level].Length - 1];
                for (int i = 1; i < GetLevelUpData()[level].Length; i++)
                {
                    skills[i - 1] = GetLevelUpData()[level][i];
                }
                d.Set <string[]>("Skills", skills);
                lst.Add(config);
            }
            return(lst.ToArray());
        }
Ejemplo n.º 10
0
    public void SetInfo(HeroInfo info)
    {
        if (info == null)
        {
            return;
        }

        _txtHeroLevel.text     = info.Level.ToString();
        _txtHeroLevelNext.text = (info.Level + 1).ToString();
        _itemWidget[0].SetInfo(GameConfig.ITEM_CONFIG_ID_EXP_1, info);
        _itemWidget[1].SetInfo(GameConfig.ITEM_CONFIG_ID_EXP_2, info);
        _itemWidget[2].SetInfo(GameConfig.ITEM_CONFIG_ID_EXP_3, info);
        _itemWidget[3].SetInfo(GameConfig.ITEM_CONFIG_ID_EXP_4, info);
        _itemWidget[4].SetInfo(GameConfig.ITEM_CONFIG_ID_EXP_5, info);

        HeroLevelConfig expCfg = HeroLevelConfigLoader.GetConfig(info.Level);

        if (expCfg != null)
        {
            if (expCfg.ExpRequire == 0)
            {
                _imageExpPrg.fillAmount = 1;
                _txtExpPrg.gameObject.SetActive(false);
            }
            else
            {
                if (_curSeq != null)
                {
                    _curSeq.Kill();
                }
                Sequence seq = DOTween.Sequence();
                _curSeq = seq;
                seq.Join(_imageExpPrg.DOFillAmount(1.0f * info.Exp / expCfg.ExpRequire, 0.5f));
                seq.Play();
                _txtExpPrg.text = string.Format("{0}/{1}", info.Exp, expCfg.ExpRequire);
                _txtExpPrg.gameObject.SetActive(true);
            }
        }
    }