private static void MoveRandomPiece(ChessPieceColor color, List <ChessPiece> pieces) { MovementCommandBase movement; var turnPieces = pieces.Where(p => p.Color == color).ToList(); var nextPieceIndex = random.Next(turnPieces.Count()); var nextPiece = turnPieces[nextPieceIndex]; var nextPieceType = nextPiece.GetType(); if (nextPieceType == typeof(Peon)) { movement = new PeonMovement(boardService); } else if (nextPieceType == typeof(Horse)) { movement = new HorseMovement(boardService); } else { movement = new BishopMovement(boardService); } movement.MovePiece(nextPiece); }
private void Awake() { movement = new BishopMovement(); }