Esempio n. 1
0
        public void RefreshGroup(int groupId, bool force)
        {
            var current = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

            if (!_shop.State.Groups.TryGetValue(groupId, out var groupData))
            {
                Logger.Error($"no state group id = {groupId}", this);
            }

            if (_shop.Static.GoodGroups.TryGetValue(groupId, out var group))
            {
                Logger.Error($"no static group id = {groupId}", this);
            }
            //var groupData = _shop.State.Groups[groupId];

            //var group = _shop.GetGroup(groupId);c
            if (!force && current < groupData.FinishTime)
            {
                throw new Exception("no time for refresh");
            }
            if (force)
            {
                var price = group.RechargePrices.Values.FirstOrDefault(x => x.Numbler == groupData.RefreshNumber).Price;
                _scorers.Spend(price, _formula);
                if (groupData.RefreshNumber < group.RechargePrices.Count)
                {
                    groupData.RefreshNumber++;
                }
            }
            _shopLogic.UpdateGroups(groupId, current + group.Period);
        }
Esempio n. 2
0
        private void FirstSession(long currentTime)
        {
            _player.State.RegisterTime = currentTime.ToString();
            _explorer.State.IsRun      = false;
            _explorer.State.StageId    = -1;
            _player.UpgradeLevel(0);
            foreach (var temp in _shop.Static.GoodGroups)
            {
                var group = _shop.GetGroup(temp.Key);
                if (group.Period == 0)
                {
                    _shopLogic.UpdateGroups(temp.Key, 0);
                }
                else
                {
                    _shopLogic.UpdateGroups(temp.Key, currentTime + group.Period);
                }
                if (_shop.State.Groups.TryGetValue(temp.Value.Id, out var data))
                {
                    data.RefreshNumber = 1;
                }
            }
            foreach (var temp in _achievement.Static.Achievements)
            {
                var data     = _achievement.CreateAchievementData(temp.Key);
                var duration = (int)_formula.Calculate(temp.Value.Time);
                if (duration > 0)
                {
                    data.FinishTime = currentTime + duration;
                }
            }

            LogicLog.SetSession(LogSessionType.OpenGame);
            _settings.State.CurrentVersion = Application.version;
            _settings.State.Build          = _settings.Settings.Builds.FirstOrDefault(x => x.Value.Version == Application.version).Key;
        }