The Lifelet class represents a single lifeform in the simulation.
 public ShelledLifelet(Lifelet lifelet, World world)
 {
     // Init
     _lifelet = lifelet;
     _world = world;
     _validWorldAge = _world.Age;
 }
Exemplo n.º 2
0
 public Message(World world, char contents, Lifelet sender)
     : base(world,sender.Position)
 {
     // Init
     _contents = contents;
     _maxAge = Math2.JitteredValue(Config.MessageMaxAge,Config.MessageMaxAgeJitter);
     _sender = sender;
 }
 public double Distance(Lifelet other)
 {
     return this.Position.Distance(other.Position);
 }
Exemplo n.º 4
0
        public void Simulate()
        {
            // Init
            _highlightedLifelet = null;
            _age++;

            // Food
            foreach(Food food in _food) {
                food.Simulate();
            }

            // Messages
            foreach(Message message in _messages) {
                message.Simulate();
            }

            // Loop life forms
            foreach(Lifelet life in _lifelets) {

                // Simulate
                life.PrepareSimulate();
                life.Simulate();

                // Check that the simulation was performed properly
                if(life.DidSimulate != true) {
                    throw new Exception("Implementing class did not call base Simulate()!");
                }

                // Highlighted?
                if(life.Distance(new Vector(_cursor.X,_cursor.Y)) < Config.DisplayMouseSensitivity) _highlightedLifelet = life;
            }
        }
Exemplo n.º 5
0
 public void RemoveLifelet(Lifelet life)
 {
     _lifelets.Remove(life);
 }
 public double Distance(Lifelet other)
 {
     checkIfValid();
     return _lifelet.Distance(other);
 }
Exemplo n.º 7
0
 private void recieveEnergy(Lifelet sender, double amount)
 {
     //TODO: should we tax this with a conversion ratio?
     _energy += amount;
 }
Exemplo n.º 8
0
 private void recieveAttack(Lifelet sender, double amount)
 {
     //TODO: should we tax this with a conversion ratio?
     _health -= 50.0;//(amount*4); //TODO
 }