public Wolf(Texture2D texture, Color color, int radius, Vector2 startingPosition, Vector2 velocity, Organism.OrganismType organismType, float initialEnergy, float visionRadius, float reproductionThreshold, Dictionary<Organism.OrganismType, Reaction> reactionDictionary) : base(texture, color, radius, startingPosition, velocity, organismType, initialEnergy, visionRadius, reproductionThreshold, reactionDictionary) { Texture = texture; Color = color; Radius = radius; Position = startingPosition; Velocity = velocity; MyType = organismType; Energy = initialEnergy; VisionRadius = visionRadius; ReproductionThreshold = reproductionThreshold; ReactionDictionary = reactionDictionary; Rando = new Random(); alive = true; }
//called when organism is in direct contact with 'something it can consume' public override void Consume(Organism o) { Velocity = new Vector2(0, 0); o.Velocity = new Vector2(0, 0); if (o.Energy > 1f) { Energy += o.Energy * .05f; o.Energy -= o.Energy * .05f; } else { Energy += o.Energy; o.Energy = 0; o.alive = false; } //Velocity = new Vector2(Rando.Next(-5, 5), Rando.Next(-5, 5)); }
public virtual Organism Reproduce() { Vector2 startPos = Position + new Vector2(Rando.Next(-25, 25), Rando.Next(-25, 25)); Organism o = new Organism(Texture, Color, Radius, startPos, new Vector2(Rando.Next(-5, 5), Rando.Next(-5, 5)), MyType, Energy / 2, VisionRadius, ReproductionThreshold, ReactionDictionary); Energy = Energy / 2; return o; }
//called when organism is in direct contact with 'something it can consume' public virtual void Consume(Organism o) { Velocity = new Vector2(0, 0); o.Velocity = new Vector2(0, 0); Energy += o.Energy; o.Energy = 0; o.alive = false; //Velocity = new Vector2(Rando.Next(-5, 5), Rando.Next(-5, 5)); }