public SaveData Load(string path = null)
        {
            var result       = new SaveData();
            var collectibles = new List <CollectibleData>();

            result.collectibles = new CollectibleData[0];
            var playerPos = PlayerPrefsX.GetVector3(playerPosition);

            result.playerPosition = playerPos;

            var position            = PlayerPrefsX.GetVector3Array(collectiblePositions);
            var mandatory           = PlayerPrefsX.GetBoolArray(collectibleIsMandatory);
            var isFake              = PlayerPrefsX.GetBoolArray(effectFakeFlag);
            var effectType          = PlayerPrefsX.GetIntArray(effectTypes);
            var effectDurationsType = PlayerPrefsX.GetIntArray(effectDurationsTypes);
            var effectAffectStat    = PlayerPrefsX.GetIntArray(effectAffectStats);
            var effectRegen         = PlayerPrefsX.GetBoolArray(effectRegens);
            var effectAmount        = PlayerPrefsX.GetFloatArray(effectAmounts);
            var effectDuration      = PlayerPrefsX.GetFloatArray(effectDurations);
            var effectIconName      = PlayerPrefsX.GetStringArray(effectIconNames);

            var lenght = position.Length;

            if (mandatory.Length == lenght &&
                effectType.Length == lenght &&
                effectDurationsType.Length == lenght &&
                effectAffectStat.Length == lenght &&
                effectRegen.Length == lenght &&
                effectAmount.Length == lenght &&
                effectDuration.Length == lenght &&
                effectIconName.Length == lenght
                )
            {
                for (var i = 0; i < lenght; i++)
                {
                    EffectData effectData;
                    if (isFake[i])
                    {
                        effectData = EffectData.MakeFakeData();
                    }
                    else
                    {
                        effectData = new EffectData()
                        {
                            gameEffectType = (EffectType)effectType[i],
                            durationType   = (EffectDuration)effectDurationsType[i],
                            gameStatType   = (StatType)effectAffectStat[i],
                            affectRegen    = effectRegen[i],
                            amount         = effectAmount[i],
                            duration       = effectDuration[i],
                            iconName       = effectIconName[i]
                        };
                    }
                    var collectible = new CollectibleData(position[i], mandatory[i], effectData);
                    collectibles.Add(collectible);
                }

                result.collectibles = collectibles.ToArray();
                return(result);
            }
            else
            {
                Debug.LogError("Effect prefs data corrupted");
                return(result);
            }
        }
예제 #2
0
 public CollectibleData(Vector3 position, bool isMandatory, EffectData effectData)
 {
     this.position    = position;
     this.isMandatory = isMandatory;
     this.effectData  = effectData;
 }