Пример #1
0
        private void SetNetworkStatistic(StaticString statisticName, float statisticValue)
        {
            AchievementStatistic statistic = this.GetStatistic(statisticName);

            if (statistic != null)
            {
                if (statistic.Type == AchievementStatistic.StatisticType.Float)
                {
                    this.SetNetworkStatisticFloat(statisticName, statisticValue);
                }
                else if (statistic.Type == AchievementStatistic.StatisticType.Int)
                {
                    this.SetNetworkStatisticInteger(statisticName, (int)statisticValue);
                }
                if (this.OnStatisticSet != null)
                {
                    this.OnStatisticSet(this, new EventArgs());
                }
                if (this.debug)
                {
                    Diagnostics.Log("[Achievement Statistic] Network statistic (name: '{0}') has been set to '{1}'.", new object[]
                    {
                        statisticName,
                        statistic.Value
                    });
                }
            }
        }
Пример #2
0
        private AchievementStatistic GetStatistic(StaticString statisticName)
        {
            AchievementStatistic achievementStatistic = this.statistics.FirstOrDefault((AchievementStatistic s) => s.Name == statisticName);

            if (achievementStatistic != null)
            {
                return(achievementStatistic);
            }
            Diagnostics.LogWarning("Can't get network statistic (name: '{0}').", new object[]
            {
                statisticName
            });
            return(null);
        }
Пример #3
0
        public float GetStatisticValue(StaticString statisticName)
        {
            if (this.IsDisabled)
            {
                return(-1f);
            }
            AchievementStatistic statistic = this.GetStatistic(statisticName);

            if (statistic != null)
            {
                return(statistic.Value);
            }
            return(-1f);
        }
Пример #4
0
        public void IncrementStatistic(StaticString statisticName, bool commit = false)
        {
            if (this.IsDisabled)
            {
                return;
            }
            AchievementStatistic statistic = this.GetStatistic(statisticName);

            if (statistic != null)
            {
                statistic.Increment();
                this.SetNetworkStatistic(statisticName, statistic.Value);
                if (commit)
                {
                    this.Commit();
                }
            }
        }