Example #1
0
        public void SaveCreatures(IEnumerable <Creature> creatures)
        {
            var creatureRecords = creatures.Select(c => new CreatureRecord
            {
                Id       = Guid.NewGuid(),
                ParentId = c.Parent,
                Dna      = DnaInterpreter.Encode(DnaInterpreter.Processors, c.Dna)
            }).ToList();

            _storageController.Save(creatureRecords);
        }
Example #2
0
        private CreatureRecord[] CreateBase()
        {
            var dna = new int[RedirectProcessor.DnaLength];

            DnaInterpreter.Encode(DnaInterpreter.Processors, DnaInterpreter.DefaultDnaDecrypted).CopyTo(dna, 0);

            var record = new CreatureRecord
            {
                Id       = Guid.NewGuid(),
                ParentId = null,
                Dna      = dna
            };
            var records = new CreatureRecord[DnaProcessor.GenerationSetCount];

            for (var i = 0; i < DnaProcessor.GenerationSetCount; i++)
            {
                records[i] = record;
            }

            return(records);
        }