Пример #1
0
        public void DailySign(float multiple)
        {
            if (!CanDailySign())
            {
                DispatchEvent(EventGameData.Action.Error, LTKey.DAILY_SIGN_CANT_SIGN);
                return;
            }

            var days = localData.signDays;

            localData.signDays          = (days % 7) + 1;
            localData.lastSignDateTicks = DateTime.Now.Date.Ticks;
            var t = TableDailySign.Get(days);

            if (t.type == 1)
            {
                AddDiamondWithEffect(t.count);
            }
            else if (t.type == 2)
            {
                AddCoin(t.count * multiple * FormulaUtil.Expresso(CT.table.formulaArgsDailySignCoin));
            }
            SaveLocalData();
            DispatchEvent(EventGameData.Action.DataChange);

            Analytics.Event.DailySign(days, multiple);
        }
Пример #2
0
        private void OnEventVirus(EventVirus evt)
        {
            if (evt.action == EventVirus.Action.DEAD)
            {
                // add coin
                getCoin       += FormulaUtil.CoinConvert(evt.virus.size, mTableGameLevel.coinValueFactor * D.I.vipCoinValueMul, D.I.coinValue);
                mAddCoinCount += evt.virus.size * 0.1f;
                if (Random.value > CT.table.coinAddProb[evt.virus.size - 1])
                {
                    var pos       = UIUtil.GetUIPos(evt.virus.rectTransform);
                    int coinCount = Mathf.Clamp(Mathf.CeilToInt(mAddCoinCount), 1, 15);
                    Unibus.Dispatch(EventBattle.Get(EventBattle.Action.GET_COIN, coinCount, pos));
                    mAddCoinCount = 0;
                }

                // virus kills 4 buff
                D.I.kills4Buff += 1;

                // book
                D.I.BookAddCollectCount(evt.virus.id);
            }
            else if (evt.action == EventVirus.Action.BE_HIT)
            {
                if (BuffProxy.Ins.Has_Effect_Coin)
                {
                    var buff = BuffProxy.Ins.GetBuff("coin");
                    if (buff != null && Random.value <= buff.param2)
                    {
                        getCoin += FormulaUtil.CoinConvert(evt.virus.size, mTableGameLevel.coinValueFactor * buff.param1 * D.I.vipCoinValueMul, D.I.coinValue);
                        var pos = UIUtil.GetUIPos(evt.virus.rectTransform);
                        Unibus.Dispatch(EventBattle.Get(EventBattle.Action.GET_COIN, 1, pos));
                    }
                }
            }
        }
Пример #3
0
 protected virtual void UpdateColor()
 {
     colorIndex = FormulaUtil.GetHpColorIndex(hpRange, hp);
     if (mLastColorIndex != colorIndex)
     {
         OnColorChanged(colorIndex);
         mLastColorIndex = colorIndex;
     }
 }
Пример #4
0
        private void GenBuff()
        {
            var buffID = FormulaUtil.RandomInProbDict(buffTypePriority);
            var _speed = CT.table.buffSpeedRange.random;
            var pos    = new Vector2(Random.Range(60, UIUtil.width - 60), UIUtil.height);
            var dir    = Quaternion.AngleAxis(CT.table.buffSpawnDirection.random, Vector3.forward) * Vector2.down;

            Buff.Create().Reset(buffID, pos, dir, _speed);
        }
Пример #5
0
        private void Refresh()
        {
            costText.text = mCurrent.KMB();
            gainText.text = (mCurrent * FormulaUtil.Expresso(CT.table.formulaArgsCoinExchange)).KMB();

            subBtn.SetBtnGrey(mCurrent <= 0);
            addBtn.SetBtnGrey(mCurrent >= D.I.diamond);

            exchangeBtn.SetBtnGrey(mCurrent <= 0);
        }
Пример #6
0
        protected override void OnInit()
        {
            base.OnInit();

            mTableGameLevel = TableGameLevel.Get(D.I.gameLevel);
            mSpawnCountFix  = FormulaUtil.Expresso(CT.table.formulaArgsVirusSpawnCount);

            mWaveModule.Init();
            mBuffGenModule.Init();
            Unibus.Subscribe <EventAircraft>(OnEventAircraft);
            Unibus.Subscribe <EventVirus>(OnEventVirus);
        }
