Beispiel #1
0
        public virtual void Load(string filename, WorldSaveData saveData)
        {
            _context.SetStore(nameof(World), this);
            _context.SetStore(nameof(Player), Player.Instance);

            if (AudioManager.Instance && World.BackgroundMusic)
            {
                AudioManager.Instance.Push(World.BackgroundMusic, 0.0f, 1.0f, 0.0f);
            }

            _variables.LoadFrom(saveData.PersistentVariables, VariableDefinition.Saved);

            foreach (var zoneData in saveData.Zones)
            {
                var zone = World.GetZoneByName(zoneData.Name);
                var data = zone != null?GetZone(zone) : null;

                if (data != null)
                {
                    data.Load(zoneData);
                }
            }

            SaveFilename = filename;
        }
Beispiel #2
0
        protected virtual void SetupVariables(VariableList savedVariables)
        {
            if (_propertyMap == null)
            {
                _propertyMap = new PropertyMap <Player>();
                AddPropertiesToMap(_propertyMap);
            }

            if (_variableMap == null || _variableMap.Version != WorldManager.Instance.World.PlayerSchema.Version)
            {
                _variableMap = new VariableMap(WorldManager.Instance.World.PlayerSchema.Version)
                               .Add(_propertyMap)
                               .Add(WorldManager.Instance.World.PlayerSchema);
            }

            _variableStore.Setup(_variableMap, new PropertyList <Player>(this, _propertyMap), new VariableListener(this, _variables));
            _variables.Setup(WorldManager.Instance.World.PlayerSchema, this);
            _variables.LoadFrom(savedVariables, VariableDefinition.Saved);
        }
Beispiel #3
0
        public virtual void Load(NpcSaveData saveData)
        {
            SetupVariables();

            if (saveData != null)
            {
                _variables.LoadFrom(saveData.NpcTraits, VariableDefinition.Saved);

                if (Controller)
                {
                    Controller.Mover.WarpToPosition(saveData.Position, saveData.Direction, CollisionLayer.None);
                    Controller.Load(saveData.ControllerData);
                }

                if (Trainer)
                {
                    Trainer.Traits.LoadFrom(saveData.TrainerTraits, VariableDefinition.Saved);
                }
            }
        }
Beispiel #4
0
        protected virtual void Load(CreatureSaveData data)
        {
            Name           = data.Name;
            _learnedSkills = data.LearnedSkills;
            Traits.LoadFrom(data.Traits, VariableDefinition.Saved);

            foreach (var moveData in data.Moves)
            {
                var move = Move.Create(this, moveData);

                if (move != null)
                {
                    Moves.Add(move);
                }
                else
                {
                    Debug.LogWarningFormat(this, _missingAbilityWarning, Name);
                }
            }
        }
Beispiel #5
0
 protected virtual void Load(MoveSaveData data)
 {
     Name = data.Name;
     Traits.LoadFrom(data.Traits, VariableDefinition.Saved);
 }
Beispiel #6
0
 public virtual void Load(ZoneSaveData saveData)
 {
     _variables.LoadFrom(saveData.PersistentVariables, VariableDefinition.Saved);
     _npcData = saveData.Npcs.ToDictionary(npc => npc.Id);
 }