C# Class LifeSimulation.Core.Lifelet

The Lifelet class represents a single lifeform in the simulation.
Afficher le fichier Open project: dankrusi/life-simulation-challenge Class Usage Examples

Méthodes publiques

Méthode Description
Distance ( Lifelet other ) : double

Measures the distance from this lifelet to another.

Distance ( ShelledLifelet other ) : double

Measures the distance from this lifelet to another.

Distance ( Vector point ) : double

Measures the distance from this lifelet to a specific point.

Draw ( Graphics g ) : void

Draws the current state of the lifelet to the graphics context.

Lifelet ( World world, Vector pos ) : System

Initializes a new instance of the LifeSimulation.Core.Lifelet class.

PrepareSimulate ( ) : void

Prepares a lifelet for simulation by an extending class.

Shell ( ) : ShelledLifelet
Simulate ( ) : void

Simulate this instance for one timestep. Extending classes must call base.Simulate() otherwise they are disqualified.

VerifyIntegrity ( ) : void

Méthodes protégées

Méthode Description
attack ( ShelledLifelet other, double amount ) : void

Attacks another lifelet with the given amount of energy.

audibleMessages ( ) : List

Returns all audible messages.

closestLifelet ( ) : ShelledLifelet

Returns the closest visible lifelet.

debugDraw ( Graphics g ) : void
getLifeletByUID ( long uid ) : ShelledLifelet

Returns the visible lifelet by UID.

giveEnergy ( ShelledLifelet other, double amount ) : void

Gives a specific amount of energy to another lifelet.

move ( Vector v ) : void

Sets a request to move the lifelet with the given velocity.

moveRandomly ( double speed ) : void

Sets a request to move the lifelet randomly with the given speed.

moveToDestination ( Vector destination, double speed ) : void

Sets a request to move the lifelet in the direction of destination with the given speed.

talk ( char message ) : void

Creates a new message originating from this lifelet.

visibleFood ( ) : List

Returns all visible food.

visibleLifelets ( ) : List

Returns all visible lifelets.

Private Methods

Méthode Description
die ( ) : void
recieveAttack ( Lifelet sender, double amount ) : void
recieveEnergy ( Lifelet sender, double amount ) : void

Method Details

Distance() public méthode

Measures the distance from this lifelet to another.
public Distance ( Lifelet other ) : double
other Lifelet
Résultat double

Distance() public méthode

Measures the distance from this lifelet to another.
public Distance ( ShelledLifelet other ) : double
other ShelledLifelet
Résultat double

Distance() public méthode

Measures the distance from this lifelet to a specific point.
public Distance ( Vector point ) : double
point Vector
Résultat double

Draw() public méthode

Draws the current state of the lifelet to the graphics context.
public Draw ( Graphics g ) : void
g System.Drawing.Graphics
Résultat void

Lifelet() public méthode

Initializes a new instance of the LifeSimulation.Core.Lifelet class.
public Lifelet ( World world, Vector pos ) : System
world World
pos Vector
Résultat System

PrepareSimulate() public méthode

Prepares a lifelet for simulation by an extending class.
public PrepareSimulate ( ) : void
Résultat void

Shell() public méthode

public Shell ( ) : ShelledLifelet
Résultat ShelledLifelet

Simulate() public méthode

Simulate this instance for one timestep. Extending classes must call base.Simulate() otherwise they are disqualified.
public Simulate ( ) : void
Résultat void

VerifyIntegrity() public méthode

public VerifyIntegrity ( ) : void
Résultat void

attack() protected méthode

Attacks another lifelet with the given amount of energy.
protected attack ( ShelledLifelet other, double amount ) : void
other ShelledLifelet
amount double
Résultat void

audibleMessages() protected méthode

Returns all audible messages.
protected audibleMessages ( ) : List
Résultat List

closestLifelet() protected méthode

Returns the closest visible lifelet.
protected closestLifelet ( ) : ShelledLifelet
Résultat ShelledLifelet

debugDraw() protected méthode

protected debugDraw ( Graphics g ) : void
g System.Drawing.Graphics
Résultat void

getLifeletByUID() protected méthode

Returns the visible lifelet by UID.
protected getLifeletByUID ( long uid ) : ShelledLifelet
uid long
Résultat ShelledLifelet

giveEnergy() protected méthode

Gives a specific amount of energy to another lifelet.
protected giveEnergy ( ShelledLifelet other, double amount ) : void
other ShelledLifelet
amount double
Résultat void

move() protected méthode

Sets a request to move the lifelet with the given velocity.
protected move ( Vector v ) : void
v Vector
Résultat void

moveRandomly() protected méthode

Sets a request to move the lifelet randomly with the given speed.
protected moveRandomly ( double speed ) : void
speed double
Résultat void

moveToDestination() protected méthode

Sets a request to move the lifelet in the direction of destination with the given speed.
protected moveToDestination ( Vector destination, double speed ) : void
destination Vector
speed double
Résultat void

talk() protected méthode

Creates a new message originating from this lifelet.
protected talk ( char message ) : void
message char
Résultat void

visibleFood() protected méthode

Returns all visible food.
protected visibleFood ( ) : List
Résultat List

visibleLifelets() protected méthode

Returns all visible lifelets.
protected visibleLifelets ( ) : List
Résultat List