Пример #7
0
 private void ResetFixFactor()
 {
     if (mFirePower <= tableGameLevel.firePowerLimitation)
     {
         mHpFixFactor         = 1;
         mSpeedFixFactor      = 1;
         mSpawnCountFixFactor = 1;
     }
     else
     {
         mHpFixFactor         = FormulaUtil.Expresso(CT.table.formulaArgsVirusHp);
         mSpawnCountFixFactor = FormulaUtil.Expresso(CT.table.formulaArgsVirusSpawnCount);
         mSpeedFixFactor      = 1;
     }
 }
Пример #8
0
        private void SpawnVirus()
        {
            var direction = Quaternion.AngleAxis(CT.table.spawnVirusDirection.random, Vector3.forward) * Vector2.down;
            var pos       = new Vector2(Random.Range(VirusBase.baseRadius, UIUtil.width - VirusBase.baseRadius), UIUtil.height + VirusBase.baseRadius);

            var virusIndex = FormulaUtil.RandomIndexInProbArray(tableGameWave.virusProb);
            var virusTable = TableVirus.Get(tableGameWave.virus[virusIndex]);
            var virusType  = "DestroyViruses." + virusTable.type;
            var virus      = (VirusBase)EntityManager.Create(System.Type.GetType(virusType));

            var hpRange = new Vector2(tableGameLevel.hpRange.min, tableGameLevel.hpRange.max);
            var hp      = tableGameWave.virusHp[virusIndex].random * tableGameLevel.virusHpFactor * mHpFixFactor * CT.table.hpRandomRange.random;
            var speed   = tableGameWave.virusSpeed[virusIndex].random * tableGameLevel.virusSpeedFactor * mSpeedFixFactor * CT.table.speedRandomRange.random;
            var size    = tableGameWave.virusSize[virusIndex].random;

            virus.Reset(virusTable.id, hp, size, speed, pos, direction, hpRange, true);
        }
Пример #9
0
        public void ExchangeCoin(float diamond)
        {
            if (diamond > this.diamond)
            {
                DispatchEvent(EventGameData.Action.Error, LTKey.EXCHANGE_DIAMOND_NOT_ENOUGH.LT());
                return;
            }

            localData.diamond -= diamond;
            var addCoin = diamond * FormulaUtil.Expresso(CT.table.formulaArgsCoinExchange);

            localData.coin += addCoin;

            SaveLocalData();
            DispatchEvent(EventGameData.Action.DataChange);

            Analytics.Event.Exchange(diamond, addCoin);
        }
Пример #10
0
        private void GenBuff()
        {
            bool  isGen = false;
            var   _tab  = TableBuffKillGen.Get(a => a.gameLevel.Contains(D.I.gameLevel) && a.streak == D.I.streak);
            var   _prob = D.I.IsVip() ? _tab.vipProbability : _tab.probability;
            float ratio = _prob * D.I.kills4Buff;

            if (Random.value <= ratio)
            {
                isGen = true;
                var _typeProb = D.I.IsVip() ? _tab.vipBuffTypePriority : _tab.buffTypePriority;
                var buffID    = FormulaUtil.RandomInProbDict(_typeProb);
                var _speed    = CT.table.buffSpeedRange.random;
                var dir       = Quaternion.AngleAxis(CT.table.buffSpawnDirection.random, Vector3.forward) * Vector2.down;
                Buff.Create().Reset(buffID, position, dir, _speed);
            }

            if (isGen)
            {
                D.I.kills4Buff = 0;
            }
        }
Пример #11
0
        public void SetData(int days)
        {
            var t = TableDailySign.Get(days);

            title.text = LT.Get(t.nameID);
            image.SetSprite(t.icon);
            if (t.type == 2) // coin
            {
                count.text = "x" + t.count * FormulaUtil.Expresso(CT.table.formulaArgsDailySignCoin);
            }
            else
            {
                count.text = "x" + t.count;
            }
            if (days == D.I.signDays)
            {
                if (D.I.CanDailySign())
                {
                    stateRadio.Radio(1);
                }
                else
                {
                    stateRadio.Radio(0);
                }
            }
            else
            {
                if (days < D.I.signDays)
                {
                    stateRadio.Radio(2);
                }
                else
                {
                    stateRadio.Radio(0);
                }
            }
            bgRadio.Radio(stateRadio.index);
            btn.clickEventID = days;
        }
Пример #12
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);
        }