Esempio n. 1
0
        public TableWeapon Get(int id)
        {
            TableWeapon data = null;

            _ins.mDict.TryGetValue(id, out data);
            return(data);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public void SetData()
 {
     weaponGroup.SetData <WeaponItem, TableWeapon>(TableWeapon.GetAll(),
                                                   (index, item, data) =>
     {
         item.SetData(data.id);
     });
 }
Esempio n. 4
0
        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());
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        private void OnEventGameDataWhenever(EventGameData evt)
        {
            if (evt.action == EventGameData.Action.UnlockNewLevel)
            {
                if (D.I.unlockedGameLevel == 2)
                {
                    needOpenTutorial = true;
                }
                else if (!GameLocalData.Instance.isRateOver)
                {
                    foreach (var lv in CT.table.rateUsHintLevel)
                    {
                        if (lv == D.I.unlockedGameLevel - 1)
                        {
                            needOpenRate = true;
                            break;
                        }
                    }
                }

                if (D.I.unlockedGameLevel == CT.table.dailySignUnlockLevel)
                {
                    mOpenHints.Add(LTKey.UNLOCK_SYSTEM_X.LT(LTKey.DAILY_SIGN.LT()));
                }
                if (D.I.unlockedGameLevel == CT.table.bookUnlockLevel)
                {
                    mOpenHints.Add(LTKey.UNLOCK_SYSTEM_X.LT(LTKey.VIRUS_BOOK.LT()));
                }
                if (D.I.unlockedGameLevel == CT.table.weaponUnlockLevel)
                {
                    mOpenHints.Add(LTKey.UNLOCK_SYSTEM_X.LT(LTKey.WEAPON_SYSTEM.LT()));
                }
                foreach (var t in TableWeapon.GetAll())
                {
                    if (D.I.unlockedGameLevel == t.unlockLevel)
                    {
                        mOpenHints.Add(LTKey.UNLOCK_WEAPON_X.LT(LT.Get(t.nameID)));
                    }
                }
            }
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        public int GetTrialWeaponID()
        {
            if (unlockedGameLevel < CT.table.weaponUnlockLevel)
            {
                return(0);
            }

            var _last = new DateTime(localData.lastTrialTicks);

            if (_last.DayOfYear != DateTime.Now.DayOfYear)
            {
                localData.lastTrialTicks = DateTime.Now.Ticks;
                localData.trialCount     = 0;
                SaveLocalData();
            }
            if (localData.trialCount >= CT.table.maxWeaponTrialCount)
            {
                return(0);
            }
            if (localData.trialWeaponID == 0 && streak < 0)
            {
                var _weapons = new List <int>();
                foreach (var w in TableWeapon.GetAll())
                {
                    if (w.unlockLevel <= unlockedGameLevel)
                    {
                        _weapons.Add(w.id);
                    }
                }
                var _id = FormulaUtil.RandomInArray(_weapons.ToArray());
                if (_id != 0)
                {
                    localData.trialWeaponID = _id;
                    SaveLocalData();
                }
            }
            return(localData.trialWeaponID);
        }
        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());
        }
Esempio n. 10
0
 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);
     }
 }