public void WeaponPowerLevelUp() { if (isWeaponPowerLevelMax) { DispatchEvent(EventGameData.Action.Error, LTKey.ALREADY_LEVEL_MAX.LT()); return; } if (weaponPowerLevel >= firePowerLevel) { DispatchEvent(EventGameData.Action.Error, LTKey.CANNOT_EXCEED_FIRE_POWER_LEVEL.LT()); return; } var cost = weaponPowerUpCost; if (coin < cost) { DispatchEvent(EventGameData.Action.Error, LTKey.UPGRADE_LACK_OF_COIN.LT()); return; } localData.coin -= cost; weaponLevelData.SetPowerLevel(weaponId, weaponPowerLevel + 1); SaveLocalData(); SaveWeaponLevelData(); DispatchEvent(EventGameData.Action.DataChange); Analytics.Event.Upgrade($"{TableWeapon.Get(weaponId).type.ToLower()}_power", weaponPowerLevel); }
public void SetData(int id) { mId = id; var table = TableWeapon.Get(id); icon.SetSprite(table.icon); icon.SetGrey(D.I.unlockedGameLevel < table.unlockLevel); title.text = LT.Get(table.nameID); selectedObj.SetActive(id == D.I.weaponId); radioState.Radio(D.I.unlockedGameLevel < table.unlockLevel ? 0 : D.I.weaponId == id ? 2 : 1); unlockText.text = LTKey.WEAPON_UNLOCK_ON_GAME_LEVEL_X.LT(table.unlockLevel - 1); trialTag.SetActive(!D.I.noAd && D.I.GetTrialWeaponID() == id && !D.I.IsInTrial()); }
public void ChangeWeapon(int id) { if (id > 0 && unlockedGameLevel < TableWeapon.Get(id).unlockLevel) { DispatchEvent(EventGameData.Action.Error, LTKey.NOT_REACH_WEAPON_UNLOCK_GAME_LEVEL.LT()); return; } localData.weaponId = id; SaveLocalData(); DispatchEvent(EventGameData.Action.ChangeWeapon); DispatchEvent(EventGameData.Action.DataChange); Analytics.Event.ChangeWeapon(id); }
public void Reset() { var weaponType = D.I.weaponId <= 0 ? "WeaponNone" : TableWeapon.Get(D.I.weaponId).type; if (mLastWeaponType != weaponType) { if (mWeapon != null) { DestroyImmediate(mWeapon.gameObject); } var prefab = ResourceUtil.Load <WeaponBase>(PathUtil.Entity(weaponType)); if (prefab != null) { mWeapon = Instantiate(prefab); mWeapon.rectTransform.SetParent(mWeaponRoot, false); } mLastWeaponType = weaponType; } mWeapon.Reset(D.I.weaponId, D.I.weaponPowerLevel, D.I.weaponSpeedLevel); }
public void SetData() { if (D.I.unlockedGameLevel < CT.table.weaponUnlockLevel) { gameObject.SetActive(false); return; } gameObject.SetActive(true); if (D.I.weaponId <= 0) { icon.SetSprite("icon_weapon_default"); powerFill.value = 0; powerLevelText.text = $"{LTKey.FIRE_POWER.LT()} {LTKey.LEVEL_DOT.LT()}1"; powerUpBtn.SetData("0", true, false); speedFill.value = 0; speedLevelText.text = $"{LTKey.FIRE_SPEED.LT()} {LTKey.LEVEL_DOT.LT()}1"; speedUpBtn.SetData("0", true, false); return; } var table = TableWeapon.Get(D.I.weaponId); icon.SetSprite(table.icon); powerUpBtn.Set4LevelUp(D.I.weaponPowerUpCost, D.I.isWeaponPowerLevelMax); powerLevelText.text = $"{LTKey.FIRE_POWER.LT()} {LTKey.LEVEL_DOT.LT()}{D.I.weaponPowerLevel}"; powerFill.value = 1f * D.I.weaponPowerLevel / D.I.weaponPowerMaxLevel; powerTips.SetData(table.powerUpTips.LT()); speedUpBtn.Set4LevelUp(D.I.weaponSpeedUpCost, D.I.isWeaponSpeedLevelMax); speedLevelText.text = $"{LTKey.FIRE_SPEED.LT()} {LTKey.LEVEL_DOT.LT()}{D.I.weaponSpeedLevel}"; speedFill.value = 1f * D.I.weaponSpeedLevel / D.I.weaponSpeedMaxLevel; speedTips.SetData(table.speedUpTips.LT()); }
public virtual void Reset(int id, int powerLevel, int speedLevel) { this.id = id; if (id <= 0) { return; } table = TableWeapon.Get(id); tablePower = TableWeaponPowerLevel.Get(_ => _.weaponId == id && _.level == powerLevel); tableSpeed = TableWeaponSpeedLevel.Get(_ => _.weaponId == id && _.level == speedLevel); rechargeDuration = tableSpeed.recharge; damage = tablePower.damage; effects[0] = table.effect1 * tablePower.effectFactor1 * tableSpeed.effectFactor1; effects[1] = table.effect2 * tablePower.effectFactor2 * tableSpeed.effectFactor2; effects[2] = table.effect3 * tablePower.effectFactor3 * tableSpeed.effectFactor3; effects[3] = table.effect4 * tablePower.effectFactor4 * tableSpeed.effectFactor4; effects[4] = table.effect5 * tablePower.effectFactor5 * tableSpeed.effectFactor5; mUnitIndex = 0; mUnitCD.Clear(); for (int i = 0; i < unitCount; i++) { mUnitCD.Add(rechargeDuration); } }