Exemple #1
0
        public Organism(DNA dna)
            : this()
        {
            DNA = dna;

            var genes = GeneInterpreter.Interprit(DNA);

            ApplyTraits(genes);

            LoadUpdateBlocks(genes);
            LoadCollisionHandlers(genes);
        }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            GeneInterpreter.CheckMakerIntegrity();

            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            Circle       = Content.Load <Texture2D>("circle");
            Virus        = Content.Load <Texture2D>("virus");
            Sprint       = Content.Load <Texture2D>("sprint");

            for (int i = 0; i < 2; i++)
            {
                ObjectManager.Instance.Add(new Organism(new DNA("prey.txt")));
                ObjectManager.Instance.Add(new Organism(new DNA("predator.txt")));
                ObjectManager.Instance.Add(new Organism(new DNA("predator.txt")));
            }

            if (Directory.Exists("Genomes"))
            {
                var files = Directory.GetFiles("Genomes", "*.dna");

                foreach (var file in files)
                {
                    ObjectManager.Instance.Add(new Organism(new DNA(file)));
                }
            }

            for (int i = 0; i < 2; i++)
            {
                ObjectManager.Instance.Add(new Organism(new DNA(20, 60)));
            }

            for (int i = 0; i < 50; i++)
            {
                ObjectManager.Instance.Add(new Food(new Vector2(Random.Next(Width), Random.Next(Height)), Random.Next(100, 500)));
            }

            // TODO: use this.Content to load your game content here
        }