C# 클래스 Terrarium.Game.WorldState

파일 보기 프로젝트 열기: eugeniomiro/Terrarium 1 사용 예제들

공개 메소드들

메소드 설명
AddOrganism ( OrganismBase.OrganismState state ) : void

Should only be called by the GameEngine.

BuildIndex ( ) : void

Build the cell index.

ClearIndex ( ) : void

Clear the current cell index.

DuplicateMutable ( ) : object

Copies the object, but not the isImmutable bit. Makes a newly immutable copy.

FillCells ( OrganismBase.OrganismState state, int cellX, int cellY, int cellRadius, System.Boolean clear ) : void

Fills in the appropriate grid cells in our CellIndex given the organism state.

FindOrganisms ( int x1, int x2, int y1, int y2 ) : ArrayList

Find organisms with the given rectangular area.

FindOrganismsInCells ( int minGridX, int maxGridX, int minGridY, int maxGridY ) : ArrayList

Finds all organisms within a range of cells.

FindOrganismsInView ( OrganismBase.OrganismState state, int radius ) : ArrayList

Find a list of organisms within the view of the given organism.

GetAvailableLight ( OrganismBase.PlantState plant ) : int

Percentage of light reaching this plant. We assume the sun moves from east to west directly overhead We get a rough estimation like this: Get all plants with a certain radius whose radius blocks any East-West vector that intersects any part of the radius of the plant in question -- assume they block it completely Figure out which blocks it at the highest angle. Discount the amount of light the plant sees by angle / 180

GetOrganismState ( string organismID ) : OrganismBase.OrganismState

Retrieve the organism state from the world state for the given ID.

IsGridCellOccupied ( int cellX, int cellY ) : System.Boolean

Used to determine if a grid cell is occupied.

MakeImmutable ( ) : void

Makes all portions of the world state immutable including all organism state objects.

OnlyOverlapsSelf ( OrganismBase.OrganismState state ) : System.Boolean

Make sure the organism only overlaps itself and not other organisms.

RefreshOrganism ( OrganismBase.OrganismState state ) : void

Should only be called by the game engine. Should be called if the state of the organism changes.

RemoveOrganism ( string organismID ) : void

Should only be called by the game engine. Removes an organism from the world state.

WorldState ( int gridWidth, int gridHeight ) : System

Creates a new world state with the given number of grid cells.

비공개 메소드들

메소드 설명
buildIndexInternal ( bool isDeserializing ) : void

Builds the cell index.

메소드 상세

AddOrganism() 공개 메소드

Should only be called by the GameEngine.
public AddOrganism ( OrganismBase.OrganismState state ) : void
state OrganismBase.OrganismState The state of the organism to add.
리턴 void

BuildIndex() 공개 메소드

Build the cell index.
public BuildIndex ( ) : void
리턴 void

ClearIndex() 공개 메소드

Clear the current cell index.
public ClearIndex ( ) : void
리턴 void

DuplicateMutable() 공개 메소드

Copies the object, but not the isImmutable bit. Makes a newly immutable copy.
public DuplicateMutable ( ) : object
리턴 object

FillCells() 공개 메소드

Fills in the appropriate grid cells in our CellIndex given the organism state.
public FillCells ( OrganismBase.OrganismState state, int cellX, int cellY, int cellRadius, System.Boolean clear ) : void
state OrganismBase.OrganismState The state of the organism being added.
cellX int The location of the organism in cells.
cellY int The location of the organism in cells.
cellRadius int The radius in cells of the organism.
clear System.Boolean Determines if cells should be cleared or set.
리턴 void

FindOrganisms() 공개 메소드

Find organisms with the given rectangular area.
public FindOrganisms ( int x1, int x2, int y1, int y2 ) : ArrayList
x1 int Part of the location rectangle.
x2 int Part of the location rectangle.
y1 int Part of the location rectangle.
y2 int Part of the location rectangle.
리턴 System.Collections.ArrayList

FindOrganismsInCells() 공개 메소드

Finds all organisms within a range of cells.
public FindOrganismsInCells ( int minGridX, int maxGridX, int minGridY, int maxGridY ) : ArrayList
minGridX int Leftmost grid cell
maxGridX int Rightmost grid cell
minGridY int Topmost grid cell
maxGridY int Bottommost grid cell
리턴 System.Collections.ArrayList

FindOrganismsInView() 공개 메소드

Find a list of organisms within the view of the given organism.
public FindOrganismsInView ( OrganismBase.OrganismState state, int radius ) : ArrayList
state OrganismBase.OrganismState The state of the organism to check.
radius int The radius of vision.
리턴 System.Collections.ArrayList

GetAvailableLight() 공개 메소드

Percentage of light reaching this plant. We assume the sun moves from east to west directly overhead We get a rough estimation like this: Get all plants with a certain radius whose radius blocks any East-West vector that intersects any part of the radius of the plant in question -- assume they block it completely Figure out which blocks it at the highest angle. Discount the amount of light the plant sees by angle / 180
public GetAvailableLight ( OrganismBase.PlantState plant ) : int
plant OrganismBase.PlantState The plant to get light for.
리턴 int

GetOrganismState() 공개 메소드

Retrieve the organism state from the world state for the given ID.
public GetOrganismState ( string organismID ) : OrganismBase.OrganismState
organismID string The ID to match an organism state.
리턴 OrganismBase.OrganismState

IsGridCellOccupied() 공개 메소드

Used to determine if a grid cell is occupied.
public IsGridCellOccupied ( int cellX, int cellY ) : System.Boolean
cellX int The cell index.
cellY int The cell index.
리턴 System.Boolean

MakeImmutable() 공개 메소드

Makes all portions of the world state immutable including all organism state objects.
public MakeImmutable ( ) : void
리턴 void

OnlyOverlapsSelf() 공개 메소드

Make sure the organism only overlaps itself and not other organisms.
public OnlyOverlapsSelf ( OrganismBase.OrganismState state ) : System.Boolean
state OrganismBase.OrganismState The state of the organism to check.
리턴 System.Boolean

RefreshOrganism() 공개 메소드

Should only be called by the game engine. Should be called if the state of the organism changes.
public RefreshOrganism ( OrganismBase.OrganismState state ) : void
state OrganismBase.OrganismState The state of the organism to refresh.
리턴 void

RemoveOrganism() 공개 메소드

Should only be called by the game engine. Removes an organism from the world state.
public RemoveOrganism ( string organismID ) : void
organismID string The ID of the organism that needs to be removed.
리턴 void

WorldState() 공개 메소드

Creates a new world state with the given number of grid cells.
public WorldState ( int gridWidth, int gridHeight ) : System
gridWidth int The width of the world state in grid cells.
gridHeight int The height of the world state in grid cells.
리턴 System