private void LevelUpFirePower() { if (DataAPIController.instance.LevelUpDamage()) { dmgCf = dmgCfNext; dmgCfNext = ConfigurationManager.instance.playerDamage.GetRecordByKeySearch(dmgCf.Level + 1); UpdateDownUI(); } }
public override void Setup() { currentGold = DataAPIController.instance.GetCurrentGold(); if (root == null) { root = GetComponent <DownPanelExtendItem>(); } if (!isSetupOneTime) { isSetupOneTime = true; int damageLevel = DataAPIController.instance.GetCurrentDamageLevel(); int fireRateLevel = DataAPIController.instance.GetCurrentFireRateLevel(); dmgCf = ConfigurationManager.instance.playerDamage.GetRecordByKeySearch(damageLevel); dmgCfNext = ConfigurationManager.instance.playerDamage.GetRecordByKeySearch(damageLevel + 1); frCf = ConfigurationManager.instance.playerFireRate.GetRecordByKeySearch(fireRateLevel); frCfNext = ConfigurationManager.instance.playerFireRate.GetRecordByKeySearch(fireRateLevel + 1); root.btnDownBuy.onClick.AddListener(() => { LevelUpFirePower(); }); root.btnMidBuy.onClick.AddListener(() => { LevelUpFireRate(); }); DataAPIController.instance.RegisterEvent(DataPath.GOLD, OnGoldChangeEvent); } UpdateDownUI(); UpdateMidUI(); }
public bool LevelUpDamage() { int currentLevel = GetCurrentDamageLevel(); ConfigPlayerDamageRecord nextLevelConfig = ConfigurationManager.instance.playerDamage.GetRecordByKeySearch(currentLevel + 1); if (nextLevelConfig == null) { return(false); } int gold = GetCurrentGold(); if (gold >= nextLevelConfig.UnlockFee) { gold -= nextLevelConfig.UnlockFee; currentLevel++; dataModel.UpdateData(DataPath.GOLD, gold); dataModel.UpdateData(DataPath.DAMAGELEVEL, currentLevel); return(true); } return(false); }