C# Class MBC.Shared.Entities.Ship

Inheritance: System.Entity
Mostrar archivo Open project: aiclub/Mohawk_Battleship Class Usage Examples

Public Methods

Method Description
ConflictsWith ( Ship otherShip ) : bool

Checks if another Ship occupies any cells that this Ship occupies.

Hit ( Coordinates coords ) : void

Hits the ship at the coordinates.

IsAt ( Coordinates location ) : bool

Indicates whether or not a location is an occupied cell.

IsHitAt ( Coordinates location ) : bool

Checks whether the hit flag has been set at the specific ship location index.

IsSunk ( ) : bool

Place ( Coordinates location, ShipOrientation orientation ) : void

Places this Ship with the location and orientation. Sets the state of being placed to true.

Reset ( ) : void

Resets the ship back to its initialized state.

Ship ( System.Entity parent, int length ) : System

Sets the length of the Ship to length. The length must be at least 1.

Ship ( Ship shipCopy ) : System

Copies an existing Ship.

Sink ( ) : void

Sinks the ship

ToString ( ) : string

Provides a string representation.

Private Methods

Method Description
GetAllLocations ( ) : IEnumerable

Method Details

ConflictsWith() public method

Checks if another Ship occupies any cells that this Ship occupies.
public ConflictsWith ( Ship otherShip ) : bool
otherShip Ship The to check for confliction with.
return bool

Hit() public method

Hits the ship at the coordinates.
public Hit ( Coordinates coords ) : void
coords Coordinates
return void

IsAt() public method

Indicates whether or not a location is an occupied cell.
public IsAt ( Coordinates location ) : bool
location Coordinates The of the location to check.
return bool

IsHitAt() public method

Checks whether the hit flag has been set at the specific ship location index.
public IsHitAt ( Coordinates location ) : bool
location Coordinates
return bool

IsSunk() public method

public IsSunk ( ) : bool
return bool

Place() public method

Places this Ship with the location and orientation. Sets the state of being placed to true.
public Place ( Coordinates location, ShipOrientation orientation ) : void
location Coordinates The of the bottom-most/left-most part of /// the .
orientation ShipOrientation The to set.
return void

Reset() public method

Resets the ship back to its initialized state.
public Reset ( ) : void
return void

Ship() public method

Sets the length of the Ship to length. The length must be at least 1.
Thrown when the is less /// than 1.
public Ship ( System.Entity parent, int length ) : System
parent System.Entity
length int The number of cells the occupies.
return System

Ship() public method

Copies an existing Ship.
public Ship ( Ship shipCopy ) : System
shipCopy Ship
return System

Sink() public method

Sinks the ship
public Sink ( ) : void
return void

ToString() public method

Provides a string representation.
public ToString ( ) : string
return string