public Lifelet UnshellLifelet(ShelledLifelet shelled) { //TODO: This is not very efficient... Should we re-write LoopList as a Hashtable? foreach(Lifelet lifelet in _lifelets) { if(shelled.UID == lifelet.UID) return lifelet; } return null; }
public double Distance(ShelledLifelet other) { checkIfValid(); return _lifelet.Distance(other); }
/// <summary> /// Attacks another lifelet with the given amount of energy. /// </summary> protected void attack(ShelledLifelet other, double amount) { // Check delay if(!this.CanAttack) return; // Make sure we have this energy to give and we are in distance if(this.Energy >= amount && this.Distance(other) < Config.LifeletMaximumAttackRange) { _energy -= amount; _world.UnshellLifelet(other).recieveAttack(this,amount); } }
/// <summary> /// Gives a specific amount of energy to another lifelet. /// </summary> protected void giveEnergy(ShelledLifelet other, double amount) { // Check delay if(!this.CanGiveEnergy) return; // Make sure we have this energy to give and we are in distance if(this.Energy >= amount && this.Distance(other) < this.Visibility) { _energy -= amount; _world.UnshellLifelet(other).recieveEnergy(this,amount); } }
/// <summary> /// Measures the distance from this lifelet to another. /// </summary> public double Distance(ShelledLifelet other) { return this.Position.Distance(other.Position); }