public LifeformStats(string id, int maxSpeedgain, SpawnLifeform spawn)
        {
            this.Fields    = new object[11];
            this.Fields[0] = EntityType.LIFEFORM_STATS;

            this.Id            = id;
            this.Genom         = spawn.Genom;
            this.P1Genom       = spawn.P1Genom;
            this.P2Genom       = spawn.P2Genom;
            this.Life          = spawn.Life;
            this.Generation    = spawn.Generation;
            this.VisualRange   = spawn.VisualRange;
            this.MaxNrChildren = spawn.MaxNrChildren;
            this.Speed         = Math.Min(maxSpeedgain, spawn.Speed);
            this.InitialLife   = spawn.Life;
        }
Example #2
0
        public Lifeform(SpawnLifeform spawn, int width, int height, ISpace ts) : base(spawn.Genom.ToString(), ts)
        {
            string id = Guid.NewGuid().ToString();

            this.rng          = new Random(Environment.TickCount);
            this.nrChildren   = 0;
            this.maxSpeedgain = 40;
            this.breedingCost = 50;
            this.maxFood      = this.breedingCost * 2;
            this.targetMate   = null;
            this.targetFood   = null;
            this.width        = width;
            this.height       = height;
            this.Stats        = new LifeformStats(id, this.maxSpeedgain, spawn);
            this.Position     = new Position(id, spawn.X, spawn.Y);
            this.FoodAmount   = spawn.Food;
        }