Chess Game  1.1.0
A full chess game for Unity
cgChessPieceScript Class Reference

This script controls the piece on the board, it alters graphics according to promotions/reverts and registers mouse down and mouse up events for dragging purposes More...

Inherits MonoBehaviour.

Public Types

enum  Type {
  WhitePawn = 1, WhiteRook = 2, WhiteKnight = 3, WhiteBishop = 4,
  WhiteQueen = 5, WhiteKing = 6, BlackPawn = -1, BlackRook = -2,
  BlackKnight = -3, BlackBishop = -4, BlackQueen = -5, BlackKing = -6
}
 All possible chess types. More...
 

Public Member Functions

void SetCallbacks (Action< cgChessPieceScript > onDown, Action< cgChessPieceScript > onUp)
 Set mouse callbacks to allow this instance to be dragged and dropped. More...
 
void SetType (Type toType)
 Set the type of this piece, changes its sprite accordingly. Useful when reverting moves, or when pawns are promoted. More...
 
void SetType (int toType)
 Set the type of this piece, changes its sprite accordingly. Useful when reverting moves, or when pawns are promoted. More...
 
void StartAtSquare (cgSquareScript startSquare)
 Start at provided square. More...
 
void moveToSquare (cgSquareScript newSquare)
 Move to a new square. More...
 

Public Attributes

cgSquareScript square
 The current square being occupied by this instance. More...
 
Type type = Type.WhitePawn
 The type of this piece. More...
 
bool displayAs3D
 Should we display as 3d?(true) or 2d(false). More...
 
GameObject twoDPieceHolder
 If displaying as 2d, we will use the sprites insde this Holder. More...
 
GameObject threeDPieceHolder
 If displaying as 3d, we will use the models insde this Holder. More...
 
bool dead = false
 Is this instance dead? More...
 

Properties

bool white [get]
 Is this piece white? More...
 

Detailed Description

This script controls the piece on the board, it alters graphics according to promotions/reverts and registers mouse down and mouse up events for dragging purposes

Member Enumeration Documentation

◆ Type

All possible chess types.

Member Function Documentation

◆ moveToSquare()

void cgChessPieceScript.moveToSquare ( cgSquareScript  newSquare)

Move to a new square.

Parameters
newSquarethe new square to move to.

◆ SetCallbacks()

void cgChessPieceScript.SetCallbacks ( Action< cgChessPieceScript onDown,
Action< cgChessPieceScript onUp 
)

Set mouse callbacks to allow this instance to be dragged and dropped.

Parameters
onDownCallback for mouse down
onUpCallback for mouse up

◆ SetType() [1/2]

void cgChessPieceScript.SetType ( Type  toType)

Set the type of this piece, changes its sprite accordingly. Useful when reverting moves, or when pawns are promoted.

Parameters
toTypeThe type to change to.

◆ SetType() [2/2]

void cgChessPieceScript.SetType ( int  toType)

Set the type of this piece, changes its sprite accordingly. Useful when reverting moves, or when pawns are promoted.

Parameters
toTypeThe type to change to.

◆ StartAtSquare()

void cgChessPieceScript.StartAtSquare ( cgSquareScript  startSquare)

Start at provided square.

Parameters
startSquarethe starting square.

Member Data Documentation

◆ dead

bool cgChessPieceScript.dead = false

Is this instance dead?

◆ displayAs3D

bool cgChessPieceScript.displayAs3D

Should we display as 3d?(true) or 2d(false).

◆ square

cgSquareScript cgChessPieceScript.square

The current square being occupied by this instance.

◆ threeDPieceHolder

GameObject cgChessPieceScript.threeDPieceHolder

If displaying as 3d, we will use the models insde this Holder.

◆ twoDPieceHolder

GameObject cgChessPieceScript.twoDPieceHolder

If displaying as 2d, we will use the sprites insde this Holder.

◆ type

Type cgChessPieceScript.type = Type.WhitePawn

The type of this piece.

Property Documentation

◆ white

bool cgChessPieceScript.white
get

Is this piece white?


The documentation for this class was generated from the following file: