Exemplo n.º 1
0
            public RuntimeStefData(string uniqueID, float[] timeStack)
            {
                this.listStatus   = new List <StatusEffect.Runtime>();
                this.statusEffect = DatabaseStats.Load().GetStatusEffect(uniqueID);

                for (int i = 0; i < timeStack.Length; ++i)
                {
                    this.listStatus.Add(new StatusEffect.Runtime(
                                            timeStack[i], this.statusEffect.statusEffect
                                            ));
                }
            }
Exemplo n.º 2
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private void RequireInit(bool forceInit = false)
        {
            if (!forceInit && this.runtimeStatsData != null &&
                this.runtimeAttrsData != null && this.runtimeStefsData != null)
            {
                return;
            }

            this.runtimeStatsData = new Dictionary <string, RuntimeStatData>();
            this.runtimeAttrsData = new Dictionary <string, RuntimeAttrData>();
            this.runtimeStefsData = new Dictionary <string, RuntimeStefData>();

            StatAsset[] originStats = DatabaseStats.Load().GetStatAssets();
            AttrAsset[] originAttrs = DatabaseStats.Load().GetAttrAssets();

            if (STATS_TLB == null)
            {
                STATS_TLB = new Dictionary <string, string>();
                for (int i = 0; i < originStats.Length; ++i)
                {
                    STATS_TLB.Add(
                        originStats[i].stat.uniqueName,
                        originStats[i].uniqueID
                        );
                }
            }

            for (int i = 0; i < originStats.Length; ++i)
            {
                this.runtimeStatsData.Add(
                    originStats[i].uniqueID,
                    new RuntimeStatData(i, originStats[i])
                    );
            }

            int statsOverridesCount = this.statsOverrides.Count;

            for (int i = 0; i < statsOverridesCount; ++i)
            {
                string uniqueID = this.statsOverrides[i].statUniqueID;
                if (this.runtimeStatsData.ContainsKey(uniqueID))
                {
                    if (this.statsOverrides[i].overrideValue)
                    {
                        this.runtimeStatsData[uniqueID].baseValue = this.statsOverrides[i].baseValue;
                    }

                    if (this.statsOverrides[i].overrideFormula)
                    {
                        this.runtimeStatsData[uniqueID].formula = this.statsOverrides[i].formula;
                    }
                }
            }

            if (ATTRS_TLB == null)
            {
                ATTRS_TLB = new Dictionary <string, string>();
                for (int i = 0; i < originAttrs.Length; ++i)
                {
                    ATTRS_TLB.Add(
                        originAttrs[i].attribute.uniqueName,
                        originAttrs[i].uniqueID
                        );
                }
            }

            for (int i = 0; i < originAttrs.Length; ++i)
            {
                if (!originAttrs[i].attribute.stat)
                {
                    Debug.LogErrorFormat(
                        "Attribute {0} has no Stat assigned",
                        originAttrs[i].attribute.uniqueName
                        );
                    continue;
                }

                string statName = originAttrs[i].attribute.stat.stat.uniqueName;
                float  value    = Mathf.Lerp(
                    originAttrs[i].attribute.minValue,
                    this.GetStat(statName),
                    originAttrs[i].attribute.percent
                    );

                this.runtimeAttrsData.Add(
                    originAttrs[i].uniqueID,
                    new RuntimeAttrData(i, value, originAttrs[i])
                    );

                this.AddOnChangeStatUpdateAttribute(originAttrs[i].uniqueID);
            }
        }