public void RequestSkillUpgrade(long heroID, int skillID, int index) { HeroInfo info = GetHeroInfo(heroID); if (info == null) { return; } SkillInfo skillInfo = info.GetSkillByID(skillID); int level = 1; if (skillInfo != null) { level = skillInfo.Level; } if (level + 1 > info.Level) { UIUtil.ShowMsgFormat("MSG_HERO_SKILL_NEED_HERO_LEVEL", info.Level + 1); return; } int moneyCost = SkillInfo.GetUpgradeCost(index, level); if (UserManager.Instance.Money < moneyCost) { UIUtil.ShowMsgFormat("MSG_CITY_BUILDING_MONEY_LIMIT"); return; } if (UserManager.Instance.GetCurrentSkillPoint() <= 0) { UIUtil.ShowMsgFormat("MSG_HERO_SKILL_POINT_LIMIT"); return; } PSkill builder = new PSkill(); builder.heroId = heroID; builder.cfgId = skillID; NetworkManager.Instance.Send(eCommand.UPGRADE_SKILL, builder, (buffer) => { CommonAnswer ret = Net.Deserialize <CommonAnswer>(buffer); if (!Net.CheckErrorCode(ret.err_code, eCommand.UPGRADE_SKILL)) { return; } // 减去消耗的金钱和技能点 Money -= moneyCost; UseSkillPoint(); if (skillInfo != null) { ++skillInfo.Level; } // 刷新英雄技能界面 UIManager.Instance.RefreshWindow <UINewHeroView>(); UIManager.Instance.RefreshWindow <UINewHeroListView>(); // 刷新主界面的金钱数据 EventDispatcher.TriggerEvent(EventID.EVENT_UI_MAIN_REFRESH_VALUE); }); }
public void SetInfo(HeroInfo info, int skillID, int index) { _currentHeroInfo = info; _currentIndex = index; _skillIcon.sprite = ResourceManager.Instance.GetSkillIcon(skillID); SkillSettingsConfig cfg = SkillSettingsConfigLoader.GetConfig(skillID, false); if (cfg == null) { _flag.gameObject.SetActive(false); _textMoney.gameObject.SetActive(false); _btnUplev.gameObject.SetActive(false); _textLevel.gameObject.SetActive(false); _textUnlock.gameObject.SetActive(false); _skillIcon.gameObject.SetActive(false); _textName.gameObject.SetActive(false); _txtFullLevel.gameObject.SetActive(false); return; } _skillIcon.gameObject.SetActive(true); _textName.gameObject.SetActive(true); _textName.text = cfg.Name; bool lockSkill = false; if (index == 2 && info.Level < GameConfig.SKILL_UNLOCK2 || index == 3 && info.Level < GameConfig.SKILL_UNLOCK3 || index == 4 && info.Level < GameConfig.SKILL_UNLOCK4) { lockSkill = true; } if (!lockSkill) { SkillInfo skillInfo = info.GetSkillByID(skillID); int level = skillInfo != null ? skillInfo.Level : 1; // 已经解锁 _flag.gameObject.SetActive(true); _textMoney.gameObject.SetActive(true); _btnUplev.gameObject.SetActive(true); _textLevel.gameObject.SetActive(true); _textUnlock.gameObject.SetActive(false); int upgradeCost = SkillInfo.GetUpgradeCost(index, level); if (upgradeCost > 0) { // 未满级 _textMoney.text = upgradeCost.ToString(); _textMoney.gameObject.SetActive(true); _txtFullLevel.gameObject.SetActive(false); _flag.gameObject.SetActive(true); _btnUplev.gameObject.SetActive(true); } else { // 已满级 _textMoney.gameObject.SetActive(false); _txtFullLevel.gameObject.SetActive(true); _flag.gameObject.SetActive(false); _btnUplev.gameObject.SetActive(false); } _textLevel.text = "Lv." + level; } else { // 提升到固定品阶解锁 _flag.gameObject.SetActive(false); _textMoney.gameObject.SetActive(false); _btnUplev.gameObject.SetActive(false); _textLevel.gameObject.SetActive(false); _textUnlock.gameObject.SetActive(true); _txtFullLevel.gameObject.SetActive(false); if (index == 2) { _textUnlock.text = Str.Format("UI_HERO_SKILL_UPGRADE_TIP", GameConfig.SKILL_UNLOCK2); } else if (index == 3) { _textUnlock.text = Str.Format("UI_HERO_SKILL_UPGRADE_TIP", GameConfig.SKILL_UNLOCK3); } else if (index == 4) { _textUnlock.text = Str.Format("UI_HERO_SKILL_UPGRADE_TIP", GameConfig.SKILL_UNLOCK4); } } }