C# Class LifeSimulation.Core.Lifelet

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

Public Methods

Method 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

Protected Methods

Method 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

Method Description
die ( ) : void
recieveAttack ( Lifelet sender, double amount ) : void
recieveEnergy ( Lifelet sender, double amount ) : void

Method Details

Distance() public method

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

Distance() public method

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

Distance() public method

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

Draw() public method

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

Lifelet() public method

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

PrepareSimulate() public method

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

Shell() public method

public Shell ( ) : ShelledLifelet
return ShelledLifelet

Simulate() public method

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

VerifyIntegrity() public method

public VerifyIntegrity ( ) : void
return void

attack() protected method

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

audibleMessages() protected method

Returns all audible messages.
protected audibleMessages ( ) : List
return List

closestLifelet() protected method

Returns the closest visible lifelet.
protected closestLifelet ( ) : ShelledLifelet
return ShelledLifelet

debugDraw() protected method

protected debugDraw ( Graphics g ) : void
g System.Drawing.Graphics
return void

getLifeletByUID() protected method

Returns the visible lifelet by UID.
protected getLifeletByUID ( long uid ) : ShelledLifelet
uid long
return ShelledLifelet

giveEnergy() protected method

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

move() protected method

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

moveRandomly() protected method

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

moveToDestination() protected method

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
return void

talk() protected method

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

visibleFood() protected method

Returns all visible food.
protected visibleFood ( ) : List
return List

visibleLifelets() protected method

Returns all visible lifelets.
protected visibleLifelets ( ) : List
return List